@@ -5,8 +5,8 @@ import 'package:go_router/go_router.dart';
55import 'package:flutter_bloc/flutter_bloc.dart' ;
66import 'package:on_time_front/presentation/app/bloc/schedule/schedule_bloc.dart' ;
77import 'package:on_time_front/l10n/app_localizations.dart' ;
8- import 'package:on_time_front/presentation/shared/components/custom_alert_dialog .dart' ;
9- import 'package:on_time_front/presentation/shared/components/modal_button .dart' ;
8+ import 'package:on_time_front/presentation/shared/components/modal_wide_button .dart' ;
9+ import 'package:on_time_front/presentation/shared/components/two_action_dialog .dart' ;
1010import 'package:on_time_front/presentation/shared/constants/app_colors.dart' ;
1111
1212class ScheduleStartScreen extends StatefulWidget {
@@ -22,14 +22,29 @@ class ScheduleStartScreen extends StatefulWidget {
2222}
2323
2424class _ScheduleStartScreenState extends State <ScheduleStartScreen > {
25- void _showModal (BuildContext context) {
26- showDialog (
27- context: context,
28- barrierDismissible: false ,
29- builder: (BuildContext context) {
30- return _ScheduleStartScreenModal ();
31- },
25+ Future <void > _showModal (BuildContext context) async {
26+ final l10n = AppLocalizations .of (context)! ;
27+
28+ final result = await showTwoActionDialog (
29+ context,
30+ config: TwoActionDialogConfig (
31+ title: l10n.confirmLeave,
32+ description: l10n.confirmLeaveDescription,
33+ barrierDismissible: false ,
34+ secondaryAction: DialogActionConfig (
35+ label: l10n.leave,
36+ variant: ModalWideButtonVariant .neutral,
37+ ),
38+ primaryAction: DialogActionConfig (
39+ label: l10n.stay,
40+ variant: ModalWideButtonVariant .primary,
41+ ),
42+ ),
3243 );
44+
45+ if (result == DialogActionResult .secondary && context.mounted) {
46+ context.go ('/home' );
47+ }
3348 }
3449
3550 bool _isFiveMinutesBefore () {
@@ -122,7 +137,7 @@ class _ScheduleStartScreenState extends State<ScheduleStartScreen> {
122137 right: 10 ,
123138 child: IconButton (
124139 icon: const Icon (Icons .close),
125- onPressed: () => _showModal (context),
140+ onPressed: () async => _showModal (context),
126141 ),
127142 ),
128143 ],
@@ -177,31 +192,3 @@ class _ScheduleStartScreenState extends State<ScheduleStartScreen> {
177192 );
178193 }
179194}
180-
181- class _ScheduleStartScreenModal extends StatelessWidget {
182- @override
183- Widget build (BuildContext context) {
184- return CustomAlertDialog (
185- title: Text (
186- AppLocalizations .of (context)! .confirmLeave,
187- ),
188- content: Text (
189- AppLocalizations .of (context)! .confirmLeaveDescription,
190- ),
191- actions: [
192- ModalButton (
193- onPressed: () => context.go ('/home' ),
194- text: AppLocalizations .of (context)! .leave,
195- color: Theme .of (context).colorScheme.surfaceContainerLow,
196- textColor: Theme .of (context).colorScheme.outline,
197- ),
198- ModalButton (
199- onPressed: () => Navigator .pop (context),
200- text: AppLocalizations .of (context)! .stay,
201- color: Theme .of (context).colorScheme.primary,
202- textColor: Theme .of (context).colorScheme.onPrimary,
203- ),
204- ],
205- );
206- }
207- }
0 commit comments