mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-24 06:48:38 +02: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:
@@ -0,0 +1,55 @@
|
||||
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
|
||||
part 'wallet_edit_view_model.g.dart';
|
||||
|
||||
class WalletEditViewModel = WalletEditViewModelBase with _$WalletEditViewModel;
|
||||
|
||||
abstract class WalletEditViewModelState {}
|
||||
|
||||
class WalletEditViewModelInitialState extends WalletEditViewModelState {}
|
||||
|
||||
class WalletEditRenamePending extends WalletEditViewModelState {}
|
||||
|
||||
class WalletEditDeletePending extends WalletEditViewModelState {}
|
||||
|
||||
abstract class WalletEditViewModelBase with Store {
|
||||
WalletEditViewModelBase(this._walletListViewModel, this._walletLoadingService)
|
||||
: state = WalletEditViewModelInitialState(),
|
||||
newName = '';
|
||||
|
||||
@observable
|
||||
WalletEditViewModelState state;
|
||||
|
||||
@observable
|
||||
String newName;
|
||||
|
||||
final WalletListViewModel _walletListViewModel;
|
||||
final WalletLoadingService _walletLoadingService;
|
||||
|
||||
@action
|
||||
Future<void> changeName(WalletListItem walletItem) async {
|
||||
state = WalletEditRenamePending();
|
||||
await _walletLoadingService.renameWallet(
|
||||
walletItem.type, walletItem.name, newName);
|
||||
_walletListViewModel.updateList();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> remove(WalletListItem wallet) async {
|
||||
state = WalletEditDeletePending();
|
||||
final walletService = getIt.get<WalletService>(param1: wallet.type);
|
||||
await walletService.remove(wallet.name);
|
||||
resetState();
|
||||
_walletListViewModel.updateList();
|
||||
}
|
||||
|
||||
@action
|
||||
void resetState() {
|
||||
state = WalletEditViewModelInitialState();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:cake_wallet/core/auth_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -21,8 +20,8 @@ abstract class WalletListViewModelBase with Store {
|
||||
this._walletLoadingService,
|
||||
this._authService,
|
||||
) : wallets = ObservableList<WalletListItem>() {
|
||||
_updateList();
|
||||
reaction((_) => _appStore.wallet, (_) => _updateList());
|
||||
updateList();
|
||||
reaction((_) => _appStore.wallet, (_) => updateList());
|
||||
}
|
||||
|
||||
@observable
|
||||
@@ -37,20 +36,14 @@ abstract class WalletListViewModelBase with Store {
|
||||
|
||||
@action
|
||||
Future<void> loadWallet(WalletListItem walletItem) async {
|
||||
final wallet = await _walletLoadingService.load(walletItem.type, walletItem.name);
|
||||
final wallet =
|
||||
await _walletLoadingService.load(walletItem.type, walletItem.name);
|
||||
|
||||
_appStore.changeCurrentWallet(wallet);
|
||||
_updateList();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> remove(WalletListItem wallet) async {
|
||||
final walletService = getIt.get<WalletService>(param1: wallet.type);
|
||||
await walletService.remove(wallet.name);
|
||||
await _walletInfoSource.delete(wallet.key);
|
||||
_updateList();
|
||||
}
|
||||
|
||||
void _updateList() {
|
||||
void updateList() {
|
||||
wallets.clear();
|
||||
wallets.addAll(
|
||||
_walletInfoSource.values.map(
|
||||
@@ -58,7 +51,8 @@ abstract class WalletListViewModelBase with Store {
|
||||
name: info.name,
|
||||
type: info.type,
|
||||
key: info.key,
|
||||
isCurrent: info.name == _appStore.wallet!.name && info.type == _appStore.wallet!.type,
|
||||
isCurrent: info.name == _appStore.wallet!.name &&
|
||||
info.type == _appStore.wallet!.type,
|
||||
isEnabled: availableWalletTypes.contains(info.type),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user