-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- implement wallet delete and rename - implement wallet screen as it is in cake - don't show recovery screen for restored wallet - settings screen [WIP]
- Loading branch information
Showing
15 changed files
with
333 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:cup_cake/coins/abstract.dart'; | ||
import 'package:cup_cake/coins/list.dart'; | ||
import 'package:cup_cake/view_model/abstract.dart'; | ||
|
||
class SettingsViewModel extends ViewModel { | ||
SettingsViewModel(); | ||
|
||
@override | ||
String get screenName => "Settings"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:cup_cake/coins/abstract.dart'; | ||
import 'package:cup_cake/view_model/create_wallet_view_model.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:cup_cake/view_model/abstract.dart'; | ||
import 'package:path/path.dart' as p; | ||
|
||
class WalletEditViewModel extends ViewModel { | ||
WalletEditViewModel({ | ||
required this.walletInfo, | ||
}); | ||
|
||
CoinWalletInfo walletInfo; | ||
|
||
late StringFormElement walletName = StringFormElement("Wallet name", | ||
initialText: p.basename(walletInfo.walletName),); | ||
|
||
late PinFormElement walletPassword = PinFormElement( | ||
label: "Wallet password", | ||
password: true, | ||
valueOutcome: FlutterSecureStorageValueOutcome( | ||
"secure.wallet_password", | ||
canWrite: false, | ||
verifyMatching: true, | ||
), | ||
validator: (String? input) { | ||
if (input == null) return L.warning_input_cannot_be_null; | ||
if (input == "") return L.warning_input_cannot_be_empty; | ||
if (input.length < 4) { | ||
return L.warning_password_too_short; | ||
} | ||
return null; | ||
}, | ||
showNumboard: false,); | ||
|
||
late final List<FormElement> form = [ | ||
walletName, | ||
walletPassword, | ||
]; | ||
|
||
@override | ||
String get screenName => "Edit wallet"; | ||
|
||
Future<void> deleteWallet(BuildContext context) async { | ||
if (!(await walletInfo.checkWalletPassword(await walletPassword.value))) { | ||
throw Exception("Invalid wallet password"); | ||
} | ||
walletInfo.deleteWallet(); | ||
if (!context.mounted) return; | ||
Navigator.of(context).pop(); | ||
} | ||
|
||
|
||
Future<void> renameWallet(BuildContext context) async { | ||
if (!(await walletInfo.checkWalletPassword(await walletPassword.value))) { | ||
throw Exception("Invalid wallet password"); | ||
} | ||
walletInfo.renameWallet(await walletName.value); | ||
if (!context.mounted) return; | ||
Navigator.of(context).pop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.