Skip to content

Commit

Permalink
[Enhancement] Calendar Improvements (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Dec 18, 2023
1 parent edc10f2 commit a537ea2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/base/errorHandling/error_handling_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ErrorHandlingRouter extends ConsumerWidget {
}

void recordFlutterError(FlutterErrorDetails flutterErrorDetails) {
if (!kIsWeb) {
if (!kIsWeb && !kDebugMode) {
FirebaseCrashlytics.instance.recordFlutterFatalError(flutterErrorDetails);
}
}
Expand Down
22 changes: 21 additions & 1 deletion lib/calendarComponent/services/calendar_view_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CalendarViewService {
calendarEvent = event;
}

if (calendarEvent != null) {
if (calendarEvent != null && calendarEvent.url != null) {
showModalBottomSheet(
isScrollControlled: true,
useSafeArea: true,
Expand All @@ -66,6 +66,26 @@ class CalendarViewService {
);
},
);
} else if (calendarEvent != null) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
calendarEvent!.title,
textAlign: TextAlign.center,
),
content: Text(
calendarEvent.timeDatePeriod(context),
),
actionsAlignment: MainAxisAlignment.center,
actions: [
ElevatedButton(
onPressed: () => Navigator.pop(context),
child: const Text("Okay"),
),
],
),
);
}
}
}
12 changes: 8 additions & 4 deletions lib/calendarComponent/viewModels/calendar_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ class CalendarViewModel {
CalendarEvent? leftColumn;
List<CalendarEvent> rightColumn = [];

final filteredEvents = events.value ?? [];
filteredEvents
.removeWhere((element) => element.startDate.isBefore(DateTime.now()));
final filteredEvents = events.value
?.where(
(element) => element.startDate.isBefore(
DateTime.now(),
),
)
.toList() ??
[];
filteredEvents.sort((a, b) => a.startDate.compareTo(b.startDate));

final currentDate = DateTime.now();
final currentDay =
DateTime(currentDate.year, currentDate.month, currentDate.day);
Expand Down
1 change: 0 additions & 1 deletion lib/calendarComponent/views/calendar_day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CalendarDayView extends ConsumerWidget {
},
headerDateFormat: "EEEE, dd.MM.yyyy",
showNavigationArrow: true,
minDate: getIt<CalendarViewService>().minDate(ref),
maxDate: getIt<CalendarViewService>().maxDate(ref),
timeSlotViewSettings: const TimeSlotViewSettings(
startHour: 7,
Expand Down
1 change: 0 additions & 1 deletion lib/calendarComponent/views/calendar_month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class CalendarMonthView extends ConsumerWidget {
firstDayOfWeek: 1,
showDatePickerButton: true,
showNavigationArrow: true,
minDate: getIt<CalendarViewService>().minDate(ref),
maxDate: getIt<CalendarViewService>().maxDate(ref),
onTap: (details) {
getIt<CalendarViewService>()
Expand Down
9 changes: 6 additions & 3 deletions lib/calendarComponent/views/calendar_week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ class CalendarWeekView extends ConsumerWidget {
context,
),
onTap: (details) {
getIt<CalendarViewService>()
.showModalSheet(details, null, context, ref);
getIt<CalendarViewService>().showModalSheet(
details,
null,
context,
ref,
);
},
firstDayOfWeek: 1,
showDatePickerButton: true,
headerDateFormat: "",
showWeekNumber: true,
showNavigationArrow: true,
minDate: getIt<CalendarViewService>().minDate(ref),
maxDate: getIt<CalendarViewService>().maxDate(ref),
timeSlotViewSettings: const TimeSlotViewSettings(
startHour: 7,
Expand Down
7 changes: 5 additions & 2 deletions lib/lectureComponent/views/basic_lecture_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class BasicLectureInfoView extends ConsumerWidget {
const BasicLectureInfoView(
{super.key, required this.lectureDetails, this.lecture});
const BasicLectureInfoView({
super.key,
required this.lectureDetails,
this.lecture,
});

final LectureDetails lectureDetails;
final Lecture? lecture;
Expand Down

0 comments on commit a537ea2

Please sign in to comment.