From 497c6e65af90f6283913ce3ebcfbd31a54ebb27e Mon Sep 17 00:00:00 2001 From: Username * Date: Thu, 21 Dec 2023 00:05:34 +0100 Subject: [PATCH] bug fix with the time column and more improvements --- .../widgets/grid_view_subject_builder.dart | 2 +- lib/components/widgets/time_column.dart | 24 ++++---------- lib/constants/custom_times.dart | 32 ++++++------------- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/lib/components/widgets/grid_view_subject_builder.dart b/lib/components/widgets/grid_view_subject_builder.dart index ed76096..bb64e75 100644 --- a/lib/components/widgets/grid_view_subject_builder.dart +++ b/lib/components/widgets/grid_view_subject_builder.dart @@ -74,7 +74,7 @@ class SubjectBuilder extends ConsumerWidget { }, borderRadius: BorderRadius.circular(5), child: Ink( - padding: const EdgeInsets.all(5), + padding: const EdgeInsets.all(3), decoration: BoxDecoration( color: color, border: Border.all( diff --git a/lib/components/widgets/time_column.dart b/lib/components/widgets/time_column.dart index c2a0eff..e1ca42e 100644 --- a/lib/components/widgets/time_column.dart +++ b/lib/components/widgets/time_column.dart @@ -17,29 +17,19 @@ class TimeColumn extends ConsumerWidget { return Column(children: [ Column( - children: List.generate( - rows(ref), - (i) => SizedBox( + children: List.generate(rows(ref), (i) { + return SizedBox( height: compactMode ? 125 : 100, child: Text( is24HoursFormat - ? times24h[i + - (customStartTime.hour == 0 - ? 0 - : customTimePeriod - ? customStartTime.hour - : 8)] - : timespmam[i + - (customStartTime.hour == 0 - ? 0 - : customTimePeriod - ? customStartTime.hour - : 8)], + ? times24h[i + (customTimePeriod ? customStartTime.hour : 8)] + : timespmam[ + i + (customTimePeriod ? customStartTime.hour : 8)], style: const TextStyle(fontSize: 13), textAlign: TextAlign.center, ), - ), - ), + ); + }), ), ]); } diff --git a/lib/constants/custom_times.dart b/lib/constants/custom_times.dart index 7b53417..fda3a9f 100644 --- a/lib/constants/custom_times.dart +++ b/lib/constants/custom_times.dart @@ -8,11 +8,8 @@ TimeOfDay getCustomStartTime(TimeOfDay customTime, WidgetRef ref) { final customTimePeriod = ref.watch(settingsProvider).customTimePeriod; if (customTimePeriod) { - if (customTime.hour != 00) { - return TimeOfDay(hour: customTime.hour, minute: customTime.minute); - } else { - return const TimeOfDay(hour: 0, minute: 0); - } + if (customTime.hour != 0) return customTime; + return const TimeOfDay(hour: 0, minute: 0); } else { return const TimeOfDay(hour: 8, minute: 0); } @@ -24,30 +21,21 @@ TimeOfDay getCustomEndTime(TimeOfDay customTime, WidgetRef ref) { final customTimePeriod = ref.watch(settingsProvider).customTimePeriod; if (customTimePeriod) { - if (customTime.hour != 00) { - return TimeOfDay(hour: customTime.hour, minute: customTime.minute); - } else { - return const TimeOfDay(hour: 24, minute: 0); - } + if (customTime.hour != 0) return customTime; + return const TimeOfDay(hour: 24, minute: 0); } else { return const TimeOfDay(hour: 18, minute: 0); } } -/// Returns the hour part of the customTime, formatted. +/// Returns a formatted custom time hour. String getCustomTimeHour(TimeOfDay customTime) { - if (customTime.hour < 10) { - return "0${customTime.hour}"; - } else { - return "${customTime.hour}"; - } + if (customTime.hour < 10) return "0${customTime.hour}"; + return "${customTime.hour}"; } -/// Returns the minute part of the customTime, formatted. +/// Returns a formatted custom time hour. String getCustomTimeMinute(TimeOfDay customTime) { - if (customTime.minute < 10) { - return "0${customTime.minute}"; - } else { - return "${customTime.minute}"; - } + if (customTime.minute < 10) return "0${customTime.minute}"; + return "${customTime.minute}"; }