Skip to content

Commit

Permalink
Added add birth day remainder page
Browse files Browse the repository at this point in the history
  • Loading branch information
ZainNaqvi committed Jul 30, 2022
1 parent 72e3d56 commit 9e5560c
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions lib/ui/add_task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class AddTaskBar extends StatefulWidget {

class _AddTaskBarState extends State<AddTaskBar> {
DateTime? _selectedDate = DateTime.now();
String _startTime = DateFormat('hh:mm a').format(DateTime.now()).toString();
String _endTime = "9:29 AM";
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -43,9 +45,7 @@ class _AddTaskBarState extends State<AddTaskBar> {
hintText: DateFormat.yMd().format(_selectedDate!),
widget: IconButton(
onPressed: () async {
setState(() {
_selectedDate = _getUserDate(context);
});
_getUserDate(context);
},
icon: Icon(
Icons.calendar_today_outlined,
Expand All @@ -54,7 +54,33 @@ class _AddTaskBarState extends State<AddTaskBar> {
),
),
Row(
children: [],
children: [
Expanded(
child: MyTextField(
hintText: _startTime,
lable: "Start Time",
widget: IconButton(
icon: Icon(Icons.access_time_rounded),
onPressed: () {
_getUserTIme(isStarttime: true);
},
),
),
),
SizedBox(width: 6.w),
Expanded(
child: MyTextField(
hintText: _endTime,
lable: "End Time",
widget: IconButton(
icon: Icon(Icons.access_time_rounded),
onPressed: () {
_getUserTIme(isStarttime: false);
},
),
),
),
],
),
],
),
Expand All @@ -79,6 +105,33 @@ class _AddTaskBarState extends State<AddTaskBar> {
}
}

_getUserTIme({required bool isStarttime}) async {
var userPickTime = await _showTimePicker();
String _formatedTime = userPickTime.format(context);
if (userPickTime == null) {
print("Time is not valid time cancelled");
} else if (isStarttime) {
setState(() {
_startTime = _formatedTime;
});
} else if (isStarttime == false) {
setState(() {
_endTime = _formatedTime;
});
}
}

_showTimePicker() {
return showTimePicker(
initialEntryMode: TimePickerEntryMode.input,
context: context,
initialTime: TimeOfDay(
hour: int.parse(_startTime.split(":")[0]),
minute: int.parse(_startTime.split(":")[1].split(" ")[0]),
),
);
}

AppBar _appBar() {
return AppBar(
elevation: 0,
Expand Down

0 comments on commit 9e5560c

Please sign in to comment.