Skip to content

Commit

Permalink
Various Minor Bugfixes (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Nov 30, 2024
1 parent ad5d21c commit 4e6cbe2
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 67 deletions.
3 changes: 2 additions & 1 deletion lib/calendarComponent/model/calendar_data_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class MeetingDataSource extends CalendarDataSource {
@override
String getSubject(int index) {
final calendarEvent = cast<CalendarEvent>(appointments![index])!;
return "${calendarEvent.title}\n${calendarEvent.location ?? ""}";
final location = calendarEvent.locations.firstOrNull ?? "";
return "${calendarEvent.title}\n$location";
}

@override
Expand Down
9 changes: 6 additions & 3 deletions lib/calendarComponent/model/calendar_event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:campus_flutter/base/theme/constants.dart';
import 'package:campus_flutter/base/util/read_list_value.dart';
import 'package:campus_flutter/searchComponent/model/comparison_token.dart';
import 'package:campus_flutter/searchComponent/protocols/searchable.dart';
import 'package:easy_localization/easy_localization.dart';
Expand All @@ -19,7 +20,8 @@ class CalendarEvent extends Searchable {
final DateTime startDate;
@JsonKey(name: "dtend")
final DateTime endDate;
final String? location;
@JsonKey(readValue: readListValue)
final List<String> locations;

int? color;
bool? isVisible;
Expand Down Expand Up @@ -84,7 +86,8 @@ class CalendarEvent extends Searchable {
@JsonKey(includeFromJson: false, includeToJson: false)
List<ComparisonToken> get comparisonTokens => [
if (title != null) ComparisonToken(value: title!),
if (location != null) ComparisonToken(value: location!),
if (locations.isNotEmpty)
for (var location in locations) ComparisonToken(value: location),
];

CalendarEvent({
Expand All @@ -95,7 +98,7 @@ class CalendarEvent extends Searchable {
this.description,
required this.startDate,
required this.endDate,
this.location,
required this.locations,
this.color,
});

Expand Down
6 changes: 4 additions & 2 deletions lib/calendarComponent/model/calendar_event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class CalendarAdditionViewModel {
title: titleController.text,
startDate: from.value,
endDate: to.value,
locations: [],
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/calendarComponent/views/event_creation_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class EventCreationView extends ConsumerWidget {
.read(calendarAdditionViewModel(calendarEvent))
.saveEvent()
.then((value) {
ref.invalidate(calendarAdditionViewModel);
if (context.mounted) {
ref.invalidate(calendarAdditionViewModel);
context.canPop() ? context.pop() : context.go(calendar);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class CalendarHomeWidgetEventView extends ConsumerWidget {
style: Theme.of(context).textTheme.labelSmall,
),
Text(
calendarEvent.location ?? context.tr("unknown"),
calendarEvent.locations.firstOrNull ??
context.tr("unknown"),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelSmall,
Expand Down
2 changes: 1 addition & 1 deletion lib/homeComponent/view/contactCard/contact_card_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class _ContactCardViewState extends ConsumerState<ContactCardView> {
}

ImageProvider<Object> imageData(AsyncSnapshot<List<StudentCard>?> snapshot) {
if (snapshot.hasData) {
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
return Image.memory(
base64DecodeImageData(snapshot.data!.first.image),
).image;
Expand Down
5 changes: 1 addition & 4 deletions lib/personComponent/views/person_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ class _PersonDetailsViewState extends ConsumerState<PersonDetailsView> {
),
onTap: () => context.push(
roomSearch,
extra: (
personDetails.rooms.first.id,
null,
),
extra: personDetails.rooms.first.id,
),
),
ListTile(
Expand Down
29 changes: 16 additions & 13 deletions lib/placesComponent/views/homeWidget/cafeteria_widget_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ class _CafeteriaWidgetViewState extends ConsumerState<CafeteriaWidgetView> {
Icons.filter_list,
color: context.primaryColor,
),
onTap: () => showModalBottomSheet(
builder: (context) => PreferenceSelectionView<Cafeteria>(
data: ref
.read(cafeteriasViewModel)
.getCafeteriaEntries(context),
entry: context.tr("cafeteria"),
),
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
showDragHandle: true,
),
onTap: () => context.mounted
? showModalBottomSheet(
builder: (context) =>
PreferenceSelectionView<Cafeteria>(
data: ref
.read(cafeteriasViewModel)
.getCafeteriaEntries(context),
entry: context.tr("cafeteria"),
),
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
showDragHandle: true,
)
: null,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class CalendarSearchResultView extends ConsumerWidget {
),
IconText(
iconData: Icons.location_pin,
label: calendarEvent.location ?? context.tr("unknown"),
label:
calendarEvent.locations.firstOrNull ?? context.tr("unknown"),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.secondary,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/settingsComponent/views/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class SettingsView extends ConsumerWidget {

Widget _resetPreferencesButton(BuildContext context, WidgetRef ref) {
return ListTile(
onTap: () => ref.read(onboardingViewModel).resetPreferences(ref),
onTap: () => context.mounted
? ref.read(onboardingViewModel).resetPreferences(ref)
: null,
dense: true,
title: Text(
context.tr("resetPreferences"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BasicLectureInfoView extends ConsumerWidget {
),
),
),
if (lecture?.speaker == null)
if (lecture?.speaker == null && lectureDetails.speaker != null)
BasicLectureInfoRowView(
information: Speaker.getSpeakerName(lectureDetails.speaker!),
iconData: Icons.person,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class LectureMeetingInfoView extends ConsumerWidget {
iconData: Icons.hourglass_top,
),
BasicLectureInfoRowView(
information:
ref.read(viewModel).event!.location ?? context.tr("unknown"),
information: ref.read(viewModel).event!.locations.firstOrNull ??
context.tr("unknown"),
iconData: Icons.location_on,
trailingWidget: IconButton(
onPressed: () => context.push(
roomSearch,
extra: ref.read(viewModel).event!.location,
extra: ref.read(viewModel).event!.locations.firstOrNull,
),
icon: Icon(
Icons.search,
Expand Down
Loading

0 comments on commit 4e6cbe2

Please sign in to comment.