diff options
Diffstat (limited to 'lib/screens/events_screen.dart')
-rw-r--r-- | lib/screens/events_screen.dart | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/lib/screens/events_screen.dart b/lib/screens/events_screen.dart index 60d1b26..0b78fbe 100644 --- a/lib/screens/events_screen.dart +++ b/lib/screens/events_screen.dart @@ -1,6 +1,10 @@ import 'package:flutter/material.dart'; import 'package:table_calendar/table_calendar.dart'; +import '../widgets/event_list.dart'; + +enum Vista { calendario, lista } + class EventsScreen extends StatefulWidget { const EventsScreen({super.key}); @@ -9,6 +13,7 @@ class EventsScreen extends StatefulWidget { } class _EventsScreenState extends State<EventsScreen> { + Vista vista = Vista.calendario; DateTime _selectedDay = DateTime.now(); DateTime _focusedDay = DateTime.now(); CalendarFormat _calendarFormat = CalendarFormat.month; @@ -18,29 +23,51 @@ class _EventsScreenState extends State<EventsScreen> { return Scaffold( appBar: AppBar( title: const Text('Eventos'), - actions: const [], + actions: [ + SegmentedButton<Vista>( + showSelectedIcon: false, + segments: const [ + ButtonSegment<Vista>( + value: Vista.calendario, + icon: Icon(Icons.calendar_month), + ), + ButtonSegment<Vista>( + value: Vista.lista, + icon: Icon(Icons.list), + ), + ], + selected: <Vista>{vista}, + onSelectionChanged: (p0) { + setState(() { + vista = p0.first; + }); + }, + ) + ], ), body: Container( - child: TableCalendar( - firstDay: DateTime.fromMicrosecondsSinceEpoch(0), - lastDay: DateTime.utc(9000, 12, 31), - focusedDay: _focusedDay, - selectedDayPredicate: (day) { - return isSameDay(_selectedDay, day); - }, - onDaySelected: (selectedDay, focusedDay) { - setState(() { - _selectedDay = selectedDay; - _focusedDay = focusedDay; - }); - }, - calendarFormat: _calendarFormat, - onFormatChanged: (format) { - setState(() { - _calendarFormat = format; - }); - }, - )), + child: vista == Vista.calendario + ? TableCalendar( + firstDay: DateTime.fromMicrosecondsSinceEpoch(0), + lastDay: DateTime.utc(9000, 12, 31), + focusedDay: _focusedDay, + selectedDayPredicate: (day) { + return isSameDay(_selectedDay, day); + }, + onDaySelected: (selectedDay, focusedDay) { + setState(() { + _selectedDay = selectedDay; + _focusedDay = focusedDay; + }); + }, + calendarFormat: _calendarFormat, + onFormatChanged: (format) { + setState(() { + _calendarFormat = format; + }); + }, + ) + : const EventList()), floatingActionButton: FloatingActionButton.extended( label: const Text('Nuevo'), icon: const Icon(Icons.add), |