mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Cw 426 replace trash and swipe with edit icons (#974)
* feat: Replace trash and swipe with edit icons on node list item - replaces yellow Test button with red Delete node button with confirmation on the edit node page * feat: make node indicator icons bigger (figma comment) * feat: Replace trash and swipe with edit icons on wallet list page and create wallet_edit_page.dart * fix: make delete buttons red * fix: make wallet name wrap when it is too long * refactor: improve logic & fix observer not refreshing * fix: add string * feat: remove the confirmation pop-up for switching between wallets - which was another item on the jira issue * fix: remove slideable widgets from node list * feat: add edit button to currently selected node & disable deleting if selected * fix: rename wallet also renames to new wallet files * feat: make sure edits can't overlap existing names * fix: improve rename flow, fix electrum transactions refresh & add delete old logic * fix: also fix rename for monero & haven * refactor: fix identations * refactor: dont declare the current wallet twice * refactor: missing newWalletInfo.id * fix: dont unnecessarily load the current wallet * fix: remove unnecessary reaction * feat: make save button disabled until the text is changed * feat: make walletEditViewModel and make state useful for pending actions * fix: add back reaction for desktop flow * - Remove un-necessary code - Format Edit page --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
bb6dea0292
commit
d4969633b0
48 changed files with 670 additions and 249 deletions
|
@ -7,43 +7,58 @@ import 'package:cw_core/wallet_type.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class WalletLoadingService {
|
||||
WalletLoadingService(
|
||||
this.sharedPreferences,
|
||||
this.keyService,
|
||||
this.walletServiceFactory);
|
||||
|
||||
final SharedPreferences sharedPreferences;
|
||||
final KeyService keyService;
|
||||
final WalletService Function(WalletType type) walletServiceFactory;
|
||||
WalletLoadingService(
|
||||
this.sharedPreferences, this.keyService, this.walletServiceFactory);
|
||||
|
||||
Future<WalletBase> load(WalletType type, String name) async {
|
||||
final walletService = walletServiceFactory.call(type);
|
||||
final password = await keyService.getWalletPassword(walletName: name);
|
||||
final wallet = await walletService.openWallet(name, password);
|
||||
final SharedPreferences sharedPreferences;
|
||||
final KeyService keyService;
|
||||
final WalletService Function(WalletType type) walletServiceFactory;
|
||||
|
||||
if (type == WalletType.monero) {
|
||||
await updateMoneroWalletPassword(wallet);
|
||||
}
|
||||
Future<void> renameWallet(
|
||||
WalletType type, String name, String newName) async {
|
||||
final walletService = walletServiceFactory.call(type);
|
||||
final password = await keyService.getWalletPassword(walletName: name);
|
||||
|
||||
return wallet;
|
||||
}
|
||||
// Save the current wallet's password to the new wallet name's key
|
||||
await keyService.saveWalletPassword(
|
||||
walletName: newName, password: password);
|
||||
// Delete previous wallet name from keyService to keep only new wallet's name
|
||||
// otherwise keeps duplicate (old and new names)
|
||||
await keyService.deleteWalletPassword(walletName: name);
|
||||
|
||||
Future<void> updateMoneroWalletPassword(WalletBase wallet) async {
|
||||
final key = PreferencesKey.moneroWalletUpdateV1Key(wallet.name);
|
||||
var isPasswordUpdated = sharedPreferences.getBool(key) ?? false;
|
||||
await walletService.rename(name, password, newName);
|
||||
}
|
||||
|
||||
if (isPasswordUpdated) {
|
||||
return;
|
||||
}
|
||||
Future<WalletBase> load(WalletType type, String name) async {
|
||||
final walletService = walletServiceFactory.call(type);
|
||||
final password = await keyService.getWalletPassword(walletName: name);
|
||||
final wallet = await walletService.openWallet(name, password);
|
||||
|
||||
final password = generateWalletPassword();
|
||||
// Save new generated password with backup key for case where
|
||||
// wallet will change password, but it will fail to update in secure storage
|
||||
final bakWalletName = '#__${wallet.name}_bak__#';
|
||||
await keyService.saveWalletPassword(walletName: bakWalletName, password: password);
|
||||
await wallet.changePassword(password);
|
||||
await keyService.saveWalletPassword(walletName: wallet.name, password: password);
|
||||
isPasswordUpdated = true;
|
||||
await sharedPreferences.setBool(key, isPasswordUpdated);
|
||||
}
|
||||
if (type == WalletType.monero) {
|
||||
await updateMoneroWalletPassword(wallet);
|
||||
}
|
||||
|
||||
return wallet;
|
||||
}
|
||||
|
||||
Future<void> updateMoneroWalletPassword(WalletBase wallet) async {
|
||||
final key = PreferencesKey.moneroWalletUpdateV1Key(wallet.name);
|
||||
var isPasswordUpdated = sharedPreferences.getBool(key) ?? false;
|
||||
|
||||
if (isPasswordUpdated) {
|
||||
return;
|
||||
}
|
||||
|
||||
final password = generateWalletPassword();
|
||||
// Save new generated password with backup key for case where
|
||||
// wallet will change password, but it will fail to update in secure storage
|
||||
final bakWalletName = '#__${wallet.name}_bak__#';
|
||||
await keyService.saveWalletPassword(
|
||||
walletName: bakWalletName, password: password);
|
||||
await wallet.changePassword(password);
|
||||
await keyService.saveWalletPassword(
|
||||
walletName: wallet.name, password: password);
|
||||
isPasswordUpdated = true;
|
||||
await sharedPreferences.setBool(key, isPasswordUpdated);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue