refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
enum CalendarEventStatus { active, archived }
|
||||
|
||||
class CalendarEvent {
|
||||
final String id;
|
||||
final String title;
|
||||
final DateTime startAt;
|
||||
final DateTime? endAt;
|
||||
final CalendarEventStatus status;
|
||||
|
||||
const CalendarEvent({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.startAt,
|
||||
required this.endAt,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory CalendarEvent.fromJson(Map<String, dynamic> json) {
|
||||
return CalendarEvent(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
startAt: DateTime.parse(json['start_at'] as String).toLocal(),
|
||||
endAt: json['end_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['end_at'] as String).toLocal(),
|
||||
status: _calendarEventStatusFromApi(json['status'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CalendarEventStatus _calendarEventStatusFromApi(String raw) {
|
||||
switch (raw) {
|
||||
case 'active':
|
||||
return CalendarEventStatus.active;
|
||||
case 'archived':
|
||||
return CalendarEventStatus.archived;
|
||||
default:
|
||||
throw StateError('Unsupported calendar event status: $raw');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user