From b8f4167c9e2d13ea457f06cdedb047f52c73fe69 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Tue, 18 Mar 2025 16:14:22 +0100 Subject: [PATCH] Show special tile indicating end of the week --- lib/l10n/app_en.arb | 1 + lib/widgets/dashboard/widgets.dart | 20 ++++++++++++++++++++ lib/widgets/routines/day.dart | 13 ++++++------- lib/widgets/routines/routine_detail.dart | 22 +++++++++++++++++++--- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index fde389971..846e794e4 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -208,6 +208,7 @@ "restDay": "Rest day", "isRestDay": "Is rest day", "isRestDayHelp": "Please note that all sets and exercises will be removed when you mark a day as a rest day.", + "tillEndOfWeek": "Till end of the week", "needsLogsToAdvance": "Needs logs to advance", "needsLogsToAdvanceHelp": "Select if you want the routine to progress to the next scheduled day only if you've logged a workout for the day", "routineDays": "Days in routine", diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index ca2da1497..09f8a2abe 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -384,6 +384,10 @@ class _DashboardWorkoutWidgetState extends State { } for (final dayData in _routine!.dayDataCurrentIteration) { + if (dayData.day == null) { + continue; + } + out.add(SizedBox( width: double.infinity, child: Row( @@ -456,6 +460,22 @@ class _DashboardWorkoutWidgetState extends State { out.add(const Divider()); } + if (_routine!.fitInWeek) { + out.add(Row( + children: [ + Expanded( + child: Text( + AppLocalizations.of(context).tillEndOfWeek, + style: const TextStyle(fontWeight: FontWeight.bold), + overflow: TextOverflow.ellipsis, + ), + ), + const Icon(Icons.hotel), + ], + )); + out.add(const Divider()); + } + return out; } diff --git a/lib/widgets/routines/day.dart b/lib/widgets/routines/day.dart index f47f98a9e..71434e9d9 100644 --- a/lib/widgets/routines/day.dart +++ b/lib/widgets/routines/day.dart @@ -138,7 +138,6 @@ class DayHeader extends StatelessWidget { if (_dayData.day == null || _dayData.day!.isRest) { return ListTile( - // tileColor: Colors.amber, tileColor: Theme.of(context).focusColor, contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), title: Text( @@ -165,12 +164,12 @@ class DayHeader extends StatelessWidget { trailing: _dayData.date.isSameDayAs(DateTime.now()) ? const Icon(Icons.today) : null, minLeadingWidth: 8, onTap: () { - _viewMode - ? null - : Navigator.of(context).pushNamed( - GymModeScreen.routeName, - arguments: GymModeArguments(_routineId, _dayData.day!.id!, _dayData.iteration), - ); + if (!_viewMode) { + Navigator.of(context).pushNamed( + GymModeScreen.routeName, + arguments: GymModeArguments(_routineId, _dayData.day!.id!, _dayData.iteration), + ); + } }, ); } diff --git a/lib/widgets/routines/routine_detail.dart b/lib/widgets/routines/routine_detail.dart index d69ca4d6b..f7ad8bcdc 100644 --- a/lib/widgets/routines/routine_detail.dart +++ b/lib/widgets/routines/routine_detail.dart @@ -50,10 +50,26 @@ class RoutineDetail extends StatelessWidget { ), ), ..._routine.dayDataCurrentIteration - // TODO: we should probably add a block at the end of the days telling - // the user that there are no more days in the routine till next week - // .where((dayData) => dayData.day != null) + .where((dayData) => dayData.day != null) .map((dayData) => RoutineDayWidget(dayData, _routine.id!, viewMode)), + if (_routine.fitInWeek) + Padding( + padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12), + child: Card( + margin: EdgeInsets.zero, + child: ListTile( + tileColor: Theme.of(context).focusColor, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + title: Text( + i18n.tillEndOfWeek, + style: Theme.of(context).textTheme.headlineSmall, + overflow: TextOverflow.ellipsis, + ), + leading: const Icon(Icons.hotel), + minLeadingWidth: 8, + ), + ), + ), ], ); }