Skip to content

Commit 889649d

Browse files
authored
Merge pull request #516 from DevKor-github/feature/schedule-modal-dismissal
[codex] Adjust schedule modal dismissal
2 parents 86a8964 + 863d156 commit 889649d

3 files changed

Lines changed: 69 additions & 59 deletions

File tree

‎lib/presentation/calendar/screens/calendar_screen.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
124124
Future<void> _openCreateScheduleSheet(BuildContext context) async {
125125
final saved = await showModalBottomSheet<bool>(
126126
context: context,
127+
isDismissible: false,
127128
isScrollControlled: true,
128129
backgroundColor: Colors.transparent,
129130
builder: (context) =>

‎lib/presentation/shared/components/bottom_nav_bar_scaffold.dart‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class _BottomNavigationBarScaffoldState extends State<BottomNavBarScaffold> {
101101
onPressed: () {
102102
showModalBottomSheet(
103103
context: context,
104+
isDismissible: false,
104105
isScrollControlled: true,
105106
backgroundColor: Colors.transparent,
106107
builder: (context) => const ScheduleCreateScreen(),
@@ -174,10 +175,7 @@ class _HomeIcon extends StatelessWidget {
174175
semanticsLabel: AppLocalizations.of(context)!.home,
175176
height: iconTheme.size,
176177
fit: BoxFit.contain,
177-
colorFilter: ColorFilter.mode(
178-
iconTheme.color!,
179-
BlendMode.srcIn,
180-
),
178+
colorFilter: ColorFilter.mode(iconTheme.color!, BlendMode.srcIn),
181179
);
182180
}
183181
}
@@ -194,10 +192,7 @@ class _MyIcon extends StatelessWidget {
194192
semanticsLabel: AppLocalizations.of(context)!.myPage,
195193
height: iconTheme.size,
196194
fit: BoxFit.contain,
197-
colorFilter: ColorFilter.mode(
198-
iconTheme.color!,
199-
BlendMode.srcIn,
200-
),
195+
colorFilter: ColorFilter.mode(iconTheme.color!, BlendMode.srcIn),
201196
);
202197
}
203198
}

‎lib/presentation/shared/components/cupertino_picker_modal.dart‎

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ extension ModalBottomSheetExtension on BuildContext {
88
required Duration initialValue,
99
required CupertinoTimerPickerMode mode,
1010
required Function(Duration value) onSaved,
11-
Function? onDisposed,
11+
VoidCallback? onDisposed,
1212
}) {
1313
showModalBottomSheet<void>(
14-
isDismissible: false,
14+
isDismissible: true,
1515
context: this,
1616
builder: (BuildContext context) {
1717
final textTheme = Theme.of(context).textTheme;
@@ -41,18 +41,20 @@ extension ModalBottomSheetExtension on BuildContext {
4141
Expanded(
4242
flex: 1,
4343
child: ElevatedButton(
44-
onPressed: () {
45-
//calling order matters
46-
Navigator.pop(context);
47-
onDisposed?.call();
48-
},
49-
style: ButtonStyle(
50-
backgroundColor: WidgetStatePropertyAll(
51-
Color.fromARGB(255, 220, 227, 255)),
52-
foregroundColor: WidgetStatePropertyAll(
53-
Color.fromARGB(255, 92, 121, 251)),
44+
onPressed: () {
45+
//calling order matters
46+
Navigator.pop(context);
47+
},
48+
style: ButtonStyle(
49+
backgroundColor: WidgetStatePropertyAll(
50+
Color.fromARGB(255, 220, 227, 255),
5451
),
55-
child: Text(AppLocalizations.of(this)!.cancel)),
52+
foregroundColor: WidgetStatePropertyAll(
53+
Color.fromARGB(255, 92, 121, 251),
54+
),
55+
),
56+
child: Text(AppLocalizations.of(this)!.cancel),
57+
),
5658
),
5759
SizedBox(width: 20.0),
5860
Expanded(
@@ -61,7 +63,6 @@ extension ModalBottomSheetExtension on BuildContext {
6163
onPressed: () {
6264
Navigator.pop(context);
6365
onSaved(duration);
64-
onDisposed?.call();
6566
},
6667
child: Text(AppLocalizations.of(this)!.ok),
6768
),
@@ -73,17 +74,19 @@ extension ModalBottomSheetExtension on BuildContext {
7374
),
7475
);
7576
},
76-
);
77+
).whenComplete(() {
78+
onDisposed?.call();
79+
});
7780
}
7881

7982
void showCupertinoMinutePickerModal({
8083
required String title,
8184
required Duration initialValue,
8285
required Function(Duration value) onSaved,
83-
Function? onDisposed,
86+
VoidCallback? onDisposed,
8487
}) {
8588
showModalBottomSheet<void>(
86-
isDismissible: false,
89+
isDismissible: true,
8790
context: this,
8891
builder: (BuildContext context) {
8992
final textTheme = Theme.of(context).textTheme;
@@ -92,8 +95,10 @@ extension ModalBottomSheetExtension on BuildContext {
9295
borderRadius: BorderRadius.vertical(top: Radius.circular(20.0)),
9396
child: Container(
9497
color: Theme.of(context).colorScheme.surface,
95-
padding:
96-
const EdgeInsets.symmetric(horizontal: 29.0, vertical: 28.0),
98+
padding: const EdgeInsets.symmetric(
99+
horizontal: 29.0,
100+
vertical: 28.0,
101+
),
97102
child: SizedBox(
98103
height: 334,
99104
child: Column(
@@ -106,16 +111,19 @@ extension ModalBottomSheetExtension on BuildContext {
106111
width: 69.0,
107112
child: CupertinoPicker(
108113
scrollController: FixedExtentScrollController(
109-
initialItem: initialValue.inMinutes),
114+
initialItem: initialValue.inMinutes,
115+
),
110116
looping: true,
111117
itemExtent: 32,
112118
onSelectedItemChanged: (int value) {
113119
minutes = value;
114120
},
115121
children: List.generate(
116-
60,
117-
(index) => Text(
118-
(index < 10 ? '0' : '') + index.toString())),
122+
60,
123+
(index) => Text(
124+
(index < 10 ? '0' : '') + index.toString(),
125+
),
126+
),
119127
),
120128
),
121129
),
@@ -127,18 +135,20 @@ extension ModalBottomSheetExtension on BuildContext {
127135
Expanded(
128136
flex: 1,
129137
child: ElevatedButton(
130-
onPressed: () {
131-
//calling order matters
132-
Navigator.pop(context);
133-
onDisposed?.call();
134-
},
135-
style: ButtonStyle(
136-
backgroundColor: WidgetStatePropertyAll(
137-
Color.fromARGB(255, 220, 227, 255)),
138-
foregroundColor: WidgetStatePropertyAll(
139-
Color.fromARGB(255, 92, 121, 251)),
138+
onPressed: () {
139+
//calling order matters
140+
Navigator.pop(context);
141+
},
142+
style: ButtonStyle(
143+
backgroundColor: WidgetStatePropertyAll(
144+
Color.fromARGB(255, 220, 227, 255),
145+
),
146+
foregroundColor: WidgetStatePropertyAll(
147+
Color.fromARGB(255, 92, 121, 251),
140148
),
141-
child: Text(AppLocalizations.of(this)!.cancel)),
149+
),
150+
child: Text(AppLocalizations.of(this)!.cancel),
151+
),
142152
),
143153
SizedBox(width: 20.0),
144154
Expanded(
@@ -147,7 +157,6 @@ extension ModalBottomSheetExtension on BuildContext {
147157
onPressed: () {
148158
Navigator.pop(context);
149159
onSaved(Duration(minutes: minutes));
150-
onDisposed?.call();
151160
},
152161
child: Text(AppLocalizations.of(this)!.ok),
153162
),
@@ -160,18 +169,20 @@ extension ModalBottomSheetExtension on BuildContext {
160169
),
161170
);
162171
},
163-
);
172+
).whenComplete(() {
173+
onDisposed?.call();
174+
});
164175
}
165176

166177
void showCupertinoDatePickerModal({
167178
required String title,
168179
required DateTime initialValue,
169180
required Function(DateTime value) onSaved,
170181
required CupertinoDatePickerMode mode,
171-
Function? onDisposed,
182+
VoidCallback? onDisposed,
172183
}) {
173184
showModalBottomSheet<void>(
174-
isDismissible: false,
185+
isDismissible: true,
175186
context: this,
176187
builder: (BuildContext context) {
177188
final textTheme = Theme.of(context).textTheme;
@@ -203,18 +214,20 @@ extension ModalBottomSheetExtension on BuildContext {
203214
Expanded(
204215
flex: 1,
205216
child: ElevatedButton(
206-
onPressed: () {
207-
//calling order matters
208-
Navigator.pop(context);
209-
onDisposed?.call();
210-
},
211-
style: ButtonStyle(
212-
backgroundColor: WidgetStatePropertyAll(
213-
Color.fromARGB(255, 220, 227, 255)),
214-
foregroundColor: WidgetStatePropertyAll(
215-
Color.fromARGB(255, 92, 121, 251)),
217+
onPressed: () {
218+
//calling order matters
219+
Navigator.pop(context);
220+
},
221+
style: ButtonStyle(
222+
backgroundColor: WidgetStatePropertyAll(
223+
Color.fromARGB(255, 220, 227, 255),
224+
),
225+
foregroundColor: WidgetStatePropertyAll(
226+
Color.fromARGB(255, 92, 121, 251),
216227
),
217-
child: Text(AppLocalizations.of(this)!.cancel)),
228+
),
229+
child: Text(AppLocalizations.of(this)!.cancel),
230+
),
218231
),
219232
SizedBox(width: 20.0),
220233
Expanded(
@@ -223,7 +236,6 @@ extension ModalBottomSheetExtension on BuildContext {
223236
onPressed: () {
224237
Navigator.pop(context);
225238
onSaved(dateTime);
226-
onDisposed?.call();
227239
},
228240
child: Text(AppLocalizations.of(this)!.ok),
229241
),
@@ -235,6 +247,8 @@ extension ModalBottomSheetExtension on BuildContext {
235247
),
236248
);
237249
},
238-
);
250+
).whenComplete(() {
251+
onDisposed?.call();
252+
});
239253
}
240254
}

0 commit comments

Comments
 (0)