Skip to content

Commit

Permalink
added removing of event color
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Wolf committed Jul 14, 2024
1 parent 634fd1b commit 7dce8d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
22 changes: 15 additions & 7 deletions example/lib/presentation/pages/calendar_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,10 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
final colors = _eventColors;
if (colors != null) {
final newColor = await selectColorDialog(colors);
if (newColor != null) {
setState(() {
_event?.updateEventColor(newColor);
});
}}
setState(() {
_event?.updateEventColor(newColor);
});
}
},
),
SwitchListTile(
Expand Down Expand Up @@ -1288,10 +1287,19 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
Future<EventColor?> selectColorDialog(List<EventColor> colors) async {
return await showDialog<EventColor>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return SimpleDialog(
title: const Text('Select Event color'),
children: colors.map((color) =>
children: [
SimpleDialogOption(
onPressed: () { Navigator.pop(context, null); },
child: const Padding(
padding: EdgeInsets.all(16.0),
child: Text('Reset', textAlign: TextAlign.center,),
),
),
...colors.map((color) =>
SimpleDialogOption(
onPressed: () { Navigator.pop(context, color); },
child: Container(
Expand All @@ -1302,7 +1310,7 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
color: Color(color.color)),
),
)
).toList()
)]
);
}
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/models/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ class Event {
}
}

void updateEventColor(EventColor eventColor) {
_color = eventColor.color;
_colorKey = eventColor.colorKey;
void updateEventColor(EventColor? eventColor) {
_color = eventColor?.color;
_colorKey = eventColor?.colorKey;
}
}

0 comments on commit 7dce8d1

Please sign in to comment.