@@ -22,7 +22,6 @@ import 'package:wger/helpers/colors.dart';
22
22
import 'package:wger/helpers/misc.dart' ;
23
23
import 'package:wger/helpers/ui.dart' ;
24
24
import 'package:wger/l10n/generated/app_localizations.dart' ;
25
- import 'package:wger/models/exercises/exercise.dart' ;
26
25
import 'package:wger/models/workouts/log.dart' ;
27
26
import 'package:wger/models/workouts/routine.dart' ;
28
27
import 'package:wger/models/workouts/session.dart' ;
@@ -116,18 +115,22 @@ class ExerciseLogChart extends StatelessWidget {
116
115
mainAxisSize: MainAxisSize .max,
117
116
children: [
118
117
LogChartWidgetFl (_logs, _selectedDate),
119
- Row (
120
- mainAxisAlignment: MainAxisAlignment .center,
121
- children: [
122
- ..._logs.keys.map ((reps) {
123
- colors.moveNext ();
124
- return Indicator (
125
- color: colors.current,
126
- text: formatNum (reps).toString (),
127
- isSquare: false ,
128
- );
129
- }),
130
- ],
118
+ SingleChildScrollView (
119
+ scrollDirection: Axis .horizontal,
120
+ child: Row (
121
+ mainAxisAlignment: MainAxisAlignment .center,
122
+ children: [
123
+ ..._logs.keys.map ((reps) {
124
+ colors.moveNext ();
125
+
126
+ return Indicator (
127
+ color: colors.current,
128
+ text: formatNum (reps).toString (),
129
+ isSquare: false ,
130
+ );
131
+ }),
132
+ ],
133
+ ),
131
134
),
132
135
const SizedBox (height: 15 ),
133
136
],
@@ -139,49 +142,42 @@ class DayLogWidget extends StatelessWidget {
139
142
final DateTime _date;
140
143
final Routine _routine;
141
144
142
- final WorkoutSession _session;
143
- final Map <Exercise , List <Log >> _exerciseMap;
144
-
145
- const DayLogWidget (this ._date, this ._exerciseMap, this ._session, this ._routine);
145
+ const DayLogWidget (this ._date, this ._routine);
146
146
147
147
@override
148
148
Widget build (BuildContext context) {
149
+ final sessionApi =
150
+ _routine.sessions.firstWhere ((sessionApi) => sessionApi.session.date.isSameDayAs (_date));
151
+ final exercises = sessionApi.exercises;
152
+
149
153
return Card (
150
154
child: Column (
151
155
children: [
152
- SessionInfo (_session ),
153
- ..._exerciseMap.keys .map ((exercise) {
156
+ SessionInfo (sessionApi.session ),
157
+ ...exercises .map ((exercise) {
154
158
final translation =
155
159
exercise.getTranslation (Localizations .localeOf (context).languageCode);
156
160
return Column (
157
161
children: [
158
- if (_exerciseMap[exercise]! .isNotEmpty)
159
- Text (
160
- translation.name,
161
- style: Theme .of (context).textTheme.headlineSmall,
162
- )
163
- else
164
- Container (),
165
- ..._exerciseMap[exercise]! .map (
166
- (log) => Row (
167
- mainAxisAlignment: MainAxisAlignment .spaceBetween,
168
- children: [
169
- Text (log.singleLogRepTextNoNl),
170
- IconButton (
171
- icon: const Icon (Icons .delete),
172
- onPressed: () {
173
- showDeleteDialog (
174
- context,
175
- translation.name,
176
- log,
177
- translation,
178
- _exerciseMap,
179
- );
180
- },
181
- ),
182
- ],
183
- ),
162
+ Text (
163
+ translation.name,
164
+ style: Theme .of (context).textTheme.titleMedium,
184
165
),
166
+ ...sessionApi.logs.where ((l) => l.exerciseId == exercise.id).map (
167
+ (log) => Row (
168
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
169
+ children: [
170
+ Text (log.singleLogRepTextNoNl),
171
+ IconButton (
172
+ icon: const Icon (Icons .delete),
173
+ key: ValueKey ('delete-log-${log .id }' ),
174
+ onPressed: () {
175
+ showDeleteDialog (context, translation.name, log);
176
+ },
177
+ ),
178
+ ],
179
+ ),
180
+ ),
185
181
Padding (
186
182
padding: const EdgeInsets .symmetric (horizontal: 15 ),
187
183
child: ExerciseLogChart (
0 commit comments