From 0ff97bd357ee212c154f46499fc61065b44d1a34 Mon Sep 17 00:00:00 2001 From: ERussel Date: Tue, 7 Jan 2025 16:56:44 +0100 Subject: [PATCH] fix your wallets presentable --- .../Common/Protocols/YourWalletsPresentable.swift | 6 +++--- .../Add/StakingSetupProxyPresenter.swift | 10 +++++++--- .../TransferSetup/TransferSetupPresenter.swift | 11 ++++++++--- .../Modules/YourWallets/YourWalletsPresenter.swift | 12 ++++++++++-- .../Modules/YourWallets/YourWalletsProtocols.swift | 8 +++++--- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/novawallet/Common/Protocols/YourWalletsPresentable.swift b/novawallet/Common/Protocols/YourWalletsPresentable.swift index f13d7910be..a114482830 100644 --- a/novawallet/Common/Protocols/YourWalletsPresentable.swift +++ b/novawallet/Common/Protocols/YourWalletsPresentable.swift @@ -7,7 +7,7 @@ protocol YourWalletsPresentable { address: AccountAddress?, delegate: YourWalletsDelegate ) - func hideYourWallets(from view: ControllerBackedProtocol?) + func hideYourWallets(from view: YourWalletsPresentationProtocol) } extension YourWalletsPresentable { @@ -32,7 +32,7 @@ extension YourWalletsPresentable { view?.controller.present(viewController.controller, animated: true) } - func hideYourWallets(from view: ControllerBackedProtocol?) { - view?.controller.dismiss(animated: true) + func hideYourWallets(from view: YourWalletsPresentationProtocol) { + view.controller.dismiss(animated: true) } } diff --git a/novawallet/Modules/Staking/StakingProxy/Add/StakingSetupProxyPresenter.swift b/novawallet/Modules/Staking/StakingProxy/Add/StakingSetupProxyPresenter.swift index 75eed337bb..7de2b9bb8c 100644 --- a/novawallet/Modules/Staking/StakingProxy/Add/StakingSetupProxyPresenter.swift +++ b/novawallet/Modules/Staking/StakingProxy/Add/StakingSetupProxyPresenter.swift @@ -291,14 +291,18 @@ extension StakingSetupProxyPresenter: ModalPickerViewControllerDelegate { } extension StakingSetupProxyPresenter: YourWalletsDelegate { - func didSelectYourWallet(address: AccountAddress) { - wireframe.hideYourWallets(from: view) + func yourWallets( + selectionView: YourWalletsPresentationProtocol, + didSelect address: AccountAddress + ) { + wireframe.hideYourWallets(from: selectionView) + view?.didReceiveYourWallets(state: .inactive) updateRecepientAddress(address) provideInputViewModel() } - func didCloseYourWalletSelection() { + func yourWalletsDidClose(selectionView _: YourWalletsPresentationProtocol) { view?.didReceiveYourWallets(state: .inactive) } } diff --git a/novawallet/Modules/Transfer/TransferSetup/TransferSetupPresenter.swift b/novawallet/Modules/Transfer/TransferSetup/TransferSetupPresenter.swift index 6ba61552a2..5b1784b358 100644 --- a/novawallet/Modules/Transfer/TransferSetup/TransferSetupPresenter.swift +++ b/novawallet/Modules/Transfer/TransferSetup/TransferSetupPresenter.swift @@ -512,15 +512,20 @@ extension TransferSetupPresenter: AddressScanDelegate { } extension TransferSetupPresenter: YourWalletsDelegate { - func didSelectYourWallet(address: AccountAddress) { - wireframe.hideYourWallets(from: view) + func yourWallets( + selectionView: YourWalletsPresentationProtocol, + didSelect address: AccountAddress + ) { + wireframe.hideYourWallets(from: selectionView) childPresenter?.changeRecepient(address: address) view?.changeYourWalletsViewState(.inactive) recipientAddress = .address(address) } - func didCloseYourWalletSelection() { + func yourWalletsDidClose( + selectionView _: YourWalletsPresentationProtocol + ) { view?.changeYourWalletsViewState(.inactive) } } diff --git a/novawallet/Modules/YourWallets/YourWalletsPresenter.swift b/novawallet/Modules/YourWallets/YourWalletsPresenter.swift index 0f38c80095..fc988a1309 100644 --- a/novawallet/Modules/YourWallets/YourWalletsPresenter.swift +++ b/novawallet/Modules/YourWallets/YourWalletsPresenter.swift @@ -161,11 +161,19 @@ extension YourWalletsPresenter: YourWalletsPresenterProtocol { func didSelect(viewModel: YourWalletsCellViewModel.CommonModel) { selectedAddress = viewModel.displayAddress.address updateSelectedCell() - delegate?.didSelectYourWallet(address: viewModel.displayAddress.address) + + if let view { + delegate?.yourWallets( + selectionView: view, + didSelect: viewModel.displayAddress.address + ) + } } func viewWillDisappear() { - delegate?.didCloseYourWalletSelection() + if let view { + delegate?.yourWalletsDidClose(selectionView: view) + } } } diff --git a/novawallet/Modules/YourWallets/YourWalletsProtocols.swift b/novawallet/Modules/YourWallets/YourWalletsProtocols.swift index 974617bc69..5f303197f3 100644 --- a/novawallet/Modules/YourWallets/YourWalletsProtocols.swift +++ b/novawallet/Modules/YourWallets/YourWalletsProtocols.swift @@ -1,6 +1,8 @@ import UIKit -protocol YourWalletsViewProtocol: ControllerBackedProtocol { +protocol YourWalletsPresentationProtocol: ControllerBackedProtocol {} + +protocol YourWalletsViewProtocol: YourWalletsPresentationProtocol { func update(viewModel: [YourWalletsViewSectionModel]) func update(header: String) func calculateEstimatedHeight(sections: Int, items: Int) -> CGFloat @@ -13,8 +15,8 @@ protocol YourWalletsPresenterProtocol: AnyObject { } protocol YourWalletsDelegate: AnyObject { - func didSelectYourWallet(address: AccountAddress) - func didCloseYourWalletSelection() + func yourWallets(selectionView: YourWalletsPresentationProtocol, didSelect address: AccountAddress) + func yourWalletsDidClose(selectionView: YourWalletsPresentationProtocol) } extension YourWalletsDelegate {