Files
HiddingselAppOriginal/lib/appflow/model/event_organisations.dart
2026-02-13 15:53:22 +01:00

48 lines
1.5 KiB
Dart

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<bool> 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<String, dynamic> 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<EventOrganisationModel?>().firstWhere((topic) => topic?.id == id, orElse: () => null);
static List<EventOrganisationModel> values = GetIt.I<List<EventOrganisationModel>>()
..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;
}