import 'package:get_it/get_it.dart'; import 'package:hiddingsel_app/appflow/model/represented_organisations.dart'; import 'package:hiddingsel_app/appflow/model/topics.dart'; import '../controller/settings.dart'; import 'interfaces.dart'; class EventOrganisationModel extends PushNotificationTopicModel with AllowsEventNotifications { final Uri? ical; Future get eventNotificationAllowed => SettingsController.eventNotificationAllowed(this); allowEventNotification(bool allowed) { if (allowed) { SettingsController.allowEventNotification(this); } else { SettingsController.unallowEventNotification(this); } } const EventOrganisationModel(id, name, this.ical) : super(id, name); factory EventOrganisationModel.fromJson(Map json) { return EventOrganisationModel( json['id'] as String, json['name'] as String, (json['ical'] as String?) != null ? Uri.parse(json['ical'] as String) : null, ); } static EventOrganisationModel? fromId(String id) => EventOrganisationModel.values.cast().firstWhere((topic) => topic?.id == id, orElse: () => null); static List values = GetIt.I>() ..addAll(RepresentedOrganisationModel.values) ..sort((a, b) => a.name.compareTo(b.name)); bool operator == (Object other) => other is EventOrganisationModel && runtimeType == other.runtimeType && id == other.id; int get hashCode => id.hashCode; }