44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'event.dart';
|
|
|
|
void showAddEventDialog(
|
|
BuildContext context, List<Event> events, DateTime selectedDay) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text('Add Event'),
|
|
content: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
TextFormField(
|
|
decoration: InputDecoration(labelText: 'Event Name'),
|
|
onSaved: (value) {
|
|
if (value != null && value.isNotEmpty) {
|
|
events.add(Event(date: selectedDay, name: value));
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text('Cancel'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text('Save'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|