New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor notifications #8
Conversation
icon: NoorIcons.morning, | ||
time: formatTime(morningNotiTime), | ||
enabled: morningNotiEnabled, | ||
onTap: () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onTap method is redundant, it could be made into one method and called from morning & night widgets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, what if we tried something like this:
onTap: () { | |
onTap: () async { | |
final DateTime? selectedTime = await pickTime(context); | |
// ... | |
} | |
Future<DateTime?> pickTime(BuildContext context) async { | |
DateTime? timeChange; | |
final DateTime? time = await showModalBottomSheet<DateTime?>( | |
isDismissible: false, | |
context: context, | |
builder: (BuildContext context) => SizedBox( | |
height: 250, | |
child: Column( | |
children: <Widget>[ | |
Container( | |
height: 35, | |
color: Theme.of(context).dialogTheme.backgroundColor, | |
child: Row( | |
children: <Widget>[ | |
SizedBox( | |
width: 60, | |
child: TextButton( | |
child: Text( | |
'حفظ', | |
style: Theme.of(context).textTheme.bodyText1!.copyWith( | |
fontWeight: FontWeight.bold, | |
color: Theme.of(context).accentColor, | |
fontSize: 12), | |
), | |
onPressed: () async { | |
Navigator.of(context).pop(timeChange); | |
}, | |
), | |
), | |
SizedBox( | |
width: 60, | |
child: TextButton( | |
child: Text( | |
'إلغاء', | |
style: Theme.of(context).textTheme.bodyText1!.copyWith( | |
fontWeight: FontWeight.bold, | |
color: Theme.of(context).accentColor, | |
fontSize: 12), | |
), | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
), | |
), | |
], | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
), | |
), | |
Expanded( | |
child: Directionality( | |
textDirection: TextDirection.ltr, | |
child: CupertinoTheme( | |
data: CupertinoThemeData( | |
textTheme: CupertinoTextThemeData( | |
dateTimePickerTextStyle: | |
Theme.of(context).textTheme.bodyText1, | |
), | |
), | |
child: CupertinoDatePicker( | |
backgroundColor: Theme.of(context).cardColor, | |
mode: CupertinoDatePickerMode.time, | |
initialDateTime: morningNotiTime ?? DateTime.now(), | |
onDateTimeChanged: (DateTime newDateTime) => | |
timeChange = newDateTime, | |
minuteInterval: 1, | |
), | |
), | |
), | |
), | |
], | |
), | |
), | |
); | |
return time; | |
} |
Hello Ibrahim, apologies for taking time to review, are you still interested in completing this PR? |
Hi, yes i would appreciate to help with this |
Hi, i made two changes in this PR.