Skip to content

Commit

Permalink
Merge pull request #109 from andreped:107-feat-allow-visualization-ma…
Browse files Browse the repository at this point in the history
…x-or-average-weight-lifted-per-day-over-time

Enhanced visualization tab; allow aggregated visualization; allow line plots
  • Loading branch information
andreped authored Aug 9, 2024
2 parents 493111f + ad1f92b commit 56e0e89
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 140 deletions.
4 changes: 3 additions & 1 deletion lib/core/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DatabaseHelper {
required String weight,
required int reps,
required int sets,
required String timestamp,
}) async {
final db = await database;
await db.update(
Expand All @@ -128,13 +129,14 @@ class DatabaseHelper {
'weight': weight,
'reps': reps,
'sets': sets,
// Note: Do not update the timestamp here
'timestamp': timestamp,
},
where: 'id = ?',
whereArgs: [id],
);
}


Future<bool> isNewHighScore(String exerciseName, double newWeight, int newReps) async {
final db = await database;

Expand Down
73 changes: 37 additions & 36 deletions lib/tabs/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class _ExerciseStoreHomePageState extends State<ExerciseStoreHomePage> with Sing
weight: result['weight'],
reps: result['reps'],
sets: result['sets'],
timestamp: result['timestamp'],
);
setState(() {});
}
Expand Down Expand Up @@ -212,43 +213,43 @@ class _ExerciseStoreHomePageState extends State<ExerciseStoreHomePage> with Sing
}
final exercises = snapshot.data!;
return DataTable(
columns: const [
DataColumn(label: Text('ID')),
DataColumn(label: Text('Exercise')),
DataColumn(label: Text('Weight')),
DataColumn(label: Text('Reps')),
DataColumn(label: Text('Sets')),
DataColumn(label: Text('Timestamp')),
DataColumn(label: Text('Actions')),
],
rows: exercises.map((exercise) {
return DataRow(cells: [
DataCell(Text(exercise['id'].toString())),
DataCell(Text(exercise['exercise'])),
DataCell(Text(exercise['weight'])),
DataCell(Text(exercise['reps'].toString())),
DataCell(Text(exercise['sets'].toString())),
DataCell(Text(exercise['timestamp'])),
DataCell(
Row(
children: [
IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
_showEditDialog(exercise);
},
),
IconButton(
icon: const Icon(Icons.delete),
onPressed: () async {
await _deleteExercise(exercise['id']);
},
),
],
columns: const [
DataColumn(label: Text('ID')),
DataColumn(label: Text('Exercise')),
DataColumn(label: Text('Weight')),
DataColumn(label: Text('Reps')),
DataColumn(label: Text('Sets')),
DataColumn(label: Text('Timestamp')),
DataColumn(label: Text('Actions')),
],
rows: exercises.map((exercise) {
return DataRow(cells: [
DataCell(Text(exercise['id'].toString())),
DataCell(Text(exercise['exercise'])),
DataCell(Text(exercise['weight'])),
DataCell(Text(exercise['reps'].toString())),
DataCell(Text(exercise['sets'].toString())),
DataCell(Text(exercise['timestamp'])), // Display the timestamp
DataCell(
Row(
children: [
IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
_showEditDialog(exercise);
},
),
IconButton(
icon: const Icon(Icons.delete),
onPressed: () async {
await _deleteExercise(exercise['id']);
},
),
],
),
),
),
]);
}).toList(),
]);
}).toList(),
);
},
),
Expand Down
Loading

0 comments on commit 56e0e89

Please sign in to comment.