Skip to content

Commit

Permalink
Add support for units in cardio - 1.0.67 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonp2412 committed Apr 28, 2024
1 parent 8bb3f75 commit 9cfa871
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 45 deletions.
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/74.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Add support for units in cardio
- Fix grouping by week for cardio lines
- Fix grouping by weeks for graph
- Fix grouping by week
- Refactor plans
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/3_en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/5_en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/tenInchScreenshots/2_en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion lib/add_exercise_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class _AddExercisePageState extends State<AddExercisePage> {
DropdownButtonFormField<String>(
value: _unit,
decoration: const InputDecoration(labelText: 'Default unit'),
items: ['kg', 'lb'].map((String value) {
items:
(_cardio ? ['km', 'mi'] : ['kg', 'lb']).map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
Expand All @@ -69,6 +70,10 @@ class _AddExercisePageState extends State<AddExercisePage> {
onTap: () {
setState(() {
_cardio = !_cardio;
if (_cardio)
_unit = 'km';
else
_unit = 'kg';
});
},
trailing: Switch(
Expand Down
2 changes: 2 additions & 0 deletions lib/cardio_data.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class CardioData {
final DateTime created;
final double value;
final String unit;

CardioData({
required this.created,
required this.value,
required this.unit,
});
}
2 changes: 2 additions & 0 deletions lib/cardio_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class _CardioLineState extends State<CardioLine> {
db.gymSets.distance.sum(),
db.gymSets.distance.sum() / db.gymSets.duration.sum(),
db.gymSets.created,
db.gymSets.unit,
])
..where(db.gymSets.name.equals(widget.name))
..where(db.gymSets.hidden.equals(false))
Expand Down Expand Up @@ -112,6 +113,7 @@ class _CardioLineState extends State<CardioLine> {
rows.add(CardioData(
value: value,
created: row.read(db.gymSets.created)!,
unit: row.read(db.gymSets.unit)!,
));
spots.add(FlSpot(index.toDouble(), value));
}
Expand Down
32 changes: 16 additions & 16 deletions lib/edit_gym_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ class _EditGymSetState extends State<EditGymSet> {
baseOffset: 0,
extentOffset: _bodyWeightController.text.length),
),
if (!_cardio)
DropdownButtonFormField<String>(
value: _unit,
decoration: const InputDecoration(labelText: 'Unit'),
items: ['kg', 'lb'].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_unit = newValue!;
});
},
),
DropdownButtonFormField<String>(
value: _unit,
decoration: const InputDecoration(labelText: 'Unit'),
items:
(_cardio ? ['km', 'mi'] : ['kg', 'lb']).map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_unit = newValue!;
});
},
),
ListTile(
title: const Text('Created Date'),
subtitle: Text(_created.toString()),
Expand Down
2 changes: 1 addition & 1 deletion lib/graph_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class _GraphHistoryState extends State<GraphHistory> {
.format(gymSet.created)),
trailing: Text(
gymSet.cardio
? "${gymSet.distance} / ${gymSet.duration}"
? "${gymSet.distance}${gymSet.unit} / ${gymSet.duration}"
: "${gymSet.reps} x ${gymSet.weight} ${gymSet.unit}",
style: const TextStyle(fontSize: 16)),
selected: _selected.contains(gymSet.id),
Expand Down
55 changes: 29 additions & 26 deletions lib/start_plan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class _StartPlanPageState extends State<StartPlanPage> {
..limit(1))
.getSingleOrNull();
setState(() {
_unit = last?.unit ?? 'kg';
if (last?.cardio == true && _unit == 'kg') _unit = 'km';
_repsController.text = last != null ? last.reps.toString() : "0.0";
_weightController.text = last != null ? last.weight.toString() : "0.0";
_distanceController.text =
Expand Down Expand Up @@ -236,23 +238,21 @@ class _StartPlanPageState extends State<StartPlanPage> {
},
onSubmitted: (value) async => await _save(timerState, settings),
),
if (settings.showUnits && !_cardio)
DropdownButtonFormField<String>(
value: _unit,
decoration: const InputDecoration(labelText: 'Unit'),
items: ['kg', 'lb'].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
if (_cardio) ...[
TextField(
controller: _durationController,
focusNode: _durationNode,
decoration: const InputDecoration(
labelText: 'Duration',
),
keyboardType: TextInputType.number,
onTap: () {
_durationController.selection = TextSelection(
baseOffset: 0,
extentOffset: _durationController.text.length,
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_unit = newValue!;
});
},
),
if (_cardio) ...[
TextField(
focusNode: _distanceNode,
controller: _distanceController,
Expand All @@ -270,21 +270,24 @@ class _StartPlanPageState extends State<StartPlanPage> {
_durationNode.requestFocus();
},
),
TextField(
controller: _durationController,
focusNode: _durationNode,
decoration: const InputDecoration(
labelText: 'Duration',
),
keyboardType: TextInputType.number,
onTap: () {
_durationController.selection = TextSelection(
baseOffset: 0,
extentOffset: _durationController.text.length,
],
if (settings.showUnits)
DropdownButtonFormField<String>(
value: _unit,
decoration: const InputDecoration(labelText: 'Unit'),
items:
(_cardio ? ['km', 'mi'] : ['kg', 'lb']).map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_unit = newValue!;
});
},
),
],
Expanded(
child: StreamBuilder(
stream: _countStream,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flexify
description: Track gym progress, visualize graphs, enjoy offline support & timers
publish_to: none
version: 1.0.66+73
version: 1.0.67+74
environment:
sdk: '>=3.2.6 <4.0.0'
dependencies:
Expand Down

0 comments on commit 9cfa871

Please sign in to comment.