Skip to content

Commit

Permalink
Merge pull request #21 from RyanRory/wallet-deletion-warning
Browse files Browse the repository at this point in the history
Wallet deletion warning
  • Loading branch information
jagerman authored Apr 19, 2022
2 parents 86e677d + ba55cd3 commit f211cfd
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 10 deletions.
20 changes: 20 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:oxen_wallet/src/screens/auth/create_login_page.dart';
import 'package:oxen_wallet/src/screens/auth/create_unlock_page.dart';
import 'package:oxen_wallet/src/screens/changelog/changelog_page.dart';
import 'package:oxen_wallet/src/screens/dangerzone/dangerzone_page.dart';
import 'package:oxen_wallet/src/screens/dangerzone/dangerzone_remove_wallet.dart';
import 'package:oxen_wallet/src/screens/dashboard/create_dashboard_page.dart';
import 'package:oxen_wallet/src/screens/disclaimer/disclaimer_page.dart';
import 'package:oxen_wallet/src/screens/faq/faq_page.dart';
Expand Down Expand Up @@ -389,6 +390,13 @@ class Router {
);
});

case Routes.dangerzoneRemoveWallet:
return MaterialPageRoute<void>(builder: (context) {
return DangerzoneRemoveWalletPage(
onConfirmed: settings.arguments as void Function(),
);
});

case Routes.subaddressList:
return MaterialPageRoute<Subaddress>(
builder: (_) => MultiProvider(providers: [
Expand Down
1 change: 1 addition & 0 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Routes {
static const addressBookAddContact = '/address_book_add_contact';
static const dangerzoneKeys = '/dangerzone/keys';
static const dangerzoneSeed = '/dangerzone/seed';
static const dangerzoneRemoveWallet = '//dangerzone/remove_wallet';
static const showKeys = '/dangerzone/show/keys';
static const subaddressList = '/subaddress_list';
static const restoreWalletFromSeedDetails = '/restore_from_seed_details';
Expand Down
82 changes: 82 additions & 0 deletions lib/src/screens/dangerzone/dangerzone_remove_wallet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:oxen_wallet/generated/l10n.dart';
import 'package:oxen_wallet/palette.dart';
import 'package:oxen_wallet/routes.dart';
import 'package:oxen_wallet/src/screens/base_page.dart';
import 'package:oxen_wallet/src/widgets/primary_button.dart';

class DangerzoneRemoveWalletPage extends BasePage {
DangerzoneRemoveWalletPage({this.onConfirmed});

final void Function() onConfirmed;

@override
Widget body(BuildContext context) {
final _baseWidth = 411.43;
final _screenWidth = MediaQuery.of(context).size.width;
final textScaleFactor = _screenWidth < _baseWidth ? 0.76 : 1.0;

return Column(children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(20),
child: Icon(Icons.warning_amber_sharp,
size: 125, color: OxenPalette.red),
),
Padding(
padding: EdgeInsets.all(10),
child: Text(
S.of(context).dangerzone,
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
textScaleFactor: textScaleFactor,
textAlign: TextAlign.center,
),
),
Padding(
padding: EdgeInsets.all(10),
child: Text(
S.of(context).remove_wallet_confirmation,
style: TextStyle(
fontSize: 22.0,
color: Palette.lightBlue,
),
textScaleFactor: textScaleFactor,
textAlign: TextAlign.center,
)),
Padding(
padding: EdgeInsets.all(10),
child: Text(
S.of(context).dangerzone_remove_wallet_warning,
style: TextStyle(
fontSize: 16.0,
color: Palette.lightBlue,
),
textScaleFactor: textScaleFactor,
textAlign: TextAlign.center,
))
]),
),
Container(
padding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 20.0),
child: PrimaryButton(
onPressed: () {
onConfirmed();
Navigator.of(context).pop();
},
text: S.of(context).yes_im_sure,
color: Theme.of(context).primaryTextTheme.button.backgroundColor,
borderColor:
Theme.of(context).primaryTextTheme.button.decorationColor),
)
]);
}
}
23 changes: 13 additions & 10 deletions lib/src/screens/wallet_list/wallet_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ class WalletMenu {
return;
}

try {
auth.changeProcessText(
S.of(context).wallet_list_removing_wallet(wallet.name));
await _walletListStore.remove(wallet);
auth.close();
} catch (e) {
auth.changeProcessText(S
.of(context)
.wallet_list_failed_to_remove(wallet.name, e.toString()));
}
await Navigator.of(context).pushNamed(Routes.dangerzoneRemoveWallet, arguments:
() async {
try {
auth.changeProcessText(
S.of(context).wallet_list_removing_wallet(wallet.name));
await _walletListStore.remove(wallet);
auth.close();
} catch (e) {
auth.changeProcessText(S
.of(context)
.wallet_list_failed_to_remove(wallet.name, e.toString()));
}
});
});
break;
case 3:
Expand Down

0 comments on commit f211cfd

Please sign in to comment.