Skip to content

Commit 9a19b47

Browse files
committed
notifications prettier
1 parent 9317baa commit 9a19b47

4 files changed

Lines changed: 110 additions & 15 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
library my_app.globals;
22

33
bool generated = false;
4-
int notificationId= 1;
4+
5+
int talkId = 0;

AgendappDEMO/lib/Model/Talk.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
55
import 'ThemeTalk.dart';
66

77
class Talk {
8+
int id; //eventually can be changed with id from the database
89
DateTime dateInitial;
910
DateTime dateFinal;
1011
String name;
@@ -15,7 +16,7 @@ class Talk {
1516
String location = "";
1617
List<ThemeTalk> themes = new List<ThemeTalk>();
1718

18-
Talk(this.dateInitial, this.dateFinal, this.name, this.information,
19+
Talk(this.id,this.dateInitial, this.dateFinal, this.name, this.information,
1920
this.location, this.selected, this.notify,this.speakers, this.themes);
2021

2122
void addSpeaker(String speaker){
@@ -30,4 +31,7 @@ class Talk {
3031
return themes[0].color;
3132
}
3233

34+
void turnOffNotification(){
35+
this.notify = false;
36+
}
3337
}

AgendappDEMO/lib/Notification/notification_page.dart

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class _NotificationPageState extends State<NotificationPage> {
2626
void initState(){
2727
super.initState();
2828
notificationFuture = _notificationPlugin.getScheduleNotifications();
29-
print(globals.generated);
3029
if(!globals.generated){
3130
generateAllNotifications();
3231
globals.generated=true;
@@ -81,6 +80,11 @@ class _NotificationPageState extends State<NotificationPage> {
8180
//erase notification
8281
Future<void> dismissNotification(int id)async{
8382
await _notificationPlugin.cancelNotifications(id);
83+
widget.talkList.forEach((element)=>{
84+
if(element.id == id){
85+
element.notify=false
86+
}
87+
});
8488
refreshNotification();
8589
}
8690
//refresh notification list
@@ -94,9 +98,8 @@ class _NotificationPageState extends State<NotificationPage> {
9498
Future<void> createTalkNotification(Time timeTalk,Day dayTalk,String titleTalk,String descriptionTalk) async{
9599

96100
final title = titleTalk;
97-
//final description = descriptionTalk; //it will make a sting with day and hour
98101
final time = timeTalk;
99-
final day = dayTalk; //todo to be used when i integrate weekly notification
102+
final day = dayTalk;
100103
final description = 'Day: Hour: ';
101104

102105

@@ -111,7 +114,7 @@ class _NotificationPageState extends State<NotificationPage> {
111114
id=i;
112115
}
113116
}
114-
await _notificationPlugin.showWeeklyAtDayTime( //todo change to weekly at time
117+
await _notificationPlugin.showWeeklyAtDayTime(
115118
notificationData.time,
116119
notificationData.day,
117120
id,
@@ -128,15 +131,95 @@ class _NotificationPageState extends State<NotificationPage> {
128131
int i=0;
129132
widget.talkList.forEach((element) =>({
130133
if(element.selected && element.notify){
131-
//todo convert time
132-
_notificationPlugin.showWeeklyAtDayTime(Time(element.dateInitial.hour, element.dateInitial.minute),Day(element.dateInitial.day),globals.notificationId++, element.name,
133-
("Date: " + element.dateInitial.month.toString() + "/" + element.dateInitial.day.toString() + " Hour: " + element.dateInitial.hour.toString() + ":" + element.dateInitial.minute.toString() ))
134+
//element.dateInitial.subtract(new Duration(minutes: 15)) //convert time //esta linguagem e so autista...
135+
_notificationPlugin.showWeeklyAtDayTime(Time(element.dateInitial.hour, element.dateInitial.minute),Day(element.dateInitial.day),element.id, element.name,
136+
(weakToString(element.dateInitial.weekday.toString()) +" "+ element.dateInitial.day.toString() + " " +monthToString(element.dateInitial.month.toString()) + " - " + hourToString(element.dateInitial.hour.toString()) + "h" + minToString(element.dateInitial.minute.toString()) ))
134137
}
135138
//createTalkNotification(Time(element.dateInitial.hour, element.dateInitial.minute), Day(element.dateInitial.day), element.name, element.information)
136139
}
137140
));
138141
}
142+
String hourToString(String hourNum){
143+
if(hourNum.length == 1)
144+
return '0'+ hourNum;
145+
return hourNum;
146+
147+
}
139148

149+
String minToString(String minNum){
150+
if(minNum.length == 1 )
151+
return '0'+minNum;
152+
return minNum;
153+
}
154+
155+
String weakToString(String weakNum){
156+
switch(weakNum){
157+
case "1":
158+
return "Sun";
159+
break;
160+
case "2":
161+
return "Mon";
162+
break;
163+
case "3":
164+
return "Tue";
165+
break;
166+
case "4":
167+
return "Wed";
168+
break;
169+
case "5":
170+
return "Thu";
171+
break;
172+
case "6":
173+
return "Fri";
174+
break;
175+
case "7":
176+
return "Sat";
177+
break;
178+
}
179+
return null;
180+
}
181+
182+
String monthToString(String monthNum){
183+
switch(monthNum){
184+
case "1":
185+
return "Jan";
186+
break;
187+
case "2":
188+
return "Fev";
189+
break;
190+
case "3":
191+
return "Mar";
192+
break;
193+
case "4":
194+
return "Apr";
195+
break;
196+
case "5":
197+
return "May";
198+
break;
199+
case "6":
200+
return "Jun";
201+
break;
202+
case "7":
203+
return "Jul";
204+
break;
205+
case "8":
206+
return "Aug";
207+
break;
208+
case "9":
209+
return "Sep";
210+
break;
211+
case "10":
212+
return "Oct";
213+
break;
214+
case "11":
215+
return "Nov";
216+
break;
217+
case "12":
218+
return "Dec";
219+
break;
220+
}
221+
return null;
222+
}
140223
}
141224

142225
class NotificationTile extends StatelessWidget{
@@ -152,6 +235,12 @@ class NotificationTile extends StatelessWidget{
152235
@override
153236
Widget build(BuildContext context){
154237
return Card(
238+
shape: StadiumBorder(
239+
side: BorderSide(
240+
color: Colors.black,
241+
width: 2.0,
242+
),
243+
),
155244
child: ListTile(
156245
title: Text(notification.title),
157246
subtitle: Text(notification.body),

AgendappDEMO/lib/Screens/MenuOpen.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flutter_login_page/Screens/Account_Screen/Account_Screen.dart';
66
import 'package:flutter_login_page/Screens/Schedule_Screen/schedule_screen.dart';
77
import 'package:flutter_login_page/Screens/All_Talks_Screen/AllTalks.dart';
88
import 'package:flutter_login_page/Screens/Schedule_List_Screen/home.dart';
9+
import 'package:flutter_login_page/Model/Globals.dart' as globals;
910

1011
final List<ThemeTalk> allThemes = [
1112
new ThemeTalk("Auto/Tech", Color(0xFF1E90FF)),
@@ -35,24 +36,24 @@ final List<ThemeTalk> interests = [allThemes[1], allThemes[2], allThemes[3]];
3536
final user = new User("Tiago Miller", "tigasmiller@gmail.com", allThemes, "https://yt3.ggpht.com/a/AGF-l791z2rgw2RhBFQ2vnnI3wuxwMdZSNXI3U1LgQ=s176-c-k-c0x00ffffff-no-rj-mo");
3637

3738
final List<Talk> _talkList = [
38-
new Talk(new DateTime(2019, 12, 8, 8, 0), new DateTime(2019, 12, 8, 9, 30), "Drones and food delivery: A marriage made in Heaven", "There are so many food delivery unicorns, but could getting your food delivery be bad for the planet?", "Room 101", false, false, [speakers[0], speakers[3]], [allThemes[0]]),
39-
new Talk(new DateTime(2019, 12, 8, 12, 0), new DateTime(2019, 12, 8, 13, 0),
39+
new Talk(globals.talkId++,new DateTime(2019, 12, 8, 8, 0), new DateTime(2019, 12, 8, 9, 30), "Drones and food delivery: A marriage made in Heaven", "There are so many food delivery unicorns, but could getting your food delivery be bad for the planet?", "Room 101", false, false, [speakers[0], speakers[3]], [allThemes[0]]),
40+
new Talk(globals.talkId++,new DateTime(2019, 12, 8, 12, 0), new DateTime(2019, 12, 8, 13, 0),
4041
"Breakout startups",
4142
"Are these the companies everyone will be talking about in 2020? Dozens of the world’s leading investors think so. Each morning and lunchtime on Centre Stage you’ll get an introduction to some of the world’s most exciting early and growth stage startups. Each of the startups have been hand-selected by some of the world’s most successful investors. You’re in for a treat.",
4243
"Room 102", true, true, [speakers[1]], [allThemes[1], allThemes[2], allThemes[3]]),
43-
new Talk(new DateTime(2019, 12, 8, 14, 0), new DateTime(2019, 12, 8, 15, 0),
44+
new Talk(globals.talkId++,new DateTime(2019, 12, 8, 14, 0), new DateTime(2019, 12, 8, 15, 0),
4445
"Building the next great ad empire",
4546
"One of the most prominent names in the advertising industry outlines his big vision for the industry.",
4647
"Room 103", false,false, [speakers[3], speakers[4]], allThemes),
47-
new Talk(new DateTime(2019, 12, 8, 16, 0), new DateTime(2019, 12, 8, 17, 0),
48+
new Talk(globals.talkId++,new DateTime(2019, 12, 8, 16, 0), new DateTime(2019, 12, 8, 17, 0),
4849
"Welcome to the future of mobile robots",
4950
"A pioneering company at the cutting edge of robotics showcases its vision for the future of robotic technology that interacts with the world.",
5051
"Room 104", false,false, [speakers[2]], [allThemes[2]]),
51-
new Talk(new DateTime(2019, 12, 10, 9, 0), new DateTime(2019, 12, 10, 10, 0),
52+
new Talk(globals.talkId++,new DateTime(2019, 12, 10, 9, 0), new DateTime(2019, 12, 10, 10, 0),
5253
"Predicting the future of brand design",
5354
"Despite cultural, political and technological change, one thing remains constant: Companies will keep trying to sell you stuff, and they’ll keep coming up with new ways to do it. Let's hear what the experts think of where the industry is going.",
5455
"Room 105", true,true,[speakers[3]], [allThemes[3]]),
55-
new Talk(new DateTime(2019, 12, 10, 16, 0), new DateTime(2019, 12, 10, 17, 30),
56+
new Talk(globals.talkId++,new DateTime(2019, 12, 10, 16, 0), new DateTime(2019, 12, 10, 17, 30),
5657
"Learn to win",
5758
"DJI presents a ground-breaking educational robot that helps to understand science, programming and more through captivating gameplay modes and intelligent features.",
5859
"Room 106", false,false, [speakers[0]], [allThemes[0]]),

0 commit comments

Comments
 (0)