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