|
|
|
@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
@ -22,15 +23,7 @@ class ReminderPage extends StatefulWidget {
|
|
|
|
|
final String itemDescription;
|
|
|
|
|
|
|
|
|
|
List<DateTime> _scheduleList = List();
|
|
|
|
|
List<DayOfWeek> daysOfWeek = [
|
|
|
|
|
DayOfWeek.Monday,
|
|
|
|
|
DayOfWeek.Tuesday,
|
|
|
|
|
DayOfWeek.Wednesday,
|
|
|
|
|
DayOfWeek.Thursday,
|
|
|
|
|
DayOfWeek.Friday,
|
|
|
|
|
DayOfWeek.Saturday,
|
|
|
|
|
DayOfWeek.Sunday
|
|
|
|
|
];
|
|
|
|
|
List<DayOfWeek> daysOfWeek = [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday];
|
|
|
|
|
|
|
|
|
|
DateTime startDay;
|
|
|
|
|
DateTime endDay;
|
|
|
|
@ -41,8 +34,7 @@ class ReminderPage extends StatefulWidget {
|
|
|
|
|
int hour = (24 ~/ frequency).round();
|
|
|
|
|
int durations = 24 ~/ hour;
|
|
|
|
|
for (int count = 0; count < durations; count++) {
|
|
|
|
|
_scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month,
|
|
|
|
|
DateTime.now().day, (hour * count)));
|
|
|
|
|
_scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, (hour * count)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -59,6 +51,9 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
isShowDecPage: false,
|
|
|
|
|
appBarTitle: TranslationBase.of(context).reminder,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
@ -68,7 +63,7 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: double.maxFinite,
|
|
|
|
|
child: Texts(TranslationBase.of(context).reminderDes),
|
|
|
|
|
child: Texts(TranslationBase.of(context).reminderDes, textAlign: TextAlign.start),
|
|
|
|
|
),
|
|
|
|
|
Divider(),
|
|
|
|
|
SizedBox(
|
|
|
|
@ -80,25 +75,17 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
DatePicker.showDatePicker(context,
|
|
|
|
|
showTitleActions: true,
|
|
|
|
|
minTime: DateTime(
|
|
|
|
|
DateTime.now().year, DateTime.now().month - 1, 1),
|
|
|
|
|
maxTime: DateTime.now(), onConfirm: (date) {
|
|
|
|
|
DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.startDay = date;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
currentTime: widget.startDay,
|
|
|
|
|
locale: projectViewModel.localeType);
|
|
|
|
|
}, currentTime: widget.startDay, locale: projectViewModel.localeType);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
@ -120,25 +107,17 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
DatePicker.showDatePicker(context,
|
|
|
|
|
showTitleActions: true,
|
|
|
|
|
minTime: DateTime(
|
|
|
|
|
DateTime.now().year, DateTime.now().month - 1, 1),
|
|
|
|
|
maxTime: DateTime.now(), onConfirm: (date) {
|
|
|
|
|
DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.endDay = date;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
currentTime: widget.endDay,
|
|
|
|
|
locale: projectViewModel.localeType);
|
|
|
|
|
}, currentTime: widget.endDay, locale: projectViewModel.localeType);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
@ -163,10 +142,7 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
@ -196,28 +172,21 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
DatePicker.showTimePicker(context,
|
|
|
|
|
showTitleActions: true, onConfirm: (date) {
|
|
|
|
|
DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget._scheduleList[index] = date;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
currentTime: widget._scheduleList[index],
|
|
|
|
|
locale: projectViewModel.localeType);
|
|
|
|
|
}, currentTime: widget._scheduleList[index], locale: projectViewModel.localeType);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 65,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getDateTime(
|
|
|
|
|
widget._scheduleList[index])),
|
|
|
|
|
Texts(getDateTime(widget._scheduleList[index])),
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.access_time,
|
|
|
|
|
color: Colors.black,
|
|
|
|
@ -238,29 +207,29 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.2,
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).ok,
|
|
|
|
|
color: Colors.grey[800],
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onTap: () {
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).ok.toUpperCase(),
|
|
|
|
|
() {
|
|
|
|
|
schedule();
|
|
|
|
|
},
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).cancel,
|
|
|
|
|
color: Colors.red[800],
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onTap: () {
|
|
|
|
|
SizedBox(width: 10),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).cancel,
|
|
|
|
|
() {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
color: Color(0xffC5272D),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
@ -270,16 +239,11 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
schedule() async {
|
|
|
|
|
List<DateTime> scheduleDateTime =
|
|
|
|
|
calculateDaysInterval(widget.startDay, widget.endDay);
|
|
|
|
|
List<DateTime> scheduleDateTime = calculateDaysInterval(widget.startDay, widget.endDay);
|
|
|
|
|
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
calendarUtils.createOrUpdateEvents(
|
|
|
|
|
scheduleList: widget._scheduleList,
|
|
|
|
|
description: widget.itemDescription,
|
|
|
|
|
title: widget.itemDescription,
|
|
|
|
|
scheduleDateTime: scheduleDateTime);
|
|
|
|
|
calendarUtils.createOrUpdateEvents(scheduleList: widget._scheduleList, description: widget.itemDescription, title: widget.itemDescription, scheduleDateTime: scheduleDateTime);
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
@ -288,8 +252,7 @@ class _ReminderPageState extends State<ReminderPage> {
|
|
|
|
|
List<DateTime> days = [];
|
|
|
|
|
for (int i = 0; i <= endDate.difference(startDate).inDays; i++) {
|
|
|
|
|
widget._scheduleList.forEach((element) {
|
|
|
|
|
days.add(startDate.add(
|
|
|
|
|
Duration(days: i, hours: element.hour, minutes: element.minute)));
|
|
|
|
|
days.add(startDate.add(Duration(days: i, hours: element.hour, minutes: element.minute)));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return days;
|
|
|
|
|