Skip to content

Commit d19440a

Browse files
authored
Merge pull request #1957 from MixinNetwork/bugfix/wallet
Fix view wallet in delete account confirmation
2 parents 1d5be24 + 671fb9e commit d19440a

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

Mixin/UserInterface/Controllers/Setting/DeleteAccountSettingViewController.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,24 @@ extension DeleteAccountSettingViewController {
129129

130130
private func presentDeleteAccountHintWindow(assets: [MixinTokenItem]) {
131131
let window = DeleteAccountHintWindow.instance()
132-
window.onViewWallet = presentWallet
133-
window.onContinue = presentVerificationConfirmation
132+
window.onViewWallet = { [weak self] in
133+
self?.presentWallet()
134+
}
135+
window.onContinue = { [weak self] in
136+
self?.presentVerificationConfirmation()
137+
}
134138
window.render(assets: assets)
135139
window.presentPopupControllerAnimated()
136140
}
137141

138142
private func presentWallet() {
139-
let wallet = WalletViewController()
140-
navigationController?.pushViewController(wallet, animated: true)
143+
UIApplication.homeNavigationController?.popToRootViewController(animated: false)
144+
if let tabBarController = UIApplication.homeContainerViewController?.homeTabBarController {
145+
tabBarController.switchTo(child: .wallet)
146+
if let container = tabBarController.selectedViewController as? WalletContainerViewController {
147+
container.switchToWalletSummary(animated: false)
148+
}
149+
}
141150
}
142151

143152
private func requestVerificationCode(for phone: String, captchaToken token: CaptchaToken?) {

Mixin/UserInterface/Controllers/Wallet/WalletContainerViewController.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class WalletContainerViewController: UIViewController {
2323
ConcurrentJobQueue.shared.addJob(job: job)
2424
}
2525

26-
func switchToWalletSummary() {
26+
func switchToWalletSummary(animated: Bool) {
2727
guard let wallet = viewController as? WalletViewController else {
2828
return
2929
}
@@ -41,12 +41,25 @@ final class WalletContainerViewController: UIViewController {
4141
view.addSubview(summary.view)
4242
summary.didMove(toParent: self)
4343

44-
UIView.animate(withDuration: 0.5, delay: 0, options: .overdampedCurve) {
44+
let animation = {
4545
summary.view.frame = self.view.bounds
46-
} completion: { _ in
46+
}
47+
let completion = { (finished: Bool) in
4748
self.remove(child: wallet)
4849
self.viewController = summary
4950
}
51+
if animated {
52+
UIView.animate(
53+
withDuration: 0.5,
54+
delay: 0,
55+
options: .overdampedCurve,
56+
animations: animation,
57+
completion: completion
58+
)
59+
} else {
60+
animation()
61+
completion(true)
62+
}
5063
}
5164

5265
func switchToWallet(_ wallet: Wallet) {

Mixin/UserInterface/Controllers/Wallet/WalletViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class WalletViewController: UIViewController, MnemonicsBackupChecking {
5454

5555
@IBAction func switchFromWallets(_ sender: Any) {
5656
if let parent = parent as? WalletContainerViewController {
57-
parent.switchToWalletSummary()
57+
parent.switchToWalletSummary(animated: true)
5858
}
5959
}
6060

0 commit comments

Comments
 (0)