#10 Fixed gray background in timetable on days outside of given range

This commit is contained in:
Elias Müller 2024-01-28 16:40:52 +01:00
parent 8db1139d0d
commit 395d74ed4e
3 changed files with 6 additions and 12 deletions

View File

@ -2,4 +2,8 @@ extension IsSameDay on DateTime {
bool isSameDay(DateTime other) { bool isSameDay(DateTime other) {
return year == other.year && month == other.month && day == other.day; return year == other.year && month == other.month && day == other.day;
} }
DateTime nextWeekday(int day) {
return add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
}
} }

View File

@ -12,16 +12,6 @@ import '../../api/webuntis/queries/getTimetable/getTimetableResponse.dart';
import '../../api/webuntis/webuntisError.dart'; import '../../api/webuntis/webuntisError.dart';
import '../dataHolder.dart'; import '../dataHolder.dart';
extension DateTimeExtension on DateTime {
DateTime jumpToNextWeekDay(int day) {
return add(
Duration(
days: (day - weekday) % DateTime.daysPerWeek,
),
);
}
}
class TimetableProps extends DataHolder { class TimetableProps extends DataHolder {
final _queryWeek = DateTime.now().add(const Duration(days: 2)); final _queryWeek = DateTime.now().add(const Duration(days: 2));

View File

@ -102,8 +102,8 @@ class _TimetableState extends State<Timetable> {
view: CalendarView.workWeek, view: CalendarView.workWeek,
dataSource: _buildTableEvents(value), dataSource: _buildTableEvents(value),
maxDate: DateTime.now().add(const Duration(days: 7)), maxDate: DateTime.now().add(const Duration(days: 7)).nextWeekday(DateTime.saturday),
minDate: DateTime.now().subtract(const Duration (days: 14)), minDate: DateTime.now().subtract(const Duration (days: 14)).nextWeekday(DateTime.sunday),
controller: controller, controller: controller,