Compare commits
7 Commits
b6a73c398e
...
9aed2b3ac1
Author | SHA1 | Date | |
---|---|---|---|
9aed2b3ac1 | |||
6908623ba2 | |||
a9486727b2 | |||
e4ba71ad4b | |||
202ec599d6 | |||
fbffc0cf4a | |||
19f9dd9b3b |
|
@ -4,3 +4,4 @@ linter:
|
|||
rules:
|
||||
curly_braces_in_flow_control_structures: false
|
||||
avoid_print: false
|
||||
require_trailing_commas: true
|
||||
|
|
|
@ -22,7 +22,7 @@ class DeleteAllSets extends StatelessWidget {
|
|||
return AlertDialog(
|
||||
title: const Text("Delete all sets"),
|
||||
content: const Text(
|
||||
"This will irreversibly destroy all your gym set data. Are you sure?"),
|
||||
"This will irreversibly destroy all your gym set data. Are you sure?",),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: const Text('Cancel'),
|
||||
|
@ -36,14 +36,14 @@ class DeleteAllSets extends StatelessWidget {
|
|||
await db.gymSets.delete().go();
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Deleted all sets')));
|
||||
const SnackBar(content: Text('Deleted all sets')),);
|
||||
final navigator = Navigator.of(context);
|
||||
navigator.pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
},);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -46,7 +46,7 @@ class _DynamicColorSchemeState extends State<DynamicColorScheme> {
|
|||
context,
|
||||
colorScheme.copyWith(
|
||||
primary: color,
|
||||
));
|
||||
),);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ class EditPlanPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _EditPlanPageState extends State<EditPlanPage> {
|
||||
late PlansCompanion plan;
|
||||
List<String?> names = [];
|
||||
List<bool>? daySelections;
|
||||
List<bool>? exerciseSelections;
|
||||
|
@ -41,8 +40,6 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
names.map((name) => exercises.contains(name)).toList();
|
||||
});
|
||||
});
|
||||
|
||||
plan = widget.plan;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -89,7 +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(
|
||||
|
@ -113,20 +110,23 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
if (exerciseSelections![i]) exercises.add(names[i]);
|
||||
}
|
||||
|
||||
final newPlan = plan.copyWith(
|
||||
var newPlan = widget.plan.copyWith(
|
||||
days: Value(days.join(',')),
|
||||
exercises: Value(exercises.join(',')));
|
||||
exercises: Value(exercises.join(',')),);
|
||||
|
||||
if (plan.id.present)
|
||||
if (widget.plan.id.present)
|
||||
await db.update(db.plans).replace(newPlan);
|
||||
else
|
||||
await db.into(db.plans).insert(newPlan);
|
||||
else {
|
||||
final id = await db.into(db.plans).insert(newPlan);
|
||||
newPlan = newPlan.copyWith(id: Value(id));
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Icon(Icons.check),
|
||||
),
|
||||
));
|
||||
),);
|
||||
}
|
||||
|
||||
List<Widget> get getChildren {
|
||||
|
@ -168,7 +168,7 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
Expanded(
|
||||
child: ListView(
|
||||
children: children,
|
||||
))
|
||||
),),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
if (gymSet.id.present) {
|
||||
repsNode.requestFocus();
|
||||
_repsController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _repsController.text.length);
|
||||
baseOffset: 0, extentOffset: _repsController.text.length,);
|
||||
} else
|
||||
nameNode.requestFocus();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
if (!mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.delete)));
|
||||
icon: const Icon(Icons.delete),),);
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
|
@ -72,7 +72,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
decoration: const InputDecoration(labelText: 'Name'),
|
||||
onTap: () {
|
||||
_nameController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _nameController.text.length);
|
||||
baseOffset: 0, extentOffset: _nameController.text.length,);
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
|
@ -85,7 +85,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
focusNode: repsNode,
|
||||
onTap: () {
|
||||
_repsController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _repsController.text.length);
|
||||
baseOffset: 0, extentOffset: _repsController.text.length,);
|
||||
},
|
||||
decoration: const InputDecoration(labelText: 'Reps'),
|
||||
keyboardType: TextInputType.number,
|
||||
|
@ -102,12 +102,12 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
keyboardType: TextInputType.number,
|
||||
onTap: () {
|
||||
_weightController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _weightController.text.length);
|
||||
baseOffset: 0, extentOffset: _weightController.text.length,);
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
gymSet = gymSet.copyWith(
|
||||
weight: Value(double.tryParse(value) ?? 0));
|
||||
weight: Value(double.tryParse(value) ?? 0),);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
@ -118,7 +118,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
onPressed: () async {
|
||||
if (_nameController.text.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Please enter a name')));
|
||||
const SnackBar(content: Text('Please enter a name')),);
|
||||
nameNode.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
else {
|
||||
await Permission.notification.request();
|
||||
final newSet = gymSet.copyWith(
|
||||
created: Value(DateTime.now().toIso8601String()));
|
||||
created: Value(DateTime.now().toIso8601String()),);
|
||||
await db.into(db.gymSets).insert(newSet);
|
||||
const platform = MethodChannel('com.massive/android');
|
||||
platform.invokeMethod('timer', [3000]);
|
||||
|
@ -137,6 +137,6 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
|||
},
|
||||
child: const Icon(Icons.check),
|
||||
),
|
||||
));
|
||||
),);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,6 @@ class _HomePage extends State<HomePage> {
|
|||
],
|
||||
),
|
||||
body: getBody(),
|
||||
));
|
||||
),);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:fmassive/constants.dart';
|
||||
import 'package:fmassive/database.dart';
|
||||
import 'package:fmassive/edit_plan.dart';
|
||||
import 'package:fmassive/main.dart';
|
||||
import 'package:fmassive/start_plan.dart';
|
||||
import 'package:moor_flutter/moor_flutter.dart';
|
||||
import 'package:fmassive/plan_tile.dart';
|
||||
|
||||
class PlanList extends StatelessWidget {
|
||||
const PlanList({
|
||||
|
@ -21,51 +18,7 @@ class PlanList extends StatelessWidget {
|
|||
return ListView.builder(
|
||||
itemCount: plans.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
title: Text(plans[index].days.replaceAll(',', ', '),
|
||||
style: TextStyle(
|
||||
fontWeight: plans[index].days.contains(weekday)
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
decoration: plans[index].days.contains(weekday)
|
||||
? TextDecoration.underline
|
||||
: null)),
|
||||
subtitle: Text(plans[index].exercises),
|
||||
onLongPress: () => showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Delete set'),
|
||||
content: Text(
|
||||
'Are you sure you want to delete ${plans[index].days}?'),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
final navigator = Navigator.of(context);
|
||||
await db.plans.deleteOne(plans[index]);
|
||||
navigator.pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
onTap: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
StartPlan(plan: plans[index].toCompanion(false)),
|
||||
),
|
||||
);
|
||||
});
|
||||
return PlanTile(plan: plans[index], weekday: weekday);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
68
lib/plan_tile.dart
Normal file
68
lib/plan_tile.dart
Normal file
|
@ -0,0 +1,68 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:fmassive/database.dart';
|
||||
import 'package:fmassive/edit_plan.dart';
|
||||
import 'package:fmassive/main.dart';
|
||||
import 'package:fmassive/start_plan.dart';
|
||||
import 'package:moor_flutter/moor_flutter.dart';
|
||||
|
||||
class PlanTile extends StatelessWidget {
|
||||
PlanTile({
|
||||
super.key,
|
||||
required this.plan,
|
||||
required this.weekday,
|
||||
});
|
||||
|
||||
final Plan plan;
|
||||
final String weekday;
|
||||
final tapPosition = GlobalKey();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MenuAnchor(
|
||||
menuChildren: [
|
||||
MenuItemButton(
|
||||
child: const Text("Edit"),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
EditPlanPage(plan: plan.toCompanion(false)),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await db.plans.deleteOne(plan);
|
||||
},
|
||||
child: const Text("Delete"),
|
||||
),
|
||||
],
|
||||
builder: (context, controller, child) {
|
||||
return ListTile(
|
||||
title: Text(
|
||||
plan.days.replaceAll(',', ', '),
|
||||
style: TextStyle(
|
||||
fontWeight: plan.days.contains(weekday) ? FontWeight.bold : null,
|
||||
decoration:
|
||||
plan.days.contains(weekday) ? TextDecoration.underline : null,
|
||||
),
|
||||
),
|
||||
subtitle: Text(plan.exercises),
|
||||
onLongPress: () {
|
||||
controller.open();
|
||||
},
|
||||
onTap: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StartPlan(plan: plan.toCompanion(false)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -73,14 +73,13 @@ class _PlansPageState extends State<_PlansPage> {
|
|||
child: Text(
|
||||
'Error: ${snapshot.error}',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
)),
|
||||
),),
|
||||
);
|
||||
|
||||
if (plans == null)
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
if (plans == null) return Container();
|
||||
|
||||
return PlanList(plans: plans);
|
||||
}),
|
||||
},),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
await Navigator.push(
|
||||
|
@ -88,10 +87,10 @@ class _PlansPageState extends State<_PlansPage> {
|
|||
MaterialPageRoute(
|
||||
builder: (context) => const EditPlanPage(
|
||||
plan: PlansCompanion(
|
||||
days: Value(''), exercises: Value(''))),
|
||||
days: Value(''), exercises: Value(''),),),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.add)));
|
||||
child: const Icon(Icons.add),),);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,10 +69,6 @@ class _SetList extends State<SetList> {
|
|||
pagingController: pagingController,
|
||||
gymSet: gymSet,
|
||||
),
|
||||
firstPageProgressIndicatorBuilder: (_) =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
newPageProgressIndicatorBuilder: (_) =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
|
|
|
@ -21,7 +21,7 @@ class SetTile extends StatelessWidget {
|
|||
return ListTile(
|
||||
title: Text(gymSet.name),
|
||||
subtitle: Text(DateFormat("yyyy-MM-dd HH:mm")
|
||||
.format(DateTime.parse(gymSet.created))),
|
||||
.format(DateTime.parse(gymSet.created)),),
|
||||
trailing: Text("${gymSet.reps} x ${gymSet.weight}kg"),
|
||||
onTap: () async {
|
||||
await Navigator.push(
|
||||
|
@ -40,7 +40,7 @@ class SetTile extends StatelessWidget {
|
|||
return AlertDialog(
|
||||
title: const Text('Delete set'),
|
||||
content: Text(
|
||||
'Are you sure you want to delete ${gymSet.name} ${gymSet.reps}x${gymSet.weight}${gymSet.unit}?'),
|
||||
'Are you sure you want to delete ${gymSet.name} ${gymSet.reps}x${gymSet.weight}${gymSet.unit}?',),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: const Text('Cancel'),
|
||||
|
|
|
@ -53,8 +53,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
final settings = snapshot.data;
|
||||
print('build: $settings');
|
||||
|
||||
if (settings == null)
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
if (settings == null) return Container();
|
||||
|
||||
final filteredItems = [
|
||||
{'title': 'Alarm', 'value': settings.alarm},
|
||||
|
@ -69,7 +68,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
]
|
||||
.where((item) => (item['title'] as String)
|
||||
.toLowerCase()
|
||||
.contains(widget.search.toLowerCase()))
|
||||
.contains(widget.search.toLowerCase()),)
|
||||
.toList();
|
||||
|
||||
return material.Column(
|
||||
|
@ -90,7 +89,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
onPressed: () async {
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['csv']);
|
||||
allowedExtensions: ['csv'],);
|
||||
if (result == null) return;
|
||||
|
||||
final file = File(result.files.single.path!);
|
||||
|
@ -113,14 +112,14 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
minutes: Value(int.tryParse(row[9]) ?? 0),
|
||||
seconds: Value(int.tryParse(row[10]) ?? 0),
|
||||
steps: Value(row[11]),
|
||||
));
|
||||
),);
|
||||
await db.batch(
|
||||
(batch) => batch.insertAll(db.gymSets, gymSets));
|
||||
(batch) => batch.insertAll(db.gymSets, gymSets),);
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Imported sets')));
|
||||
const SnackBar(content: Text('Imported sets')),);
|
||||
},
|
||||
));
|
||||
),);
|
||||
|
||||
if (item['title'] == 'Sound') {
|
||||
return Center(
|
||||
|
@ -147,7 +146,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
break;
|
||||
case 'Vibrate':
|
||||
db.update(db.settings).write(
|
||||
SettingsCompanion(vibrate: Value(value)));
|
||||
SettingsCompanion(vibrate: Value(value)),);
|
||||
break;
|
||||
case 'Notify':
|
||||
db
|
||||
|
@ -161,7 +160,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
break;
|
||||
case 'Show Unit':
|
||||
db.update(db.settings).write(
|
||||
SettingsCompanion(showUnit: Value(value)));
|
||||
SettingsCompanion(showUnit: Value(value)),);
|
||||
break;
|
||||
case 'Steps':
|
||||
db
|
||||
|
|
|
@ -37,7 +37,7 @@ class _SoundPickerState extends State<SoundPicker> {
|
|||
},
|
||||
child: Text(widget.path != null
|
||||
? "Sound: ${basename(widget.path!)}"
|
||||
: 'Alarm sound'),
|
||||
: 'Alarm sound',),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/material.dart' as material;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fmassive/database.dart';
|
||||
import 'package:fmassive/edit_plan.dart';
|
||||
import 'package:fmassive/main.dart';
|
||||
import 'package:moor_flutter/moor_flutter.dart';
|
||||
|
||||
|
@ -30,11 +29,15 @@ class _StartPlanState extends State<StartPlan> {
|
|||
..addColumns([db.gymSets.name, db.gymSets.sets])
|
||||
..where(db.gymSets.name.isIn(exercises))
|
||||
..groupBy([db.gymSets.name, db.gymSets.sets]))
|
||||
.map((row) =>
|
||||
MapEntry(row.read(db.gymSets.name), row.read(db.gymSets.sets)))
|
||||
.map(
|
||||
(row) =>
|
||||
MapEntry(row.read(db.gymSets.name), row.read(db.gymSets.sets)),
|
||||
)
|
||||
.get();
|
||||
final map = Map.fromIterables(
|
||||
query.map((entry) => entry.key), query.map((entry) => entry.value));
|
||||
query.map((entry) => entry.key),
|
||||
query.map((entry) => entry.value),
|
||||
);
|
||||
setState(() {
|
||||
totals = [];
|
||||
for (var exercise in exercises) {
|
||||
|
@ -54,7 +57,9 @@ class _StartPlanState extends State<StartPlan> {
|
|||
.map((row) => MapEntry(row.read(db.gymSets.name), row.read(countExp)))
|
||||
.get();
|
||||
final map = Map.fromIterables(
|
||||
query.map((entry) => entry.key), query.map((entry) => entry.value));
|
||||
query.map((entry) => entry.key),
|
||||
query.map((entry) => entry.value),
|
||||
);
|
||||
setState(() {
|
||||
counts = [];
|
||||
for (var exercise in exercises) {
|
||||
|
@ -76,7 +81,9 @@ class _StartPlanState extends State<StartPlan> {
|
|||
final firstSet = sets.first;
|
||||
repsController.text = firstSet.reps.toString();
|
||||
repsController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: firstSet.reps.toString().length);
|
||||
baseOffset: 0,
|
||||
extentOffset: firstSet.reps.toString().length,
|
||||
);
|
||||
weightController.text = firstSet.weight.toString();
|
||||
}
|
||||
|
||||
|
@ -99,86 +106,86 @@ class _StartPlanState extends State<StartPlan> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> actions = [];
|
||||
if (widget.plan.id.present)
|
||||
actions.add(IconButton(
|
||||
onPressed: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EditPlanPage(plan: widget.plan),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.edit)));
|
||||
|
||||
if (totals.isEmpty || counts.isEmpty)
|
||||
return const CircularProgressIndicator();
|
||||
if (totals.isEmpty || counts.isEmpty) return Container();
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text('Start plan'), actions: actions),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: material.Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: ((context, index) {
|
||||
return ListTile(
|
||||
title: Text(exercises[index]),
|
||||
subtitle: Text("${counts[index]}/${totals[index]}"),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedExercise = index;
|
||||
focus(index);
|
||||
});
|
||||
},
|
||||
leading: Radio<int>(
|
||||
value: index,
|
||||
groupValue: selectedExercise,
|
||||
onChanged: (value) {
|
||||
print("onChanged $value");
|
||||
if (value == null) return;
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text('Start plan')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: material.Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: ((context, index) {
|
||||
return ListTile(
|
||||
title: Text(exercises[index]),
|
||||
subtitle: Text("${counts[index]}/${totals[index]}"),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedExercise = value;
|
||||
selectedExercise = index;
|
||||
focus(index);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
itemCount: exercises.length,
|
||||
leading: Radio<int>(
|
||||
value: index,
|
||||
groupValue: selectedExercise,
|
||||
onChanged: (value) {
|
||||
print("onChanged $value");
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
selectedExercise = value;
|
||||
focus(index);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
itemCount: exercises.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Reps'),
|
||||
controller: repsController,
|
||||
focusNode: repsNode,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Weight'),
|
||||
controller: weightController,
|
||||
focusNode: weightNode,
|
||||
),
|
||||
],
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Reps'),
|
||||
controller: repsController,
|
||||
focusNode: repsNode,
|
||||
onTap: () {
|
||||
repsController.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: repsController.text.length,
|
||||
);
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Weight'),
|
||||
controller: weightController,
|
||||
focusNode: weightNode,
|
||||
onTap: () {
|
||||
weightController.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: weightController.text.length,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
final gymSet = GymSetsCompanion(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
final gymSet = GymSetsCompanion(
|
||||
created: Value(DateTime.now().toIso8601String()),
|
||||
name: Value(exercises[selectedExercise]),
|
||||
reps: Value(int.tryParse(repsController.text) ?? 0),
|
||||
weight: Value(double.tryParse(weightController.text) ?? 0));
|
||||
await db.into(db.gymSets).insert(gymSet);
|
||||
const platform = MethodChannel('com.massive/android');
|
||||
platform.invokeMethod('timer', [180000]);
|
||||
await getCounts();
|
||||
},
|
||||
child: const Icon(Icons.check),
|
||||
weight: Value(double.tryParse(weightController.text) ?? 0),
|
||||
);
|
||||
await db.into(db.gymSets).insert(gymSet);
|
||||
const platform = MethodChannel('com.massive/android');
|
||||
platform.invokeMethod('timer', [180000]);
|
||||
await getCounts();
|
||||
},
|
||||
child: const Icon(Icons.check),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user