Skip to content

Commit

Permalink
Code finished
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSilva11 committed Jun 10, 2022
1 parent 32294f0 commit 0ec29c6
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 40 deletions.
4 changes: 4 additions & 0 deletions lib/model/entities/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ class Event {
void setTitle(String title) {
this.title = title;
}

void setDescription(String title) {
this.description;
}
}
3 changes: 1 addition & 2 deletions lib/view/Pages/calendar_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ List<Exam> getExams(store) {
List<Delivery> getDeliveries(store) {
final deliveries = <Delivery>[
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'),
];
Expand All @@ -36,9 +37,7 @@ List<Delivery> getDeliveries(store) {

List<Event> getPersonalEvents(store) {
final personalEvents = <Event>[];

// to do

return personalEvents;
}

Expand Down
63 changes: 43 additions & 20 deletions lib/view/Widgets/add_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<AddEvent> createState() => AddEventWidget();
}

class AddEventWidget extends State<AddEvent> {
final _formKey = GlobalKey<FormState>();

TextEditingController textFieldController = TextEditingController();

@override
void dispose() {
textFieldController.dispose();
super.dispose();
}
TextEditingController nameFieldController = TextEditingController();
TextEditingController timeFieldController = TextEditingController();

@override
Widget build(BuildContext context) {
Expand All @@ -43,22 +33,42 @@ class AddEventWidget extends State<AddEvent> {
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(
Expand All @@ -68,9 +78,22 @@ class AddEventWidget extends State<AddEvent> {
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));
},
),
),
Expand Down
48 changes: 30 additions & 18 deletions lib/view/Widgets/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Calendar extends StatefulWidget {
Calendar({Key key, @required this.events}) : super(key: key);

@override
State<Calendar> createState() => CalendarWidget();
State<StatefulWidget> createState() {
return CalendarWidget();
}
}

class CalendarWidget extends State<Calendar> {
Expand Down Expand Up @@ -40,7 +42,7 @@ class CalendarWidget extends State<Calendar> {
),
),
centerTitle: true,
backgroundColor: Colors.red[900],
backgroundColor: Color.fromARGB(255, 0x75, 0x17, 0x1e),
automaticallyImplyLeading: false,
),
body: Column(
Expand Down Expand Up @@ -78,11 +80,11 @@ class CalendarWidget extends State<Calendar> {
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(
Expand Down Expand Up @@ -113,11 +115,11 @@ class CalendarWidget extends State<Calendar> {
);
if (event.getTitle() != '') {
widget.events.add(event);
setState(() {
_selectedEvents =
ValueNotifier(_getEventsForDay(_selectedDay));
});
}
setState(() {
_selectedEvents =
ValueNotifier(_getEventsForDay(_selectedDay));
});
},
),
),
Expand All @@ -135,17 +137,27 @@ class CalendarWidget extends State<Calendar> {
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,
),
),
],
),
),
);
Expand Down

0 comments on commit 0ec29c6

Please sign in to comment.