diff --git a/.gitignore b/.gitignore index 065dc2c..84fa0f7 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ migrate_working_dir/ .pub/ /build/ pubspec.lock +devtools_options.yaml # Symbolication related app.*.symbols diff --git a/lib/classes/activity_action.dart b/lib/classes/activity_action.dart index 79caba1..6fd7a5a 100644 --- a/lib/classes/activity_action.dart +++ b/lib/classes/activity_action.dart @@ -18,12 +18,14 @@ class ActivityAction { List>> items() { List>> sets = []; Reps reps = activityActionSet.reps; + int totalActions = 1; for (int i = 0; i < activityActionSet.total; i++) { List> actions = []; int? weight = _setWeight(i); actions.add({ + 'actionID': totalActions++, 'name': title, 'type': reps.type, 'amount': reps.amounts[i], @@ -33,6 +35,7 @@ class ActivityAction { if (activityActionSet.type == 'alternating') { if (reps.rest != null) { actions.add({ + 'actionID': totalActions++, 'name': 'Rest', 'type': 'seconds', 'amount': reps.amounts[i], @@ -40,6 +43,7 @@ class ActivityAction { } actions.add({ + 'actionID': totalActions++, 'name': title, 'type': reps.type, 'amount': reps.amounts[i], @@ -48,6 +52,7 @@ class ActivityAction { } actions.add({ + 'actionID': totalActions++, 'name': 'Rest', 'type': 'seconds', 'amount': activityActionSet.rest ~/ 1000, diff --git a/lib/models/activity_timer_model.dart b/lib/models/activity_timer_model.dart index e2a8753..e4e3cb0 100644 --- a/lib/models/activity_timer_model.dart +++ b/lib/models/activity_timer_model.dart @@ -1,35 +1,36 @@ import 'dart:async'; -import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:sendtrain/models/activity_model.dart'; class ActivityTimerModel with ChangeNotifier { - int _actionCount = 0; + int _actionCounter = 0; ActivityModel? _activity; - List _actions = []; + List _sets = []; int _currentActionNum = 0; int _currentSetNum = 0; Timer? _periodicTimer; - int get actionCount => _actionCount; + int get actionCount => _actionCounter; int get currentActionNum => _currentActionNum; + dynamic get currentAction => currentSet[_currentActionNum]; int get currentSetNum => _currentSetNum; + dynamic get currentSet => _sets[_currentSetNum]; ActivityModel? get activity => _activity; - List get actions => _actions; + List get sets => _sets; Timer? get periodicTimer => _periodicTimer; - String get currentActionType => _actions[_currentSetNum][_currentActionNum]['type']; + bool get isActive => _isActive(); void get pause => _periodicTimer!.cancel(); void setup(ActivityModel activity) { _activity = activity; - _actions = activity.actions[0].items(); + _sets = activity.actions[0].items(); _currentActionNum = 0; _currentSetNum = 0; setActionCount(); } - bool isActive() { + bool _isActive() { return (_periodicTimer != null && _periodicTimer!.isActive) ? true : false; } @@ -43,20 +44,30 @@ class ActivityTimerModel with ChangeNotifier { int totalActions() { int count = 0; - for(int i = 0; i < _actions.length; i++) { - count = count + _actions[i].length as int; + for(int i = 0; i < _sets.length; i++) { + count = count + _sets[i].length as int; } return count; } void setActionCount() { - _actionCount = _actions[_currentSetNum][_currentActionNum]['amount']; + _actionCounter = _sets[_currentSetNum][_currentActionNum]['amount']; } void start() { _periodicTimer = Timer.periodic(const Duration(seconds: 1), (Timer timer) { - _actionCount--; + switch(currentAction['type']) { + case 'repititions': + break; + case 'seconds': + if (_actionCounter > 0) { + _actionCounter--; + } else { + nextAction(_currentActionNum + 1); + } + } + notifyListeners(); }); } @@ -67,17 +78,25 @@ class ActivityTimerModel with ChangeNotifier { notifyListeners(); } + void nextAction(int nextActionID) { + + } + + (int, int) _findAction(int actionID) { + return (1, 2); + } + // void nextAction(String type) { // setAction(_currentActionNum + 1, _getSet(), type); // } - // int _actionCount = 0; + // int _actionCounter = 0; // int _currentAction = 0; // ActivityModel? _activity; // Timer? _periodicTimer; // List _actionMap = []; - // int get actionCount => _actionCount; + // int get actionCount => _actionCounter; // int get currentAction => _currentAction; // ActivityModel? get activity => _activity; // Timer? get periodicTimer => _periodicTimer; @@ -123,9 +142,9 @@ class ActivityTimerModel with ChangeNotifier { // void getValue() { // if (_actionMap[_currentAction] == "Rest") { - // _actionCount = _activity!.actions[0].activityActionSet.rest ~/ 1000; + // _actionCounter = _activity!.actions[0].activityActionSet.rest ~/ 1000; // } else { - // _actionCount = _activity!.actions[0].activityActionSet.reps.amounts[0]; + // _actionCounter = _activity!.actions[0].activityActionSet.reps.amounts[0]; // } // } @@ -159,10 +178,10 @@ class ActivityTimerModel with ChangeNotifier { // _periodicTimer?.cancel(); // _periodicTimer = // Timer.periodic(const Duration(seconds: 1), (Timer timer) { - // if (_actionCount <= 0) { + // if (_actionCounter <= 0) { // nextAction('automatic'); // } else if (actionState() != 'Repititions') { - // _actionCount--; + // _actionCounter--; // } // notifyListeners(); // }); diff --git a/lib/widgets/activities_header.dart b/lib/widgets/activities_header.dart index 4411663..a5be690 100644 --- a/lib/widgets/activities_header.dart +++ b/lib/widgets/activities_header.dart @@ -5,10 +5,10 @@ class ActivitiesHeader extends StatefulWidget { const ActivitiesHeader({super.key}); @override - _ActivitiesHeaderState createState() => _ActivitiesHeaderState(); + State createState() => ActivitiesHeaderState(); } -class _ActivitiesHeaderState extends State { +class ActivitiesHeaderState extends State { @override void initState() { super.initState(); diff --git a/lib/widgets/activity_action_view.dart b/lib/widgets/activity_action_view.dart index 0174283..794b81a 100644 --- a/lib/widgets/activity_action_view.dart +++ b/lib/widgets/activity_action_view.dart @@ -1,15 +1,11 @@ -import 'dart:async'; -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:sendtrain/classes/activity_action.dart'; import 'package:sendtrain/models/activity_timer_model.dart'; -import 'package:sendtrain/widgets/action_card.dart'; class ActivityActionView extends StatefulWidget { - ActivityActionView({super.key, required this.action}); - ActivityAction action; + const ActivityActionView({super.key, required this.action}); + final ActivityAction action; @override State createState() => ActivityActionViewState(); @@ -18,7 +14,6 @@ class ActivityActionView extends StatefulWidget { class ActivityActionViewState extends State { @override Widget build(BuildContext context) { - int actionCount = 0; ActivityTimerModel atm = Provider.of(context, listen: true); List>> sets = atm.activity!.actions[0].items(); @@ -28,11 +23,6 @@ class ActivityActionViewState extends State { padding: const EdgeInsets.fromLTRB(10, 0, 10, 20), itemCount: widget.action.activityActionSet.total, itemBuilder: (BuildContext context, int setNum) { - String title = widget.action.title; - Set actionSet = widget.action.activityActionSet; - Reps setReps = actionSet.reps; - int setRest = actionSet.rest ~/ 1000; - int currentAction = 0; List content = []; List> set = sets[setNum]; @@ -48,13 +38,13 @@ class ActivityActionViewState extends State { }, child: Row(children: [ Ink( - // width: 90, + width: 70, padding: const EdgeInsets.all(15), color: atm.isCurrentItem(setNum, actionNum) ? Theme.of(context).colorScheme.primaryContainer : Theme.of(context).colorScheme.onPrimary, child: - Text(textAlign: TextAlign.right, 'Set ${setNum + 1} ')), + Text(textAlign: TextAlign.center, 'Set ${setNum + 1} ')), Expanded( child: Ink( padding: const EdgeInsets.all(15), @@ -67,122 +57,6 @@ class ActivityActionViewState extends State { ]))); } - // actionCount = actionCount + 2; - // content.addAll([ - // GestureDetector( - // onTap: () { - // setState(() { - // atm.setAction(currentAction, 'manual'); - // }); - // }, - // child: Row(children: [ - // Consumer(builder: (context, atm, child) { - // return Ink( - // width: 90, - // padding: const EdgeInsets.all(15), - // color: currentAction == atm.currentAction - // ? Theme.of(context).colorScheme.primaryContainer - // : Theme.of(context).colorScheme.onPrimary, - // child: Text(textAlign: TextAlign.right,'Set ${index + 1} ')); - // }), - // Expanded( - // child: Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction == atm.currentAction - // ? Theme.of(context).colorScheme.surfaceBright - // : Theme.of(context).colorScheme.surfaceContainerLow, - // child: Text( - // textAlign: TextAlign.center, - // '$title: ${setReps.amounts[index]} ${atm.setType}'))) - // ])), - // GestureDetector( - // onTap: () { - // setState(() { - // atm.setAction(currentAction + 1, 'manual'); - // }); - // }, - // child: Row(children: [ - // Consumer(builder: (context, atm, child) { - // return Ink( - // width: 90, - // padding: const EdgeInsets.all(15), - // color: currentAction + 1 == atm.currentAction - // ? Theme.of(context).colorScheme.primaryContainer - // : Theme.of(context).colorScheme.onPrimary, - // child: Text(textAlign: TextAlign.right,'Rest ${index + 1}')); - // }), - // Expanded( - // child: Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction + 1 == atm.currentAction - // ? Theme.of(context).colorScheme.surfaceBright - // : Theme.of(context).colorScheme.surfaceContainerLow, - // child: Text( - // textAlign: TextAlign.center, - // 'Rest: $setRest seconds'))) - // ])), - // ]); - - // if (actionSet.type == 'alternating') { - // actionCount = actionCount + 2; - // content.addAll([ - // GestureDetector( - // onTap: () { - // setState(() { - // atm.setAction(currentAction + 2, 'manual'); - // }); - // }, - // child: Row(children: [ - // Consumer(builder: (context, atm, child) { - // return Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction + 2 == atm.currentAction - // ? Theme.of(context).colorScheme.onPrimary - // : Theme.of(context).colorScheme.primaryContainer, - // child: Text('Set: ${index + 1} ')); - // }), - // Expanded( - // child: Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction + 2 == atm.currentAction - // ? Theme.of(context).colorScheme.onSecondary - // : Theme.of(context) - // .colorScheme - // .surfaceContainerLow, - // child: Text( - // textAlign: TextAlign.center, - // '$title: ${setReps.amounts[index]} ${atm.setType}'))) - // ])), - // GestureDetector( - // onTap: () { - // setState(() { - // atm.setAction(currentAction + 3, 'manual'); - // }); - // }, - // child: Row(children: [ - // Consumer(builder: (context, atm, child) { - // return Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction + 3 == atm.currentAction - // ? Theme.of(context).colorScheme.onPrimary - // : Theme.of(context).colorScheme.primaryContainer, - // child: Text('Set: ${index + 1} ')); - // }), - // Expanded( - // child: Ink( - // padding: const EdgeInsets.all(15), - // color: currentAction + 3 == atm.currentAction - // ? Theme.of(context).colorScheme.onSecondary - // : Theme.of(context) - // .colorScheme - // .surfaceContainerLow, - // child: Text( - // textAlign: TextAlign.center, - // 'Rest: $setRest seconds'))) - // ])), - // ]); - // } - if (setNum == 0) { return Card( shape: const RoundedRectangleBorder( diff --git a/lib/widgets/activity_card.dart b/lib/widgets/activity_card.dart index 91c8e74..52783fc 100644 --- a/lib/widgets/activity_card.dart +++ b/lib/widgets/activity_card.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:sendtrain/classes/media.dart'; import 'package:sendtrain/models/activity_model.dart'; import 'package:sendtrain/widgets/activity_view.dart'; -import 'package:sendtrain/widgets/media_card.dart'; class ActivityCard extends StatelessWidget { const ActivityCard({super.key, required this.activity}); diff --git a/lib/widgets/activity_view.dart b/lib/widgets/activity_view.dart index 0e048c7..2ed711c 100644 --- a/lib/widgets/activity_view.dart +++ b/lib/widgets/activity_view.dart @@ -8,8 +8,8 @@ import 'package:sendtrain/widgets/activity_action_view.dart'; import 'package:sendtrain/widgets/media_card.dart'; class ActivityView extends StatefulWidget { - ActivityView({super.key, required this.activity}); - ActivityModel activity; + const ActivityView({super.key, required this.activity}); + final ActivityModel activity; @override State createState() => _ActivityViewState(); @@ -56,44 +56,62 @@ class _ActivityViewState extends State { Padding( padding: const EdgeInsets.only(left: 10, right: 10), child: Card( + clipBehavior: Clip.antiAlias, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)), ), color: Theme.of(context).colorScheme.onPrimary, - child: Row(children: [ + child: Padding( + padding: const EdgeInsets.only(left: 0, right: 0), + child: Row(children: [ // LinearProgressIndicator( // value: 0.5, // minHeight: 100, // color: Theme.of(context).colorScheme.error, // semanticsLabel: 'Linear progress indicator', // ), - Expanded( - flex: 1, - child: Flex(direction: Axis.horizontal, children: [ - Consumer(builder: (context, atm, child) { + // Expanded( + // flex: 1, + // child: Flex(direction: Axis.horizontal, children: [ + // Consumer(builder: (context, atm, child) { + // return IconButton( + // iconSize: 30, + // icon: atm.isActive() + // ? const Icon(Icons.pause_rounded) + // : const Icon(Icons.play_arrow_rounded), + // onPressed: () => + // {atm.isActive() ? atm.pause : atm.start()}); + // }), + // // IconButton( + // // // iconSize: 36, + // // icon: const Icon(Icons.skip_next_rounded), + // // onPressed: () { + // // atm.nextAction('manual'); + // // }) + // ])), + Ink( + width: 70, + color: Theme.of(context).colorScheme.primaryContainer, + child: Consumer( + builder: (context, atm, child) { return IconButton( - // iconSize: 30, - icon: atm.isActive() - ? const Icon(Icons.pause_rounded) - : const Icon(Icons.play_arrow_rounded), - onPressed: () => - {atm.isActive() ? atm.pause : atm.start()}); - }), - // IconButton( - // // iconSize: 36, - // icon: const Icon(Icons.skip_next_rounded), - // onPressed: () { - // atm.nextAction('manual'); - // }) - ])), + alignment: AlignmentDirectional.center, + iconSize: 30, + icon: atm.isActive + ? const Icon(Icons.pause_rounded) + : const Icon(Icons.play_arrow_rounded), + onPressed: () => + {atm.isActive ? atm.pause : atm.start()}); + }, + )), Expanded( - flex: 1, + flex: 2, child: Consumer( builder: (context, atm, child) { return Text( style: const TextStyle(fontSize: 20), - textAlign: TextAlign.center, - '${atm.actionCount} ${atm.currentActionType}'); + textAlign: TextAlign.right, + '${atm.actionCount} ${atm.currentAction['type']}'); }, )), Expanded( @@ -103,12 +121,12 @@ class _ActivityViewState extends State { child: Consumer( builder: (context, atm, child) { return Text( - style: const TextStyle(fontSize: 20), + style: const TextStyle(fontSize: 15), textAlign: TextAlign.right, - '${atm.currentActionNum + 1} / ${atm.totalActions()}'); + '${atm.currentAction['actionID']} | ${atm.totalActions()}'); // 'Set: ${atm.currentSet + 1}/${atm.totalSets}\nRep: ${atm.currentRep + 1}/${atm.totalReps}'); }))), - ]))), + ])))), ActivityActionView(action: activity.actions[0]), // Container( // height: MediaQuery.sizeOf(context).height * .07, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..738fc0a 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import flutter_inappwebview_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) } diff --git a/pubspec.yaml b/pubspec.yaml index 5e5f2bf..fe7c8e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 0.2.1 environment: - sdk: '>=2.19.2 <3.0.0' + sdk: '>=3.0.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -36,8 +36,8 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 scaler: ^1.1.2+1 - intl: ^0.18.0 - youtube_player_flutter: ^8.1.2 + intl: ^0.20.1 + youtube_player_flutter: ^9.1.1 json_annotation: ^4.9.0 provider: ^6.1.2 @@ -53,7 +53,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^5.0.0 build_runner: ^2.4.13 json_serializable: ^6.9.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..3b4ee90 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..61c79a2 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + flutter_inappwebview_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST