edited tones, added vibrate #8
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 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,9 +72,12 @@ Future<void> seedDb(AppDatabase database) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Symbol, Value> payload = {
|
Map<Symbol, Value> payload = {
|
||||||
Symbol('title'): Value<String>(exercise['name']),
|
Symbol('title'): Value<String>(
|
||||||
Symbol('description'):
|
exercise['name'].toString().trim().replaceAll(whitespaceRE, " ")),
|
||||||
Value<String>(json.encode(exercise['instructions'])),
|
Symbol('description'): Value<String>(json.encode(exercise['instructions']
|
||||||
|
.toString()
|
||||||
|
.trim()
|
||||||
|
.replaceAll(whitespaceRE, " "))),
|
||||||
Symbol('force'): Value<String>(exercise['force'] ?? "")
|
Symbol('force'): Value<String>(exercise['force'] ?? "")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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,6 +56,7 @@ 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) {
|
||||||
@ -85,7 +86,7 @@ class ActionTimer with ChangeNotifier {
|
|||||||
Uint8List? countTone;
|
Uint8List? countTone;
|
||||||
Uint8List? finishTone;
|
Uint8List? finishTone;
|
||||||
await rootBundle
|
await rootBundle
|
||||||
.load('assets/audio/count_tone.wav')
|
.load('assets/audio/count_tone.mp3')
|
||||||
.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')
|
||||||
@ -102,14 +103,25 @@ class ActionTimer with ChangeNotifier {
|
|||||||
_currentTime--;
|
_currentTime--;
|
||||||
|
|
||||||
if (_currentTime <= 3 && _currentTime != 0) {
|
if (_currentTime <= 3 && _currentTime != 0) {
|
||||||
await _mPlayer.startPlayer(
|
await _mPlayer
|
||||||
fromDataBuffer: countTone, codec: Codec.pcm16WAV);
|
.startPlayer(fromDataBuffer: countTone, codec: Codec.mp3)
|
||||||
|
.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.startPlayer(
|
await _mPlayer
|
||||||
fromDataBuffer: finishTone, codec: Codec.mp3);
|
.startPlayer(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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('title'),
|
title: Value('rep'),
|
||||||
description: Value('description'),
|
description: Value('exercise action'),
|
||||||
totalSets: Value(int.parse(
|
totalSets: Value(int.parse(
|
||||||
actionEditController['sets']!
|
actionEditController['sets']!
|
||||||
.text)),
|
.text)),
|
||||||
|
@ -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.withOpacity(0.5),
|
color: Colors.black.withValues(alpha: 0.5),
|
||||||
blur: 10,
|
blur: 10,
|
||||||
),
|
),
|
||||||
onOpen: () {
|
onOpen: () {
|
||||||
|
@ -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.withOpacity(0.5),
|
barrierColor: Colors.black.withValues(alpha: 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) {
|
||||||
|
@ -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.withOpacity(0.5),
|
color: Colors.black.withValues(alpha: 0.5),
|
||||||
blur: 10,
|
blur: 10,
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
|
@ -53,6 +53,7 @@ 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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user