Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

ibrahimSam
Copy link

Hi, i made two changes in this PR.

  1. Change subtitleWithIcon functional widget to statless widget to make it reusable by another items.
  2. Refactor notifications parts.

icon: NoorIcons.morning,
time: formatTime(morningNotiTime),
enabled: morningNotiEnabled,
onTap: () {
Copy link
Owner

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

Copy link
Author

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:

Suggested change
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;
}

@ibrahimSam ibrahimSam closed this Oct 23, 2021
@pr-Mais
Copy link
Owner

pr-Mais commented Nov 6, 2021

Hello Ibrahim, apologies for taking time to review, are you still interested in completing this PR?

@ibrahimSam
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants