diff --git a/lib/model/entities/event.dart b/lib/model/entities/event.dart index e23f719..fe27cb3 100644 --- a/lib/model/entities/event.dart +++ b/lib/model/entities/event.dart @@ -55,4 +55,8 @@ class Event { void setTitle(String title) { this.title = title; } + + void setDescription(String title) { + this.description; + } } diff --git a/lib/view/Pages/calendar_page_view.dart b/lib/view/Pages/calendar_page_view.dart index 6ffe113..0c3c680 100644 --- a/lib/view/Pages/calendar_page_view.dart +++ b/lib/view/Pages/calendar_page_view.dart @@ -27,6 +27,7 @@ List getExams(store) { List getDeliveries(store) { final deliveries = [ Delivery('DA', DateTime(2022, 6, 6, 23, 59), 'Projeto'), + Delivery('ESOF', DateTime(2022, 6, 10, 10, 45), 'ApresentaĆ§Ć£o'), Delivery('LCOM', DateTime(2022, 6, 13, 12, 00), 'Projeto'), Delivery('LTW', DateTime(2022, 6, 14, 23, 59), 'Projeto'), ]; @@ -36,9 +37,7 @@ List getDeliveries(store) { List getPersonalEvents(store) { final personalEvents = []; - // to do - return personalEvents; } diff --git a/lib/view/Widgets/add_event.dart b/lib/view/Widgets/add_event.dart index 40b47b4..8f6c53d 100644 --- a/lib/view/Widgets/add_event.dart +++ b/lib/view/Widgets/add_event.dart @@ -2,25 +2,15 @@ import 'package:flutter/material.dart'; import 'package:uni/model/entities/event.dart'; import 'package:intl/intl.dart'; -class AddEvent extends StatefulWidget { +class AddEvent extends StatelessWidget { final DateTime selectedDay; AddEvent({Key key, @required this.selectedDay}) : super(key: key); - @override - State createState() => AddEventWidget(); -} - -class AddEventWidget extends State { final _formKey = GlobalKey(); - TextEditingController textFieldController = TextEditingController(); - - @override - void dispose() { - textFieldController.dispose(); - super.dispose(); - } + TextEditingController nameFieldController = TextEditingController(); + TextEditingController timeFieldController = TextEditingController(); @override Widget build(BuildContext context) { @@ -43,22 +33,42 @@ class AddEventWidget extends State { Container( margin: const EdgeInsets.symmetric( horizontal: 20.0, - vertical: 4.0, + vertical: 15.0, ), child: TextFormField( - controller: textFieldController, + controller: nameFieldController, decoration: const InputDecoration( icon: const Icon(Icons.calendar_today), - hintText: 'Enter a name for the new event', + hintText: 'Give your new event a name', labelText: 'Name', ), - onSaved: (val) => textFieldController.text = val.toString(), + onSaved: (name) => nameFieldController.text = name.toString(), + ), + ), + Container( + margin: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 15.0, + ), + child: TextFormField( + controller: timeFieldController, + decoration: const InputDecoration( + icon: const Icon(Icons.access_time), + hintText: 'Enter an hour (HH:mm)', + labelText: 'Hour', + ), + onSaved: (time) { + if (timeFieldController.text.isNotEmpty && + timeFieldController.text.length == 5) { + timeFieldController.text = time.toString(); + } + }, ), ), Container( margin: const EdgeInsets.symmetric( horizontal: 12.0, - vertical: 13.0, + vertical: 35.0, ), child: FloatingActionButton.extended( label: Text( @@ -68,9 +78,22 @@ class AddEventWidget extends State { icon: Icon(Icons.check_rounded, color: Colors.white), backgroundColor: Colors.grey[900], onPressed: () { - String title = textFieldController.text; + /* + String name = nameFieldController.text; + DateTime time = DateTime(2022); + if (timeFieldController.text.isNotEmpty) { + int y = selectedDay.year; + int m = selectedDay.month; + int d = selectedDay.day; + int h = int.parse(timeFieldController.text.substring(0, 2)); + int min = + int.parse(timeFieldController.text.substring(3, 5)); + time = DateTime(y, m, d, h, m); + } + Navigator.pop(context, Event(name, time)); + */ Navigator.pop( - context, Event(title, DateTime(2022, 6, 11, 12, 00))); + context, Event('Lembrete (Estudo)', selectedDay)); }, ), ), diff --git a/lib/view/Widgets/calendar.dart b/lib/view/Widgets/calendar.dart index b2cf0c7..6591d18 100644 --- a/lib/view/Widgets/calendar.dart +++ b/lib/view/Widgets/calendar.dart @@ -10,7 +10,9 @@ class Calendar extends StatefulWidget { Calendar({Key key, @required this.events}) : super(key: key); @override - State createState() => CalendarWidget(); + State createState() { + return CalendarWidget(); + } } class CalendarWidget extends State { @@ -40,7 +42,7 @@ class CalendarWidget extends State { ), ), centerTitle: true, - backgroundColor: Colors.red[900], + backgroundColor: Color.fromARGB(255, 0x75, 0x17, 0x1e), automaticallyImplyLeading: false, ), body: Column( @@ -78,11 +80,11 @@ class CalendarWidget extends State { isTodayHighlighted: true, defaultTextStyle: const TextStyle(color: Colors.black), selectedDecoration: BoxDecoration( - color: Colors.red[900], + color: Color.fromARGB(255, 0x75, 0x17, 0x1e), shape: BoxShape.circle, ), todayDecoration: const BoxDecoration( - color: Colors.red, + color: Color.fromARGB(255, 190, 40, 40), shape: BoxShape.circle, )), headerStyle: const HeaderStyle( @@ -113,11 +115,11 @@ class CalendarWidget extends State { ); if (event.getTitle() != '') { widget.events.add(event); + setState(() { + _selectedEvents = + ValueNotifier(_getEventsForDay(_selectedDay)); + }); } - setState(() { - _selectedEvents = - ValueNotifier(_getEventsForDay(_selectedDay)); - }); }, ), ), @@ -135,17 +137,27 @@ class CalendarWidget extends State { vertical: 4.0, ), decoration: BoxDecoration( - border: Border.all(), - borderRadius: BorderRadius.circular(12.0), - color: Colors.red[700], - ), + border: Border.all(), + borderRadius: BorderRadius.circular(12.0), + color: Color.fromARGB(255, 190, 40, 40)), child: ListTile( - title: Text( - value[index].title, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - ), + textColor: Colors.white, + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + value[index].title, + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + Text( + value[index].description, + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ], ), ), );