Skip to content

Commit

Permalink
bug fix with the time column and more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
user5522 committed Dec 20, 2023
1 parent 1e14b42 commit 497c6e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 40 deletions.
2 changes: 1 addition & 1 deletion lib/components/widgets/grid_view_subject_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 7 additions & 17 deletions lib/components/widgets/time_column.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
),
);
}),
),
]);
}
Expand Down
32 changes: 10 additions & 22 deletions lib/constants/custom_times.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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}";
}

0 comments on commit 497c6e6

Please sign in to comment.