Showing
5 changed files
with
653 additions
and
66 deletions
... | @@ -42,3 +42,6 @@ appbar 관련 디자인은 추후 구현 예정 | ... | @@ -42,3 +42,6 @@ appbar 관련 디자인은 추후 구현 예정 |
42 | + datetime picker widget을 이용하여 시간 선택 구현 예정 | 42 | + datetime picker widget을 이용하여 시간 선택 구현 예정 |
43 | + 알람 설정을 위한 Android Mainfest 설정 , 사용자 권한 요구 | 43 | + 알람 설정을 위한 Android Mainfest 설정 , 사용자 권한 요구 |
44 | 44 | ||
45 | +### 2021-05-14 | ||
46 | ++ datetime picker 를 이용하여 알람 설정 완료 | ||
47 | ++ 현재 알람 페이지와 알람 수정 페이지가 같은 곳에 위치 이에 따라 보이는 데이터만 존재하고 수정 여부를 묻는 것을 만들지 고민중 | ... | ... |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | -import 'package:flutter/services.dart'; | ||
3 | -import '../../shared/colors.dart'; | ||
4 | import 'package:rxdart/subjects.dart'; | 2 | import 'package:rxdart/subjects.dart'; |
5 | -import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | +import 'package:shared_preferences/shared_preferences.dart'; |
6 | -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | ||
7 | -import 'package:flutter_application_1/src/screens/SettingPage.dart'; | ||
8 | import 'package:flutter/cupertino.dart'; | 4 | import 'package:flutter/cupertino.dart'; |
9 | import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; | 5 | import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; |
6 | +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | ||
7 | +import 'package:flutter_application_1/src/screens/SettingPage.dart'; | ||
8 | +import 'package:flutter_application_1/src/screens/SettingPage/customTimepicker.dart'; | ||
10 | 9 | ||
11 | final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = | 10 | final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = |
12 | FlutterLocalNotificationsPlugin(); | 11 | FlutterLocalNotificationsPlugin(); |
... | @@ -41,9 +40,17 @@ class Alarm extends StatefulWidget { | ... | @@ -41,9 +40,17 @@ class Alarm extends StatefulWidget { |
41 | class _AlarmnState extends State<Alarm> { | 40 | class _AlarmnState extends State<Alarm> { |
42 | FlutterLocalNotificationsPlugin fltrNotification; | 41 | FlutterLocalNotificationsPlugin fltrNotification; |
43 | 42 | ||
43 | + List<Widget> alarmList = []; | ||
44 | + List<dynamic> weekdays = []; | ||
45 | + List<String> times = []; | ||
46 | + List<int> timesHours = []; | ||
47 | + List<int> timesMinutes = []; | ||
48 | + List<dynamic> saveIndex = []; | ||
49 | + List<dynamic> isSwitched = []; | ||
50 | + List<bool> _weekday = [false, false, false, false, false, false, false]; | ||
51 | + | ||
44 | void initState() { | 52 | void initState() { |
45 | super.initState(); | 53 | super.initState(); |
46 | - | ||
47 | main(); | 54 | main(); |
48 | } | 55 | } |
49 | 56 | ||
... | @@ -84,6 +91,44 @@ class _AlarmnState extends State<Alarm> { | ... | @@ -84,6 +91,44 @@ class _AlarmnState extends State<Alarm> { |
84 | ); | 91 | ); |
85 | } | 92 | } |
86 | 93 | ||
94 | + void insertAlarm() { | ||
95 | + setState(() { | ||
96 | + weekdays.add([false, false, false, false, false, false, false]); | ||
97 | + times.add(' '); | ||
98 | + timesHours.add(0); | ||
99 | + timesMinutes.add(0); | ||
100 | + isSwitched.add(false); | ||
101 | + | ||
102 | + var length = saveIndex.length; | ||
103 | + | ||
104 | + if (saveIndex.length == 0) { | ||
105 | + saveIndex.add(1); | ||
106 | + } else { | ||
107 | + saveIndex.add(saveIndex[length - 1] + 1); | ||
108 | + } | ||
109 | + | ||
110 | + length = saveIndex.length; | ||
111 | + /* | ||
112 | + _prefs.setString('alarmList', weekdays.toString()); | ||
113 | + for (var i = 0; i < times.length; i++) { | ||
114 | + _prefs.setString('time' + (saveIndex[i]).toString(), | ||
115 | + '${timesHours[i]}:${timesMinutes[i]}'); | ||
116 | + } | ||
117 | + _prefs.setString('timeIndex', saveIndex.toString()); | ||
118 | + _prefs.setString('toggle', isSwitched.toString()); | ||
119 | +*/ | ||
120 | + print(saveIndex); | ||
121 | + }); | ||
122 | + } | ||
123 | + | ||
124 | + void rerendering() { | ||
125 | + print(weekdays); | ||
126 | + print(times); | ||
127 | + print(timesHours); | ||
128 | + print(timesMinutes); | ||
129 | + setState(() {}); | ||
130 | + } | ||
131 | + | ||
87 | void _configureDidReceiveLocalNotificationSubject() { | 132 | void _configureDidReceiveLocalNotificationSubject() { |
88 | didReceiveLocalNotificationSubject.stream | 133 | didReceiveLocalNotificationSubject.stream |
89 | .listen((ReceivedNotification receivedNotification) async { | 134 | .listen((ReceivedNotification receivedNotification) async { |
... | @@ -189,79 +234,406 @@ class _AlarmnState extends State<Alarm> { | ... | @@ -189,79 +234,406 @@ class _AlarmnState extends State<Alarm> { |
189 | ], | 234 | ], |
190 | ), | 235 | ), |
191 | ), | 236 | ), |
192 | - body: FlatButton( | 237 | + body: SingleChildScrollView( |
193 | - height: size.height * 0.07, | 238 | + scrollDirection: Axis.vertical, |
194 | - onPressed: () { | 239 | + child: Padding( |
195 | - _showDailyAtTime(1, 2); | 240 | + padding: EdgeInsets.all(8.0), |
196 | - }, | 241 | + child: Column( |
197 | - child: Text( | 242 | + crossAxisAlignment: CrossAxisAlignment.center, |
198 | - '알람 설정', | 243 | + children: <Widget>[ |
199 | - textScaleFactor: 1.0, | 244 | + Row( |
200 | - style: TextStyle( | 245 | + mainAxisAlignment: MainAxisAlignment.center, |
201 | - color: Colors.white, | 246 | + children: <Widget>[ |
202 | - fontSize: 24, | 247 | + Container( |
203 | - fontFamily: 'Noto', | 248 | + width: 180, |
204 | - fontWeight: FontWeight.bold), | 249 | + height: 80, |
250 | + padding: const EdgeInsets.all(20.0), | ||
251 | + child: RaisedButton( | ||
252 | + onPressed: () async { | ||
253 | + insertAlarm(); | ||
254 | + }, | ||
255 | + shape: RoundedRectangleBorder( | ||
256 | + borderRadius: new BorderRadius.circular(30.0), | ||
257 | + side: BorderSide(color: Colors.blue)), | ||
258 | + color: Color(0xff1674f6), | ||
259 | + child: Text( | ||
260 | + '알람 추가', | ||
261 | + textScaleFactor: 1.0, | ||
262 | + style: TextStyle( | ||
263 | + fontSize: 16, | ||
264 | + color: Colors.white, | ||
265 | + fontWeight: FontWeight.bold), | ||
266 | + ), | ||
267 | + ), | ||
268 | + ), | ||
269 | + ], | ||
270 | + ), | ||
271 | + for (var i = 0; i < weekdays.length; i++) | ||
272 | + inAlarmData( | ||
273 | + context, | ||
274 | + weekdays, | ||
275 | + weekdays[i], | ||
276 | + _showWeeklyAtDayAndTime, | ||
277 | + times[i], | ||
278 | + timesHours[i], | ||
279 | + timesMinutes[i], | ||
280 | + i + 1, | ||
281 | + rerendering, | ||
282 | + size, | ||
283 | + ) | ||
284 | + ], | ||
285 | + ), | ||
205 | ), | 286 | ), |
206 | - color: Color(0xff8E97FD), | ||
207 | - shape: | ||
208 | - RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)), | ||
209 | ), | 287 | ), |
210 | ), | 288 | ), |
211 | ); | 289 | ); |
212 | } | 290 | } |
213 | 291 | ||
214 | - Future<void> _cancelNotification() async { | 292 | + Widget inAlarmData( |
215 | - await flutterLocalNotificationsPlugin.cancel(0); | 293 | + BuildContext context, |
216 | - } | 294 | + var allweekddata, |
217 | - | 295 | + var weekdayArray, |
218 | - Future<void> _showTimeoutNotification() async { | 296 | + var activeFunctions, |
219 | - var androidPlatformChannelSpecifics = AndroidNotificationDetails( | 297 | + var timeString, |
220 | - 'silent channel id', | 298 | + var timeHour, |
221 | - 'silent channel name', | 299 | + var timesMinite, |
222 | - 'silent channel description', | 300 | + var index, |
223 | - timeoutAfter: 3000, | 301 | + var rerendering, |
224 | - styleInformation: DefaultStyleInformation(true, true)); | 302 | + Size size, |
225 | - var iOSPlatformChannelSpecifics = | 303 | + ) { |
226 | - IOSNotificationDetails(presentSound: false); | 304 | + SharedPreferences _prefs; |
227 | - var platformChannelSpecifics = NotificationDetails( | 305 | + |
228 | - androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); | 306 | + var savetimeStrings; |
229 | - await flutterLocalNotificationsPlugin.show(0, 'timeout notification', | 307 | + var setDaysString = ['월', '화', '수', '목', '금', '토', '일']; |
230 | - 'Times out after 3 seconds', platformChannelSpecifics); | 308 | + |
231 | - } | 309 | + return Container( |
310 | + margin: EdgeInsets.fromLTRB(0, 0, 0, 20), | ||
311 | + decoration: BoxDecoration( | ||
312 | + border: Border.all( | ||
313 | + color: Color(0xffd0d0d0), | ||
314 | + ), | ||
315 | + borderRadius: BorderRadius.all(Radius.circular(5)), | ||
316 | + ), | ||
317 | + child: Column( | ||
318 | + children: <Widget>[ | ||
319 | + Container( | ||
320 | + alignment: Alignment.center, | ||
321 | + width: size.width, | ||
322 | + height: 50.0, | ||
323 | + child: Row( | ||
324 | + mainAxisAlignment: MainAxisAlignment.center, | ||
325 | + children: <Widget>[ | ||
326 | + Row( | ||
327 | + mainAxisAlignment: MainAxisAlignment.center, | ||
328 | + children: <Widget>[ | ||
329 | + for (var i = 0; i < weekdayArray.length; i++) | ||
330 | + GestureDetector( | ||
331 | + onTap: () async { | ||
332 | + _prefs = await SharedPreferences.getInstance(); | ||
333 | + | ||
334 | + if (weekdayArray[i] == false) { | ||
335 | + weekdayArray[i] = true; | ||
336 | + } else { | ||
337 | + weekdayArray[i] = false; | ||
338 | + } | ||
339 | + | ||
340 | + _prefs.setString( | ||
341 | + 'alarmList', allweekddata.toString()); | ||
342 | + | ||
343 | + rerendering(); | ||
344 | + }, | ||
345 | + child: Container( | ||
346 | + margin: EdgeInsets.fromLTRB(15, 0, 0, 0), | ||
347 | + width: size.width * 0.09, | ||
348 | + child: Text( | ||
349 | + setDaysString[i], | ||
350 | + style: TextStyle( | ||
351 | + color: weekdayArray[i] == false | ||
352 | + ? Colors.teal | ||
353 | + : Colors.red, | ||
354 | + fontWeight: FontWeight.bold, | ||
355 | + fontSize: 20.0), | ||
356 | + )), | ||
357 | + ), | ||
358 | + ], | ||
359 | + ) | ||
360 | + ], | ||
361 | + ), | ||
362 | + color: Colors.white, | ||
363 | + ), | ||
364 | + RaisedButton( | ||
365 | + shape: RoundedRectangleBorder( | ||
366 | + borderRadius: BorderRadius.circular(5.0)), | ||
367 | + elevation: 4.0, | ||
368 | + onPressed: () async { | ||
369 | + _prefs = await SharedPreferences.getInstance(); | ||
370 | + var abc = await DatePicker.showPicker( | ||
371 | + context, | ||
372 | + theme: DatePickerTheme( | ||
373 | + containerHeight: 210.0, | ||
374 | + ), | ||
375 | + showTitleActions: true, | ||
376 | + onConfirm: (time) { | ||
377 | + print('confirm $time'); | ||
378 | + | ||
379 | + // realTime = new DateTime(time.hour, time.minute); | ||
380 | + timeHour = time.hour; | ||
381 | + timesMinite = time.minute; | ||
382 | + | ||
383 | + savetimeStrings = '${time.hour}:${time.minute}'; | ||
384 | + | ||
385 | + var minutString; | ||
386 | + | ||
387 | + if (timesMinite.toString().length == 1) { | ||
388 | + minutString = '0' + timesMinite.toString(); | ||
389 | + } else { | ||
390 | + minutString = timesMinite.toString(); | ||
391 | + } | ||
392 | + | ||
393 | + if (timeHour - 12 < 0) { | ||
394 | + timeString = '오전 ${time.hour}:' + minutString; | ||
395 | + } else { | ||
396 | + if (timeHour == 12) { | ||
397 | + timeString = '오후 ${time.hour}:' + minutString; | ||
398 | + } else { | ||
399 | + timeString = '오후 ${time.hour - 12}:' + minutString; | ||
400 | + } | ||
401 | + } | ||
402 | + }, | ||
403 | + pickerModel: CustomPicker( | ||
404 | + currentTime: DateTime.now(), locale: LocaleType.ko), | ||
405 | + ); | ||
232 | 406 | ||
233 | - Future<void> _cancelAllNotifications() async { | 407 | + times[index - 1] = timeString; |
234 | - await flutterLocalNotificationsPlugin.cancelAll(); | 408 | + timesHours[index - 1] = timeHour; |
235 | - } | 409 | + timesMinutes[index - 1] = timesMinite; |
236 | 410 | ||
237 | - /// 매일 지정된 시간에 Alarm 을 트는 Function | 411 | + _prefs.setString('time' + (saveIndex[index - 1]).toString(), |
238 | - Future<void> _showDailyAtTime(int a, int b) async { | 412 | + savetimeStrings); |
239 | - var time = Time(11, 24, 0); | ||
240 | - var androidPlatformChannelSpecifics = AndroidNotificationDetails( | ||
241 | - 'repeatDailyAtTime channel id', | ||
242 | - 'repeatDailyAtTime channel name', | ||
243 | - 'repeatDailyAtTime description'); | ||
244 | - var iOSPlatformChannelSpecifics = IOSNotificationDetails(); | ||
245 | - var platformChannelSpecifics = NotificationDetails( | ||
246 | - androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); | ||
247 | - await flutterLocalNotificationsPlugin.showDailyAtTime( | ||
248 | - 1, | ||
249 | - '알람 시간 알림 ', | ||
250 | - '설정하신 시간인 ${_toTwoDigitString(time.hour)}시 ${_toTwoDigitString(time.minute)}분입니다.', | ||
251 | - time, | ||
252 | - platformChannelSpecifics); | ||
253 | 413 | ||
254 | - var pendingNotificationRequests = | 414 | + print(savetimeStrings); |
255 | - await flutterLocalNotificationsPlugin.pendingNotificationRequests(); | ||
256 | 415 | ||
257 | - print(pendingNotificationRequests.toList()); | 416 | + setState(() { |
417 | + savetimeStrings = savetimeStrings; | ||
418 | + }); | ||
419 | + // rerendering(); | ||
420 | + }, | ||
421 | + child: Container( | ||
422 | + alignment: Alignment.center, | ||
423 | + height: 50.0, | ||
424 | + child: Row( | ||
425 | + mainAxisAlignment: MainAxisAlignment.center, | ||
426 | + children: <Widget>[ | ||
427 | + Row( | ||
428 | + mainAxisAlignment: MainAxisAlignment.center, | ||
429 | + children: <Widget>[ | ||
430 | + Container( | ||
431 | + child: Row( | ||
432 | + mainAxisAlignment: MainAxisAlignment.center, | ||
433 | + children: <Widget>[ | ||
434 | + Icon( | ||
435 | + Icons.access_time, | ||
436 | + size: 18.0, | ||
437 | + color: Colors.teal, | ||
438 | + ), | ||
439 | + Text( | ||
440 | + " " + timeString, | ||
441 | + textAlign: TextAlign.center, | ||
442 | + style: TextStyle( | ||
443 | + color: Colors.teal, | ||
444 | + fontWeight: FontWeight.bold, | ||
445 | + fontSize: 18.0), | ||
446 | + ), | ||
447 | + ], | ||
448 | + ), | ||
449 | + ) | ||
450 | + ], | ||
451 | + ), | ||
452 | + ], | ||
453 | + ), | ||
454 | + ), | ||
455 | + color: Colors.white, | ||
456 | + ), | ||
457 | + Container( | ||
458 | + padding: EdgeInsets.fromLTRB(20, 0, 20, 0), | ||
459 | + decoration: BoxDecoration( | ||
460 | + borderRadius: BorderRadius.circular(5.0), | ||
461 | + color: Colors.white), | ||
462 | + child: Container( | ||
463 | + alignment: Alignment.center, | ||
464 | + height: 50.0, | ||
465 | + child: Row( | ||
466 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
467 | + children: <Widget>[ | ||
468 | + Text( | ||
469 | + "알람 설정", | ||
470 | + style: TextStyle( | ||
471 | + color: Colors.teal, | ||
472 | + fontWeight: FontWeight.bold, | ||
473 | + fontSize: 18.0), | ||
474 | + ), | ||
475 | + Switch( | ||
476 | + value: isSwitched[index - 1], | ||
477 | + onChanged: (value) async { | ||
478 | + print(savetimeStrings); | ||
479 | + if (value == true) { | ||
480 | + _prefs = await SharedPreferences.getInstance(); | ||
481 | + int count = 1; | ||
482 | + bool allDayFalse = true; | ||
483 | + for (var i = 0; i < weekdayArray.length; i++) { | ||
484 | + if (weekdayArray[i] == true) { | ||
485 | + await activeFunctions(timeHour, timesMinite, | ||
486 | + i + 1, index * 10, count); | ||
487 | + count++; | ||
488 | + allDayFalse = false; | ||
489 | + } | ||
490 | + } | ||
491 | + if (allDayFalse == true) { | ||
492 | + showDialog( | ||
493 | + context: context, | ||
494 | + builder: (BuildContext context) { | ||
495 | + return AlertDialog( | ||
496 | + title: new Text('요일 선택 오류'), | ||
497 | + content: | ||
498 | + new Text('선택된 요일이 없습니다. 요일을 선택해주세요.'), | ||
499 | + actions: <Widget>[ | ||
500 | + new FlatButton( | ||
501 | + child: new Text('닫기'), | ||
502 | + onPressed: () { | ||
503 | + Navigator.of(context).pop(); | ||
504 | + }) | ||
505 | + ], | ||
506 | + ); | ||
507 | + }); | ||
508 | + } else if (_prefs.getString('time' + | ||
509 | + (saveIndex[index - 1]).toString()) == | ||
510 | + null) { | ||
511 | + showDialog( | ||
512 | + context: context, | ||
513 | + builder: (BuildContext context) { | ||
514 | + return AlertDialog( | ||
515 | + title: new Text('시간 설정 오류'), | ||
516 | + content: | ||
517 | + new Text('설정된 시간이 없습니다. 시간을 설정해주세요.'), | ||
518 | + actions: <Widget>[ | ||
519 | + new FlatButton( | ||
520 | + child: new Text('닫기'), | ||
521 | + onPressed: () { | ||
522 | + Navigator.of(context).pop(); | ||
523 | + }) | ||
524 | + ], | ||
525 | + ); | ||
526 | + }); | ||
527 | + } else { | ||
528 | + setState(() { | ||
529 | + print(value); | ||
530 | + isSwitched[index - 1] = value; | ||
531 | + _prefs.setString( | ||
532 | + 'alarmList', allweekddata.toString()); | ||
533 | + // _prefs.setString( | ||
534 | + // 'time' + saveIndex[index - 1].toString(), | ||
535 | + // savetimeStrings); | ||
536 | + _prefs.setString( | ||
537 | + 'timeIndex', saveIndex.toString()); | ||
538 | + _prefs.setString( | ||
539 | + 'toggle', isSwitched.toString()); | ||
540 | + print('time' + index.toString()); | ||
541 | + showDialog( | ||
542 | + context: context, | ||
543 | + builder: (BuildContext context) { | ||
544 | + return AlertDialog( | ||
545 | + title: new Text('알람'), | ||
546 | + content: new Text('알람 설정을 완료 하였습니다.'), | ||
547 | + actions: <Widget>[ | ||
548 | + new FlatButton( | ||
549 | + child: new Text('확인'), | ||
550 | + onPressed: () { | ||
551 | + Navigator.of(context).pop(); | ||
552 | + }) | ||
553 | + ], | ||
554 | + ); | ||
555 | + }); | ||
556 | + }); | ||
557 | + } | ||
558 | + } else { | ||
559 | + _prefs = await SharedPreferences.getInstance(); | ||
560 | + int count = 1; | ||
561 | + for (var i = 0; i < weekdayArray.length; i++) { | ||
562 | + if (weekdayArray[i] == true) { | ||
563 | + await flutterLocalNotificationsPlugin | ||
564 | + .cancel((index * 10) + count); | ||
565 | + count++; | ||
566 | + } | ||
567 | + } | ||
568 | + setState(() { | ||
569 | + isSwitched[index - 1] = value; | ||
570 | + _prefs.setString('toggle', isSwitched.toString()); | ||
571 | + }); | ||
572 | + } | ||
573 | + }), | ||
574 | + GestureDetector( | ||
575 | + onTap: () async { | ||
576 | + showDialog( | ||
577 | + context: context, | ||
578 | + builder: (BuildContext context) { | ||
579 | + return AlertDialog( | ||
580 | + title: new Text('알람 삭제'), | ||
581 | + content: new Text('선택한 알람을 삭제하시겠습니까?'), | ||
582 | + actions: <Widget>[ | ||
583 | + new FlatButton( | ||
584 | + child: new Text('취소'), | ||
585 | + onPressed: () { | ||
586 | + Navigator.of(context).pop(); | ||
587 | + }), | ||
588 | + new FlatButton( | ||
589 | + child: new Text('삭제'), | ||
590 | + onPressed: () async { | ||
591 | + _prefs = await SharedPreferences | ||
592 | + .getInstance(); | ||
593 | + int count = 1; | ||
594 | + for (var i = 0; | ||
595 | + i < weekdayArray.length; | ||
596 | + i++) { | ||
597 | + if (weekdayArray[i] == true) { | ||
598 | + await flutterLocalNotificationsPlugin | ||
599 | + .cancel((index * 10) + count); | ||
600 | + count++; | ||
601 | + } | ||
602 | + } | ||
603 | + print(saveIndex); | ||
604 | + allweekddata.removeAt(index - 1); | ||
605 | + _prefs.remove('time' + | ||
606 | + saveIndex[index - 1].toString()); | ||
607 | + times.removeAt(index - 1); | ||
608 | + saveIndex.removeAt(index - 1); | ||
609 | + isSwitched.removeAt(index - 1); | ||
610 | + _prefs.setString('alarmList', | ||
611 | + allweekddata.toString()); | ||
612 | + _prefs.setString('timeIndex', | ||
613 | + saveIndex.toString()); | ||
614 | + _prefs.setString( | ||
615 | + 'toggle', isSwitched.toString()); | ||
616 | + rerendering(); | ||
617 | + Navigator.of(context).pop(); | ||
618 | + }) | ||
619 | + ], | ||
620 | + ); | ||
621 | + }); | ||
622 | + }, | ||
623 | + child: Icon( | ||
624 | + Icons.close, | ||
625 | + )) | ||
626 | + ], | ||
627 | + ), | ||
628 | + ), | ||
629 | + ), | ||
630 | + ], | ||
631 | + )); | ||
258 | } | 632 | } |
259 | 633 | ||
260 | /// weekday 가 1부터 7순으로 일 월 화 수 목 금 토 일 순서로 구성이 되어 있음 이에 따라 설정한 Weekday time 에 학습 알람을 뛰어주는 역할을 해주는 함수 | 634 | /// weekday 가 1부터 7순으로 일 월 화 수 목 금 토 일 순서로 구성이 되어 있음 이에 따라 설정한 Weekday time 에 학습 알람을 뛰어주는 역할을 해주는 함수 |
261 | Future<void> _showWeeklyAtDayAndTime( | 635 | Future<void> _showWeeklyAtDayAndTime( |
262 | int a, int b, int weekday, int index, int idindex) async { | 636 | int a, int b, int weekday, int index, int idindex) async { |
263 | - print(index + idindex); | ||
264 | - | ||
265 | Day setDay; | 637 | Day setDay; |
266 | 638 | ||
267 | if (weekday == 1) { | 639 | if (weekday == 1) { |
... | @@ -279,6 +651,7 @@ class _AlarmnState extends State<Alarm> { | ... | @@ -279,6 +651,7 @@ class _AlarmnState extends State<Alarm> { |
279 | } else if (weekday == 7) { | 651 | } else if (weekday == 7) { |
280 | setDay = Day.Sunday; | 652 | setDay = Day.Sunday; |
281 | } | 653 | } |
654 | + print('dd'); | ||
282 | 655 | ||
283 | var time = Time(a, b, 0); | 656 | var time = Time(a, b, 0); |
284 | var androidPlatformChannelSpecifics = AndroidNotificationDetails( | 657 | var androidPlatformChannelSpecifics = AndroidNotificationDetails( | ... | ... |
1 | +import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; | ||
2 | + | ||
3 | +class CustomPicker extends CommonPickerModel { | ||
4 | + var indexs; | ||
5 | + | ||
6 | + String digits(int value, int length) { | ||
7 | + return '$value'.padLeft(length, "0"); | ||
8 | + } | ||
9 | + | ||
10 | + CustomPicker({DateTime currentTime, LocaleType locale}) | ||
11 | + : super(locale: LocaleType.ko) { | ||
12 | + this.currentTime = currentTime ?? DateTime.now(); | ||
13 | + var _dayPeriod = 0; | ||
14 | + this.setLeftIndex(this.currentTime.hour); | ||
15 | + this.setMiddleIndex(this.currentTime.minute); | ||
16 | + this.setRightIndex(_dayPeriod); | ||
17 | + _fillRightList(); | ||
18 | + } | ||
19 | + | ||
20 | + @override | ||
21 | + String leftStringAtIndex(int index) { | ||
22 | + if (index >= 1 && index < 13) { | ||
23 | + return this.digits(index, 2); | ||
24 | + } else { | ||
25 | + return null; | ||
26 | + } | ||
27 | + } | ||
28 | + | ||
29 | + @override | ||
30 | + String middleStringAtIndex(int index) { | ||
31 | + if (index >= 0 && index < 60) { | ||
32 | + return this.digits(index, 2); | ||
33 | + } else { | ||
34 | + return null; | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + @override | ||
39 | + String rightStringAtIndex(int index) { | ||
40 | + if (index == 0) { | ||
41 | + return 'AM'; | ||
42 | + } else if (index == 1) { | ||
43 | + return 'PM'; | ||
44 | + } | ||
45 | + return null; | ||
46 | + } | ||
47 | + | ||
48 | + void _fillRightList() { | ||
49 | + this.rightList = List.generate(2, (int index) { | ||
50 | + return '$index'; | ||
51 | + }); | ||
52 | + } | ||
53 | + | ||
54 | + @override | ||
55 | + void setRightIndex(int index) { | ||
56 | + super.setRightIndex(index); | ||
57 | + indexs = index; | ||
58 | + _fillRightList(); | ||
59 | + } | ||
60 | + | ||
61 | + @override | ||
62 | + String leftDivider() { | ||
63 | + return ":"; | ||
64 | + } | ||
65 | + | ||
66 | + @override | ||
67 | + String rightDivider() { | ||
68 | + return " "; | ||
69 | + } | ||
70 | + | ||
71 | + @override | ||
72 | + List<int> layoutProportions() { | ||
73 | + return [1, 1, 1]; | ||
74 | + } | ||
75 | + | ||
76 | + @override | ||
77 | + DateTime finalTime() { | ||
78 | + var leftindex; | ||
79 | + | ||
80 | + print(indexs); | ||
81 | + | ||
82 | + if (indexs == 1) { | ||
83 | + if(this.currentLeftIndex() == 12){ | ||
84 | + leftindex = 12; | ||
85 | + } else { | ||
86 | + leftindex = this.currentLeftIndex() + 12; | ||
87 | + } | ||
88 | + | ||
89 | + | ||
90 | + } else if (indexs == 0) { | ||
91 | + if(this.currentLeftIndex() == 12){ | ||
92 | + leftindex = 0; | ||
93 | + } else { | ||
94 | + leftindex = this.currentLeftIndex(); | ||
95 | + } | ||
96 | + | ||
97 | + | ||
98 | + } | ||
99 | + | ||
100 | + return currentTime.isUtc | ||
101 | + ? DateTime.utc(currentTime.year, currentTime.month, currentTime.day, | ||
102 | + leftindex, this.currentMiddleIndex(), this.currentRightIndex()) | ||
103 | + : DateTime(currentTime.year, currentTime.month, currentTime.day, | ||
104 | + leftindex, this.currentMiddleIndex(), this.currentRightIndex()); | ||
105 | + } | ||
106 | +} |
... | @@ -50,6 +50,20 @@ packages: | ... | @@ -50,6 +50,20 @@ packages: |
50 | url: "https://pub.dartlang.org" | 50 | url: "https://pub.dartlang.org" |
51 | source: hosted | 51 | source: hosted |
52 | version: "1.2.0-nullsafety.1" | 52 | version: "1.2.0-nullsafety.1" |
53 | + ffi: | ||
54 | + dependency: transitive | ||
55 | + description: | ||
56 | + name: ffi | ||
57 | + url: "https://pub.dartlang.org" | ||
58 | + source: hosted | ||
59 | + version: "0.1.3" | ||
60 | + file: | ||
61 | + dependency: transitive | ||
62 | + description: | ||
63 | + name: file | ||
64 | + url: "https://pub.dartlang.org" | ||
65 | + source: hosted | ||
66 | + version: "5.2.1" | ||
53 | flutter: | 67 | flutter: |
54 | dependency: "direct main" | 68 | dependency: "direct main" |
55 | description: flutter | 69 | description: flutter |
... | @@ -88,8 +102,13 @@ packages: | ... | @@ -88,8 +102,13 @@ packages: |
88 | description: flutter | 102 | description: flutter |
89 | source: sdk | 103 | source: sdk |
90 | version: "0.0.0" | 104 | version: "0.0.0" |
91 | - intl: | 105 | + flutter_web_plugins: |
92 | dependency: transitive | 106 | dependency: transitive |
107 | + description: flutter | ||
108 | + source: sdk | ||
109 | + version: "0.0.0" | ||
110 | + intl: | ||
111 | + dependency: "direct main" | ||
93 | description: | 112 | description: |
94 | name: intl | 113 | name: intl |
95 | url: "https://pub.dartlang.org" | 114 | url: "https://pub.dartlang.org" |
... | @@ -144,6 +163,27 @@ packages: | ... | @@ -144,6 +163,27 @@ packages: |
144 | url: "https://pub.dartlang.org" | 163 | url: "https://pub.dartlang.org" |
145 | source: hosted | 164 | source: hosted |
146 | version: "1.8.0-nullsafety.1" | 165 | version: "1.8.0-nullsafety.1" |
166 | + path_provider_linux: | ||
167 | + dependency: transitive | ||
168 | + description: | ||
169 | + name: path_provider_linux | ||
170 | + url: "https://pub.dartlang.org" | ||
171 | + source: hosted | ||
172 | + version: "0.0.1+2" | ||
173 | + path_provider_platform_interface: | ||
174 | + dependency: transitive | ||
175 | + description: | ||
176 | + name: path_provider_platform_interface | ||
177 | + url: "https://pub.dartlang.org" | ||
178 | + source: hosted | ||
179 | + version: "1.0.4" | ||
180 | + path_provider_windows: | ||
181 | + dependency: transitive | ||
182 | + description: | ||
183 | + name: path_provider_windows | ||
184 | + url: "https://pub.dartlang.org" | ||
185 | + source: hosted | ||
186 | + version: "0.0.4+3" | ||
147 | pedantic: | 187 | pedantic: |
148 | dependency: transitive | 188 | dependency: transitive |
149 | description: | 189 | description: |
... | @@ -165,6 +205,13 @@ packages: | ... | @@ -165,6 +205,13 @@ packages: |
165 | url: "https://pub.dartlang.org" | 205 | url: "https://pub.dartlang.org" |
166 | source: hosted | 206 | source: hosted |
167 | version: "1.0.3" | 207 | version: "1.0.3" |
208 | + process: | ||
209 | + dependency: transitive | ||
210 | + description: | ||
211 | + name: process | ||
212 | + url: "https://pub.dartlang.org" | ||
213 | + source: hosted | ||
214 | + version: "3.0.13" | ||
168 | rxdart: | 215 | rxdart: |
169 | dependency: "direct main" | 216 | dependency: "direct main" |
170 | description: | 217 | description: |
... | @@ -172,6 +219,48 @@ packages: | ... | @@ -172,6 +219,48 @@ packages: |
172 | url: "https://pub.dartlang.org" | 219 | url: "https://pub.dartlang.org" |
173 | source: hosted | 220 | source: hosted |
174 | version: "0.23.1" | 221 | version: "0.23.1" |
222 | + shared_preferences: | ||
223 | + dependency: "direct main" | ||
224 | + description: | ||
225 | + name: shared_preferences | ||
226 | + url: "https://pub.dartlang.org" | ||
227 | + source: hosted | ||
228 | + version: "0.5.12+4" | ||
229 | + shared_preferences_linux: | ||
230 | + dependency: transitive | ||
231 | + description: | ||
232 | + name: shared_preferences_linux | ||
233 | + url: "https://pub.dartlang.org" | ||
234 | + source: hosted | ||
235 | + version: "0.0.2+4" | ||
236 | + shared_preferences_macos: | ||
237 | + dependency: transitive | ||
238 | + description: | ||
239 | + name: shared_preferences_macos | ||
240 | + url: "https://pub.dartlang.org" | ||
241 | + source: hosted | ||
242 | + version: "0.0.1+11" | ||
243 | + shared_preferences_platform_interface: | ||
244 | + dependency: transitive | ||
245 | + description: | ||
246 | + name: shared_preferences_platform_interface | ||
247 | + url: "https://pub.dartlang.org" | ||
248 | + source: hosted | ||
249 | + version: "1.0.4" | ||
250 | + shared_preferences_web: | ||
251 | + dependency: transitive | ||
252 | + description: | ||
253 | + name: shared_preferences_web | ||
254 | + url: "https://pub.dartlang.org" | ||
255 | + source: hosted | ||
256 | + version: "0.1.2+7" | ||
257 | + shared_preferences_windows: | ||
258 | + dependency: transitive | ||
259 | + description: | ||
260 | + name: shared_preferences_windows | ||
261 | + url: "https://pub.dartlang.org" | ||
262 | + source: hosted | ||
263 | + version: "0.0.2+3" | ||
175 | sky_engine: | 264 | sky_engine: |
176 | dependency: transitive | 265 | dependency: transitive |
177 | description: flutter | 266 | description: flutter |
... | @@ -240,6 +329,20 @@ packages: | ... | @@ -240,6 +329,20 @@ packages: |
240 | url: "https://pub.dartlang.org" | 329 | url: "https://pub.dartlang.org" |
241 | source: hosted | 330 | source: hosted |
242 | version: "2.1.0-nullsafety.3" | 331 | version: "2.1.0-nullsafety.3" |
332 | + win32: | ||
333 | + dependency: transitive | ||
334 | + description: | ||
335 | + name: win32 | ||
336 | + url: "https://pub.dartlang.org" | ||
337 | + source: hosted | ||
338 | + version: "1.7.4+1" | ||
339 | + xdg_directories: | ||
340 | + dependency: transitive | ||
341 | + description: | ||
342 | + name: xdg_directories | ||
343 | + url: "https://pub.dartlang.org" | ||
344 | + source: hosted | ||
345 | + version: "0.1.2" | ||
243 | sdks: | 346 | sdks: |
244 | dart: ">=2.10.0-110 <2.11.0" | 347 | dart: ">=2.10.0-110 <2.11.0" |
245 | - flutter: ">=1.12.13+hotfix.5" | 348 | + flutter: ">=1.12.13+hotfix.5 <2.0.0" | ... | ... |
... | @@ -31,6 +31,8 @@ dependencies: | ... | @@ -31,6 +31,8 @@ dependencies: |
31 | rxdart: ^0.23.1 | 31 | rxdart: ^0.23.1 |
32 | flutter_datetime_picker: ^1.3.4 | 32 | flutter_datetime_picker: ^1.3.4 |
33 | timezone: ^0.6.0 | 33 | timezone: ^0.6.0 |
34 | + intl : ^0.16.1 | ||
35 | + shared_preferences: ^0.5.6+1 | ||
34 | 36 | ||
35 | dev_dependencies: | 37 | dev_dependencies: |
36 | flutter_test: | 38 | flutter_test: | ... | ... |
-
Please register or login to post a comment