Skip to content

Commit

Permalink
Handle Locations List in CalendarEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber committed Nov 23, 2024
1 parent db538f5 commit 015d719
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 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
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
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
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

0 comments on commit 015d719

Please sign in to comment.