Add confirmation before deleting wallet; Add titles to AppBars; Allow space in wallets names

This commit is contained in:
poka 2021-01-15 03:11:58 +01:00
parent cc22dd6a08
commit 9d07d7373c
3 changed files with 59 additions and 8 deletions

View File

@ -41,7 +41,11 @@ class ConfirmStoreWalletState extends State<ConfirmStoreWallet> {
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(),
appBar: AppBar(
title: SizedBox(
height: 25,
child: Text('Confirmez ce portefeuille'),
)),
body: Center(
child: Column(children: <Widget>[
SizedBox(height: 15),
@ -96,8 +100,8 @@ class ConfirmStoreWalletState extends State<ConfirmStoreWallet> {
),
TextField(
inputFormatters: [
new FilteringTextInputFormatter.allow(
RegExp('[a-zA-Z|0-9|\\-|_]')),
FilteringTextInputFormatter.allow(
RegExp('[a-zA-Z|0-9|\\-|_| ]')),
],
enabled: isAskedWordValid,
controller: this.walletName,
@ -201,7 +205,7 @@ class ConfirmStoreWalletState extends State<ConfirmStoreWallet> {
),
actions: <Widget>[
TextButton(
child: Text('Approve'),
child: Text("J'ai compris"),
onPressed: () {
Navigator.of(context).pop();
},

View File

@ -37,7 +37,11 @@ class GenerateWalletsState extends State<GenerateWalletsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
appBar: AppBar(
title: SizedBox(
height: 25,
child: Text('Générer un portefeuille'),
)),
floatingActionButton: Container(
height: 80.0,
width: 80.0,

View File

@ -36,7 +36,11 @@ class WalletOptionsState extends State<WalletOptions> {
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(),
appBar: AppBar(
title: SizedBox(
height: 25,
child: Text(widget.walletName),
)),
body: Center(
child: SafeArea(
child: Column(children: <Widget>[
@ -212,14 +216,53 @@ class WalletOptionsState extends State<WalletOptions> {
final _walletFile = Directory('$appPath/wallets/$_name');
print('DELETE THAT ?: $_walletFile');
_walletFile.deleteSync(recursive: true);
Navigator.pop(context);
final bool _answer = await _confirmDeletingWallet();
if (_answer) {
_walletFile.deleteSync(recursive: true);
Navigator.pop(context);
}
return 0;
} catch (e) {
return 1;
}
}
Future<bool> _confirmDeletingWallet() async {
return showDialog<bool>(
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(
'Êtes-vous sûr de vouloir supprimer le portefeuille ${widget.walletName} ?'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(
'Vous pourrez restaurer ce portefeuille à tout moment grace à votre phrase de restauration.'),
],
),
),
actions: <Widget>[
TextButton(
child: Text("Non"),
onPressed: () {
Navigator.pop(context, false);
},
),
TextButton(
child: Text("Oui"),
onPressed: () {
Navigator.pop(context, true);
},
),
],
);
},
);
}
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;