Compare commits

..

No commits in common. "bdc4fee8c2ac771901e40f78ae1d00a10c88f7a2" and "2eda79737562dfc7b80dd9d2d4f43d0072884488" have entirely different histories.

10 changed files with 15 additions and 31 deletions

Binary file not shown.

Binary file not shown.

BIN
assets/audio/count_tone.wav Normal file

Binary file not shown.

View File

@ -53,7 +53,7 @@ Future<void> seedDb(AppDatabase database) async {
// final int totalActions = 5; // final int totalActions = 5;
final int totalMedia = 5; final int totalMedia = 5;
final random = Random(); final random = Random();
final whitespaceRE = RegExp(r"(?! )\s+| \s+");
// we gotta build all the activities! // we gotta build all the activities!
final jsondata = final jsondata =
await root_bundle.rootBundle.loadString('assets/exercises.json'); await root_bundle.rootBundle.loadString('assets/exercises.json');
@ -72,12 +72,9 @@ Future<void> seedDb(AppDatabase database) async {
} }
Map<Symbol, Value> payload = { Map<Symbol, Value> payload = {
Symbol('title'): Value<String>( Symbol('title'): Value<String>(exercise['name']),
exercise['name'].toString().trim().replaceAll(whitespaceRE, " ")), Symbol('description'):
Symbol('description'): Value<String>(json.encode(exercise['instructions'] Value<String>(json.encode(exercise['instructions'])),
.toString()
.trim()
.replaceAll(whitespaceRE, " "))),
Symbol('force'): Value<String>(exercise['force'] ?? "") Symbol('force'): Value<String>(exercise['force'] ?? "")
}; };

View File

@ -3,11 +3,11 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_sound/public/flutter_sound_player.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:sendtrain/database/database.dart'; import 'package:sendtrain/database/database.dart';
import 'package:sendtrain/models/action_model.dart'; import 'package:sendtrain/models/action_model.dart';
import 'package:vibration/vibration.dart';
class ActionTimer with ChangeNotifier { class ActionTimer with ChangeNotifier {
ActionModel? actionModel; ActionModel? actionModel;
@ -56,7 +56,6 @@ class ActionTimer with ChangeNotifier {
void setup(ActionModel actionModel, ItemScrollController scrollController, void setup(ActionModel actionModel, ItemScrollController scrollController,
[bool resetOnLoad = true]) async { [bool resetOnLoad = true]) async {
_scrollControllers.clear();
_scrollControllers.add(scrollController); _scrollControllers.add(scrollController);
if (resetOnLoad) { if (resetOnLoad) {
@ -86,7 +85,7 @@ class ActionTimer with ChangeNotifier {
Uint8List? countTone; Uint8List? countTone;
Uint8List? finishTone; Uint8List? finishTone;
await rootBundle await rootBundle
.load('assets/audio/count_tone.mp3') .load('assets/audio/count_tone.wav')
.then((data) => countTone = data.buffer.asUint8List()); .then((data) => countTone = data.buffer.asUint8List());
await rootBundle await rootBundle
.load('assets/audio/count_finish.mp3') .load('assets/audio/count_finish.mp3')
@ -103,25 +102,14 @@ class ActionTimer with ChangeNotifier {
_currentTime--; _currentTime--;
if (_currentTime <= 3 && _currentTime != 0) { if (_currentTime <= 3 && _currentTime != 0) {
await _mPlayer await _mPlayer.startPlayer(
.startPlayer(fromDataBuffer: countTone, codec: Codec.mp3) fromDataBuffer: countTone, codec: Codec.pcm16WAV);
.then((duration) async {
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 250);
}
});
} }
if (_currentTime == 0) { if (_currentTime == 0) {
// move to next action // move to next action
await _mPlayer await _mPlayer.startPlayer(
.startPlayer(fromDataBuffer: finishTone, codec: Codec.mp3) fromDataBuffer: finishTone, codec: Codec.mp3);
.then((duration) async {
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 250);
}
});
await setAction(state['currentAction'] + 1); await setAction(state['currentAction'] + 1);
} }

View File

@ -254,8 +254,8 @@ class _ActivityActionEditorState extends State<ActivityActionEditor> {
// create action // create action
await ActionsDao(db) await ActionsDao(db)
.createOrUpdate(ActionsCompanion( .createOrUpdate(ActionsCompanion(
title: Value('rep'), title: Value('title'),
description: Value('exercise action'), description: Value('description'),
totalSets: Value(int.parse( totalSets: Value(int.parse(
actionEditController['sets']! actionEditController['sets']!
.text)), .text)),

View File

@ -80,7 +80,7 @@ class _ActivityViewState extends State<ActivityView> {
distance: 70, distance: 70,
type: ExpandableFabType.up, type: ExpandableFabType.up,
overlayStyle: ExpandableFabOverlayStyle( overlayStyle: ExpandableFabOverlayStyle(
color: Colors.black.withValues(alpha: 0.5), color: Colors.black.withOpacity(0.5),
blur: 10, blur: 10,
), ),
onOpen: () { onOpen: () {

View File

@ -4,7 +4,7 @@ import 'package:sendtrain/providers/action_timer.dart';
Future showGenericDialog(dynamic object, BuildContext parentContext) { Future showGenericDialog(dynamic object, BuildContext parentContext) {
return showGeneralDialog( return showGeneralDialog(
barrierColor: Colors.black.withValues(alpha: 0.5), barrierColor: Colors.black.withOpacity(0.5),
transitionDuration: const Duration(milliseconds: 220), transitionDuration: const Duration(milliseconds: 220),
transitionBuilder: (BuildContext context, Animation<double> animation, transitionBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) { Animation<double> secondaryAnimation, Widget child) {

View File

@ -78,7 +78,7 @@ class _SessionViewState extends State<SessionView> {
distance: 70, distance: 70,
type: ExpandableFabType.up, type: ExpandableFabType.up,
overlayStyle: ExpandableFabOverlayStyle( overlayStyle: ExpandableFabOverlayStyle(
color: Colors.black.withValues(alpha: 0.5), color: Colors.black.withOpacity(0.5),
blur: 10, blur: 10,
), ),
children: [ children: [

View File

@ -53,7 +53,6 @@ dependencies:
dart_casing: ^3.0.1 dart_casing: ^3.0.1
collection: ^1.18.0 collection: ^1.18.0
flutter_sound: ^9.23.1 flutter_sound: ^9.23.1
vibration: ^3.1.2
flutter_launcher_name: flutter_launcher_name:
name: "SendTrain" name: "SendTrain"