Compare commits

...

3 Commits

Author SHA1 Message Date
bdc4fee8c2 Merge pull request 'edited tones, added vibrate' (#8) from action-things into main
Reviewed-on: #8
2025-02-11 08:41:00 -08:00
8dcffcca11 Merge branch 'main' into action-things 2025-02-11 08:40:40 -08:00
Joshua Burman
9f5fb0d1ad edited tones, added vibrate 2025-02-11 10:32:40 -05:00
10 changed files with 31 additions and 15 deletions

Binary file not shown.

BIN
assets/audio/count_tone.mp3 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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'] ?? "")
};

View File

@ -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);
}

View File

@ -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)),

View File

@ -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: () {

View File

@ -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) {

View File

@ -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: [

View File

@ -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"