Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Feb 16, 2024
1 parent 579d1bd commit 83f86d1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 51 deletions.
57 changes: 30 additions & 27 deletions lib/widgets/account_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,36 @@ class AccountCreateWrapperWidget extends StatelessWidget {
appBar: AppBar(
title: Text(mainTitle),
),
body: WillPopScope(
body: PopScope(
canPop: skipBackCheck,
onPopInvoked: (bool didPop) async {
if (didPop) {
return;
}
final vc = BlocProvider.of<VaultCubit>(context);
final ac = BlocProvider.of<AccountCubit>(context);
final NavigatorState navigator = Navigator.of(context);
final result = await showDialog(
routeSettings: RouteSettings(),
context: context,
builder: (context) => AlertDialog(
title: Text('Cancel registration?'),
content: Text(
'If you are part way through the account registration process, we cannot be sure whether your registration has completed or not, nor whether your Subscription provider has activated your subscription already. In that case, you may need to take additional actions to complete registration later or tidy up afterwards.'),
actions: <Widget>[
OutlinedButton(
child: Text('Cancel registration'.toUpperCase()),
onPressed: () => Navigator.of(context).pop(true)),
OutlinedButton(
child: Text('Continue registering'.toUpperCase()),
onPressed: () => Navigator.of(context).pop(false)),
]));
if (result) {
// sign out so user can see initial signin/register page again.
await ac.forgetUser(vc.signout);
navigator.pop();
}
},
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
Expand All @@ -806,32 +835,6 @@ class AccountCreateWrapperWidget extends StatelessWidget {
),
),
),
onWillPop: () async {
final vc = BlocProvider.of<VaultCubit>(context);
final ac = BlocProvider.of<AccountCubit>(context);
final result = skipBackCheck ||
await showDialog(
routeSettings: RouteSettings(),
context: context,
builder: (context) => AlertDialog(
title: Text('Cancel registration?'),
content: Text(
'If you are part way through the account registration process, we cannot be sure whether your registration has completed or not, nor whether your Subscription provider has activated your subscription already. In that case, you may need to take additional actions to complete registration later or tidy up afterwards.'),
actions: <Widget>[
OutlinedButton(
child: Text('Cancel registration'.toUpperCase()),
onPressed: () => Navigator.of(context).pop(true)),
OutlinedButton(
child: Text('Continue registering'.toUpperCase()),
onPressed: () => Navigator.of(context).pop(false)),
]));
if (result) {
// sign out so user can see initial signin/register page again.
await ac.forgetUser(vc.signout);
return true;
}
return false;
},
),
),
);
Expand Down
44 changes: 22 additions & 22 deletions lib/widgets/entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,28 @@ class EntryWidget extends StatelessWidget {
)
],
),
body: WillPopScope(
body: PopScope(
canPop: !entry.isDirty,
onPopInvoked: (bool didPop) async {
if (didPop) {
return;
}
final result = await showDialog(
routeSettings: RouteSettings(),
context: context,
builder: (context) =>
AlertDialog(title: Text(str.keep_your_changes_question), actions: <Widget>[
OutlinedButton(
child: Text(str.keep.toUpperCase()),
onPressed: () => Navigator.of(context).pop(true)),
OutlinedButton(
child: Text(str.discard.toUpperCase()),
onPressed: () => Navigator.of(context).pop(false)),
]));
if (result != null) {
endEditing(result);
}
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down Expand Up @@ -550,27 +571,6 @@ class EntryWidget extends StatelessWidget {
)),
],
),
onWillPop: () async {
if (!entry.isDirty) {
return true;
}
final result = await showDialog(
routeSettings: RouteSettings(),
context: context,
builder: (context) =>
AlertDialog(title: Text(str.keep_your_changes_question), actions: <Widget>[
OutlinedButton(
child: Text(str.keep.toUpperCase()),
onPressed: () => Navigator.of(context).pop(true)),
OutlinedButton(
child: Text(str.discard.toUpperCase()),
onPressed: () => Navigator.of(context).pop(false)),
]));
if (result != null) {
endEditing(result);
}
return false;
},
),
extendBody: true,
floatingActionButton: SpeedDial(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/entry_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ class EntryListItemWidget extends StatelessWidget {
unawaited(showDialog(
context: context,
barrierDismissible: false,
builder: (context) => WillPopScope(
onWillPop: () async => false,
builder: (context) => PopScope(
canPop: false,
child: Center(
child: SizedBox(width: 48, height: 48, child: LoadingSpinner(tooltip: str.autofilling))),
),
Expand Down

0 comments on commit 83f86d1

Please sign in to comment.