Compare commits
No commits in common. "398336640879a77a77a355290dbf4099c7cc197e" and "a3d7e651f4450d811af00e49aa8a9fc60b6078c4" have entirely different histories.
3983366408
...
a3d7e651f4
|
@ -78,8 +78,7 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
Widget build(BuildContext context) {
|
||||
List<Widget> actions = [];
|
||||
if (widget.plan.id.present)
|
||||
actions.add(
|
||||
IconButton(
|
||||
actions.add(IconButton(
|
||||
onPressed: () async {
|
||||
bool? confirm = await _showConfirmationDialog(context);
|
||||
if (!confirm!) return;
|
||||
|
@ -87,9 +86,7 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
if (!mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
);
|
||||
icon: const Icon(Icons.delete),),);
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
|
@ -107,28 +104,15 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
for (int i = 0; i < daySelections!.length; i++) {
|
||||
if (daySelections![i]) days.add(weekdayNames[i]);
|
||||
}
|
||||
if (days.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Select days first')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final exercises = [];
|
||||
for (int i = 0; i < exerciseSelections!.length; i++) {
|
||||
if (exerciseSelections![i]) exercises.add(names[i]);
|
||||
}
|
||||
if (exercises.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Select exercises first')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var newPlan = widget.plan.copyWith(
|
||||
days: Value(days.join(',')),
|
||||
exercises: Value(exercises.join(',')),
|
||||
);
|
||||
exercises: Value(exercises.join(',')),);
|
||||
|
||||
if (widget.plan.id.present)
|
||||
await db.update(db.plans).replace(newPlan);
|
||||
|
@ -142,8 +126,7 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
},
|
||||
child: const Icon(Icons.check),
|
||||
),
|
||||
),
|
||||
);
|
||||
),);
|
||||
}
|
||||
|
||||
List<Widget> get getChildren {
|
||||
|
@ -185,8 +168,7 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
Expanded(
|
||||
child: ListView(
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
),),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' as material;
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -25,27 +23,6 @@ class _StartPlanState extends State<StartPlan> {
|
|||
final repsNode = FocusNode();
|
||||
final weightController = TextEditingController();
|
||||
final weightNode = FocusNode();
|
||||
int current = 0;
|
||||
int minutes = 3;
|
||||
int seconds = 30;
|
||||
Timer? timer;
|
||||
|
||||
void startTimer() {
|
||||
setState(() {
|
||||
current = minutes * 60 * 1000 + seconds * 1000;
|
||||
});
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
print("StartPlan: current=$current");
|
||||
if (current == 0)
|
||||
setState(() {
|
||||
timer.cancel();
|
||||
});
|
||||
else
|
||||
setState(() {
|
||||
current -= 1000;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getTotals() async {
|
||||
final query = await (db.selectOnly(db.gymSets)
|
||||
|
@ -102,16 +79,12 @@ class _StartPlanState extends State<StartPlan> {
|
|||
..limit(1))
|
||||
.get();
|
||||
final firstSet = sets.first;
|
||||
setState(() {
|
||||
repsController.text = firstSet.reps.toString();
|
||||
repsController.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: firstSet.reps.toString().length,
|
||||
);
|
||||
weightController.text = firstSet.weight.toString();
|
||||
minutes = firstSet.minutes;
|
||||
seconds = firstSet.seconds;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -119,15 +92,16 @@ class _StartPlanState extends State<StartPlan> {
|
|||
super.initState();
|
||||
exercises = widget.plan.exercises.value.split(',');
|
||||
repsNode.requestFocus();
|
||||
|
||||
getCounts();
|
||||
getTotals();
|
||||
|
||||
focus(selectedExercise);
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -193,9 +167,6 @@ class _StartPlanState extends State<StartPlan> {
|
|||
);
|
||||
},
|
||||
),
|
||||
LinearProgressIndicator(
|
||||
value: current / (minutes * 60 * 1000 + seconds * 1000),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -209,9 +180,7 @@ class _StartPlanState extends State<StartPlan> {
|
|||
);
|
||||
await db.into(db.gymSets).insert(gymSet);
|
||||
const platform = MethodChannel('com.massive/android');
|
||||
platform
|
||||
.invokeMethod('timer', [minutes * 60 * 1000 + seconds * 1000]);
|
||||
startTimer();
|
||||
platform.invokeMethod('timer', [180000]);
|
||||
await getCounts();
|
||||
},
|
||||
child: const Icon(Icons.check),
|
||||
|
|
Loading…
Reference in New Issue
Block a user