upgraded dart and packages, analyze fixes, action type timer management

This commit is contained in:
Joshua Burman 2024-12-07 13:13:45 -05:00
parent 19f835d8f2
commit f781001d3b
11 changed files with 104 additions and 182 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@ migrate_working_dir/
.pub/
/build/
pubspec.lock
devtools_options.yaml
# Symbolication related
app.*.symbols

View File

@ -18,12 +18,14 @@ class ActivityAction {
List<List<Map<String, dynamic>>> items() {
List<List<Map<String, dynamic>>> sets = [];
Reps reps = activityActionSet.reps;
int totalActions = 1;
for (int i = 0; i < activityActionSet.total; i++) {
List<Map<String, dynamic>> 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,

View File

@ -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<String> _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();
// });

View File

@ -5,10 +5,10 @@ class ActivitiesHeader extends StatefulWidget {
const ActivitiesHeader({super.key});
@override
_ActivitiesHeaderState createState() => _ActivitiesHeaderState();
State<ActivitiesHeader> createState() => ActivitiesHeaderState();
}
class _ActivitiesHeaderState extends State<ActivitiesHeader> {
class ActivitiesHeaderState extends State<ActivitiesHeader> {
@override
void initState() {
super.initState();

View File

@ -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<ActivityActionView> createState() => ActivityActionViewState();
@ -18,7 +14,6 @@ class ActivityActionView extends StatefulWidget {
class ActivityActionViewState extends State<ActivityActionView> {
@override
Widget build(BuildContext context) {
int actionCount = 0;
ActivityTimerModel atm =
Provider.of<ActivityTimerModel>(context, listen: true);
List<List<Map<String, dynamic>>> sets = atm.activity!.actions[0].items();
@ -28,11 +23,6 @@ class ActivityActionViewState extends State<ActivityActionView> {
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<GestureDetector> content = [];
List<Map<String, dynamic>> set = sets[setNum];
@ -48,13 +38,13 @@ class ActivityActionViewState extends State<ActivityActionView> {
},
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<ActivityActionView> {
])));
}
// actionCount = actionCount + 2;
// content.addAll([
// GestureDetector(
// onTap: () {
// setState(() {
// atm.setAction(currentAction, 'manual');
// });
// },
// child: Row(children: [
// Consumer<ActivityTimerModel>(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<ActivityTimerModel>(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<ActivityTimerModel>(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<ActivityTimerModel>(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(

View File

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

View File

@ -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<ActivityView> createState() => _ActivityViewState();
@ -56,44 +56,62 @@ class _ActivityViewState extends State<ActivityView> {
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<ActivityTimerModel>(builder: (context, atm, child) {
// Expanded(
// flex: 1,
// child: Flex(direction: Axis.horizontal, children: [
// Consumer<ActivityTimerModel>(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<ActivityTimerModel>(
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<ActivityTimerModel>(
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<ActivityView> {
child: Consumer<ActivityTimerModel>(
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,

View File

@ -5,6 +5,8 @@
import FlutterMacOS
import Foundation
import flutter_inappwebview_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
}

View File

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

View File

@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_inappwebview_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST