Merge pull request 'edited tones, added vibrate' (#8) from action-things into main
Reviewed-on: #8
This commit is contained in:
commit
bdc4fee8c2
Binary file not shown.
BIN
assets/audio/count_tone.mp3
Normal file
BIN
assets/audio/count_tone.mp3
Normal file
Binary file not shown.
Binary file not shown.
@ -53,7 +53,7 @@ Future<void> seedDb(AppDatabase database) async {
|
||||
// final int totalActions = 5;
|
||||
final int totalMedia = 5;
|
||||
final random = Random();
|
||||
|
||||
final whitespaceRE = RegExp(r"(?! )\s+| \s+");
|
||||
// we gotta build all the activities!
|
||||
final jsondata =
|
||||
await root_bundle.rootBundle.loadString('assets/exercises.json');
|
||||
@ -72,9 +72,12 @@ Future<void> seedDb(AppDatabase database) async {
|
||||
}
|
||||
|
||||
Map<Symbol, Value> payload = {
|
||||
Symbol('title'): Value<String>(exercise['name']),
|
||||
Symbol('description'):
|
||||
Value<String>(json.encode(exercise['instructions'])),
|
||||
Symbol('title'): Value<String>(
|
||||
exercise['name'].toString().trim().replaceAll(whitespaceRE, " ")),
|
||||
Symbol('description'): Value<String>(json.encode(exercise['instructions']
|
||||
.toString()
|
||||
.trim()
|
||||
.replaceAll(whitespaceRE, " "))),
|
||||
Symbol('force'): Value<String>(exercise['force'] ?? "")
|
||||
};
|
||||
|
||||
|
@ -3,11 +3,11 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_sound/public/flutter_sound_player.dart';
|
||||
import 'package:flutter_sound/flutter_sound.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import 'package:sendtrain/models/action_model.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
class ActionTimer with ChangeNotifier {
|
||||
ActionModel? actionModel;
|
||||
@ -56,6 +56,7 @@ class ActionTimer with ChangeNotifier {
|
||||
|
||||
void setup(ActionModel actionModel, ItemScrollController scrollController,
|
||||
[bool resetOnLoad = true]) async {
|
||||
_scrollControllers.clear();
|
||||
_scrollControllers.add(scrollController);
|
||||
|
||||
if (resetOnLoad) {
|
||||
@ -85,7 +86,7 @@ class ActionTimer with ChangeNotifier {
|
||||
Uint8List? countTone;
|
||||
Uint8List? finishTone;
|
||||
await rootBundle
|
||||
.load('assets/audio/count_tone.wav')
|
||||
.load('assets/audio/count_tone.mp3')
|
||||
.then((data) => countTone = data.buffer.asUint8List());
|
||||
await rootBundle
|
||||
.load('assets/audio/count_finish.mp3')
|
||||
@ -102,14 +103,25 @@ class ActionTimer with ChangeNotifier {
|
||||
_currentTime--;
|
||||
|
||||
if (_currentTime <= 3 && _currentTime != 0) {
|
||||
await _mPlayer.startPlayer(
|
||||
fromDataBuffer: countTone, codec: Codec.pcm16WAV);
|
||||
await _mPlayer
|
||||
.startPlayer(fromDataBuffer: countTone, codec: Codec.mp3)
|
||||
.then((duration) async {
|
||||
if (await Vibration.hasVibrator()) {
|
||||
Vibration.vibrate(duration: 250);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_currentTime == 0) {
|
||||
// move to next action
|
||||
await _mPlayer.startPlayer(
|
||||
fromDataBuffer: finishTone, codec: Codec.mp3);
|
||||
await _mPlayer
|
||||
.startPlayer(fromDataBuffer: finishTone, codec: Codec.mp3)
|
||||
.then((duration) async {
|
||||
if (await Vibration.hasVibrator()) {
|
||||
Vibration.vibrate(duration: 250);
|
||||
}
|
||||
});
|
||||
|
||||
await setAction(state['currentAction'] + 1);
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,8 @@ class _ActivityActionEditorState extends State<ActivityActionEditor> {
|
||||
// create action
|
||||
await ActionsDao(db)
|
||||
.createOrUpdate(ActionsCompanion(
|
||||
title: Value('title'),
|
||||
description: Value('description'),
|
||||
title: Value('rep'),
|
||||
description: Value('exercise action'),
|
||||
totalSets: Value(int.parse(
|
||||
actionEditController['sets']!
|
||||
.text)),
|
||||
|
@ -80,7 +80,7 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
distance: 70,
|
||||
type: ExpandableFabType.up,
|
||||
overlayStyle: ExpandableFabOverlayStyle(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
color: Colors.black.withValues(alpha: 0.5),
|
||||
blur: 10,
|
||||
),
|
||||
onOpen: () {
|
||||
|
@ -4,7 +4,7 @@ import 'package:sendtrain/providers/action_timer.dart';
|
||||
|
||||
Future showGenericDialog(dynamic object, BuildContext parentContext) {
|
||||
return showGeneralDialog(
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
barrierColor: Colors.black.withValues(alpha: 0.5),
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
transitionBuilder: (BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation, Widget child) {
|
||||
|
@ -78,7 +78,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
distance: 70,
|
||||
type: ExpandableFabType.up,
|
||||
overlayStyle: ExpandableFabOverlayStyle(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
color: Colors.black.withValues(alpha: 0.5),
|
||||
blur: 10,
|
||||
),
|
||||
children: [
|
||||
|
@ -53,6 +53,7 @@ dependencies:
|
||||
dart_casing: ^3.0.1
|
||||
collection: ^1.18.0
|
||||
flutter_sound: ^9.23.1
|
||||
vibration: ^3.1.2
|
||||
|
||||
flutter_launcher_name:
|
||||
name: "SendTrain"
|
||||
|
Loading…
x
Reference in New Issue
Block a user