From d45ce90b7e11270ac156a3f2696a98226dfe596e Mon Sep 17 00:00:00 2001 From: fanyu Date: Mon, 27 Sep 2021 17:17:16 +0800 Subject: [PATCH 1/3] Add stranger transfer hint --- Mixin.xcodeproj/project.pbxproj | 14 +- Mixin/Resources/en.lproj/Localizable.strings | 3 + .../zh-Hans.lproj/Localizable.strings | 3 + ...ndConfirmationSettingsViewController.swift | 11 ++ .../Wallet/TransferOutViewController.swift | 52 +++++-- .../Windows/StrangerTransferHintWindow.swift | 33 ++++ .../Windows/StrangerTransferHintWindow.xib | 145 ++++++++++++++++++ Mixin/UserInterface/Windows/UrlWindow.swift | 2 +- .../AppGroupUserDefaults+User.swift | 4 + 9 files changed, 248 insertions(+), 19 deletions(-) create mode 100644 Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift create mode 100644 Mixin/UserInterface/Windows/StrangerTransferHintWindow.xib diff --git a/Mixin.xcodeproj/project.pbxproj b/Mixin.xcodeproj/project.pbxproj index 0d7959cb2e..248270601b 100644 --- a/Mixin.xcodeproj/project.pbxproj +++ b/Mixin.xcodeproj/project.pbxproj @@ -562,6 +562,8 @@ 7BFE47E52284530200FC4379 /* PeerHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFE47E42284530200FC4379 /* PeerHeaderView.swift */; }; 7BFE47E722845DE100FC4379 /* MessageReceiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFE47E622845DE100FC4379 /* MessageReceiver.swift */; }; 7C0D997F26CA62CD00356655 /* StaticAudioMessagePlayingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0D997E26CA62CD00356655 /* StaticAudioMessagePlayingManager.swift */; }; + 7C0E16A127016301002FC718 /* StrangerTransferHintWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0E16A027016301002FC718 /* StrangerTransferHintWindow.swift */; }; + 7C0E16A3270163EB002FC718 /* StrangerTransferHintWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7C0E16A2270163EB002FC718 /* StrangerTransferHintWindow.xib */; }; 7C14CFC126CA35CF0094AF4A /* StaticMessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C14CFBF26CA35CF0094AF4A /* StaticMessagesViewController.swift */; }; 7C14CFC226CA35CF0094AF4A /* StaticMessagesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7C14CFC026CA35CF0094AF4A /* StaticMessagesView.xib */; }; 7C5823D5268966A1003AA142 /* HomeAppsFolderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C5823D4268966A1003AA142 /* HomeAppsFolderViewController.swift */; }; @@ -1538,6 +1540,8 @@ 7BFE47E42284530200FC4379 /* PeerHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerHeaderView.swift; sourceTree = ""; }; 7BFE47E622845DE100FC4379 /* MessageReceiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageReceiver.swift; sourceTree = ""; }; 7C0D997E26CA62CD00356655 /* StaticAudioMessagePlayingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaticAudioMessagePlayingManager.swift; sourceTree = ""; }; + 7C0E16A027016301002FC718 /* StrangerTransferHintWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StrangerTransferHintWindow.swift; sourceTree = ""; }; + 7C0E16A2270163EB002FC718 /* StrangerTransferHintWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StrangerTransferHintWindow.xib; sourceTree = ""; }; 7C14CFBF26CA35CF0094AF4A /* StaticMessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaticMessagesViewController.swift; sourceTree = ""; }; 7C14CFC026CA35CF0094AF4A /* StaticMessagesView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StaticMessagesView.xib; sourceTree = ""; }; 7C5823D4268966A1003AA142 /* HomeAppsFolderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAppsFolderViewController.swift; sourceTree = ""; }; @@ -2819,6 +2823,8 @@ DFDD89E822C4B8E600128991 /* DepositTipWindow.xib */, DF846CD823694A2E00AA1197 /* MultisigUsersWindow.swift */, DF846CDA23694A4900AA1197 /* MultisigUsersWindow.xib */, + 7C0E16A027016301002FC718 /* StrangerTransferHintWindow.swift */, + 7C0E16A2270163EB002FC718 /* StrangerTransferHintWindow.xib */, ); path = Windows; sourceTree = ""; @@ -3814,6 +3820,7 @@ 7BF19C20241D40FA00B192D5 /* LocationSearchView.xib in Resources */, 7B8BB590234F36C000991ACB /* Colors.xcassets in Resources */, 94B8D18A266E41D300F43CBB /* DatabaseDiagnosticView.xib in Resources */, + 7C0E16A3270163EB002FC718 /* StrangerTransferHintWindow.xib in Resources */, 7BFCB7762419FC5B00E7BC43 /* LocationCell.xib in Resources */, DFD294491FA7145F00FADAAD /* Contact.storyboard in Resources */, 94E8913925C019F000F1E5D4 /* Pods-Mixin-acknowledgements.plist in Resources */, @@ -4056,7 +4063,7 @@ outputFileListPaths = ( ); outputPaths = ( - "$SRCROOT/MixinNotificationService/R.generated.swift", + $SRCROOT/MixinNotificationService/R.generated.swift, ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -4153,7 +4160,7 @@ outputFileListPaths = ( ); outputPaths = ( - "$SRCROOT/MixinShare/R.generated.swift", + $SRCROOT/MixinShare/R.generated.swift, ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -4173,7 +4180,7 @@ outputFileListPaths = ( ); outputPaths = ( - "$SRCROOT/R.generated.swift", + $SRCROOT/R.generated.swift, ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -4702,6 +4709,7 @@ 7BB5250324160F3D0060DAE1 /* LocationPreviewViewController.swift in Sources */, 7BDEE5C71FA72EB9004CB189 /* SearchViewController.swift in Sources */, 7BF4047B2048F008004C54E4 /* VerifyPinNavigationController.swift in Sources */, + 7C0E16A127016301002FC718 /* StrangerTransferHintWindow.swift in Sources */, DF2A245E1FCC5D15003A8C1E /* GroupAddMemberCell.swift in Sources */, DFB6CE1E23C4805B00FB6615 /* KeychainExtension.swift in Sources */, 7B2E3E5A1FA0816D00DDDDEB /* LoginContinueButton.swift in Sources */, diff --git a/Mixin/Resources/en.lproj/Localizable.strings b/Mixin/Resources/en.lproj/Localizable.strings index f95f29e849..a16d6cca74 100644 --- a/Mixin/Resources/en.lproj/Localizable.strings +++ b/Mixin/Resources/en.lproj/Localizable.strings @@ -589,6 +589,7 @@ "wallet_face_id" = "Face ID"; "wallet_header_recent_searches" = "Recent searches"; "wallet_header_trending" = "Trending"; +"wallet_transfer_stranger_hint" = "Mixin ID %@ is not in your contacts,please check if the payee is correct. If you transfer to the wrong person, assets will not be recovered!"; // Transaction "transaction_title" = "Transaction"; @@ -838,6 +839,8 @@ "setting_transfer_large_summary" = "Display confirmation dialog when transfer greater than or equal to %@."; "setting_duplicate_transfer_title" = "Duplicate Transfer Confirmation"; "setting_duplicate_transfer_summary" = "Display confirmation dialog when you transfer the same amount to the same person within 6 hours."; +"setting_stranger_transfer_title" = "Stranger Transfer Confirmation"; +"setting_stranger_transfer_summary" = "Display confirmation dialog when you transfer to a stranger"; "setting_backup_title" = "Chat Backup"; "setting_backup_now" = "Back Up Now"; "setting_backing" = "Backing Up..."; diff --git a/Mixin/Resources/zh-Hans.lproj/Localizable.strings b/Mixin/Resources/zh-Hans.lproj/Localizable.strings index fac093634a..b21d79515c 100644 --- a/Mixin/Resources/zh-Hans.lproj/Localizable.strings +++ b/Mixin/Resources/zh-Hans.lproj/Localizable.strings @@ -588,6 +588,7 @@ "wallet_store_encrypted_pin_tip" = "启用%@支付?"; "wallet_touch_id" = "指纹"; "wallet_face_id" = "面容"; +"wallet_transfer_stranger_hint" = "Mixin ID %@ 不是你的联系人,请确认收款人是否正确。如果您转错人,资产将无法追回!"; // Transaction "transaction_title" = "交易详情"; @@ -839,6 +840,8 @@ "setting_transfer_large_summary" = "当转账金额大于或等于 %@ 时显示确认弹窗"; "setting_duplicate_transfer_title" = "重复转账确认"; "setting_duplicate_transfer_summary" = "当你在 6 个小时内给相同的人转相同的金额时显示确认弹窗"; +"setting_stranger_transfer_title" = "陌生人转账确认"; +"setting_stranger_transfer_summary" = "当你给陌生人转账时显示确认弹窗"; "setting_backup_title" = "聊天记录备份"; "setting_backup_now" = "立即备份"; "setting_backing" = "正在备份..."; diff --git a/Mixin/UserInterface/Controllers/Setting/NotificationAndConfirmationSettingsViewController.swift b/Mixin/UserInterface/Controllers/Setting/NotificationAndConfirmationSettingsViewController.swift index 842d7f0586..f6d930c2ef 100644 --- a/Mixin/UserInterface/Controllers/Setting/NotificationAndConfirmationSettingsViewController.swift +++ b/Mixin/UserInterface/Controllers/Setting/NotificationAndConfirmationSettingsViewController.swift @@ -7,6 +7,8 @@ class NotificationAndConfirmationSettingsViewController: SettingsTableViewContro accessory: .switch(isOn: showsMessagePreview)) private lazy var duplicateTransferRow = SettingsRow(title: R.string.localizable.setting_duplicate_transfer_title(), accessory: .switch(isOn: duplicateTransferConfirmation)) + private lazy var strangerTransferRow = SettingsRow(title: R.string.localizable.setting_stranger_transfer_title(), + accessory: .switch(isOn: strangerTransferConfirmation)) private lazy var dataSource = SettingsDataSource(sections: [ SettingsSection(footer: R.string.localizable.setting_notification_message_preview_description(), rows: [ @@ -16,6 +18,9 @@ class NotificationAndConfirmationSettingsViewController: SettingsTableViewContro makeTransferConfirmationThresholdSection(), SettingsSection(footer: R.string.localizable.setting_duplicate_transfer_summary(), rows: [ duplicateTransferRow + ]), + SettingsSection(footer: R.string.localizable.setting_stranger_transfer_summary(), rows: [ + strangerTransferRow ]) ]) @@ -33,6 +38,10 @@ class NotificationAndConfirmationSettingsViewController: SettingsTableViewContro AppGroupUserDefaults.User.duplicateTransferConfirmation } + private var strangerTransferConfirmation: Bool { + AppGroupUserDefaults.User.strangerTransferConfirmation + } + private var transferNotificationThreshold: String { let threshold = LoginManager.shared.account?.transfer_notification_threshold ?? 0 return NumberFormatter.localizedString(from: NSNumber(value: threshold), number: .decimal) @@ -69,6 +78,8 @@ class NotificationAndConfirmationSettingsViewController: SettingsTableViewContro AppGroupUserDefaults.User.showMessagePreviewInNotification = isOn } else if row == duplicateTransferRow { AppGroupUserDefaults.User.duplicateTransferConfirmation = isOn + } else if row == strangerTransferRow { + AppGroupUserDefaults.User.strangerTransferConfirmation = isOn } } diff --git a/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift b/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift index 90d4b61c1e..af678a0369 100644 --- a/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift +++ b/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift @@ -39,6 +39,7 @@ class TransferOutViewController: KeyboardBasedLayoutViewController { private var chainAsset: AssetItem? private var isInputAssetAmount = true private var adjustBottomConstraintWhenKeyboardFrameChanges = true + private var ignoreStrangerTransferConfirmation = true private weak var payWindowIfLoaded: PayWindow? @@ -210,25 +211,45 @@ class TransferOutViewController: KeyboardBasedLayoutViewController { switch opponent! { case .contact(let user): - DispatchQueue.global().async { [weak self] in - let action: PayWindow.PinAction = .transfer(trackId: traceId, user: user, fromWeb: false) - PayWindow.checkPay(traceId: traceId, asset: asset, action: action, opponentId: user.userId, amount: amount, fiatMoneyAmount: fiatMoneyAmount, memo: memo, fromWeb: false) { (canPay, errorMsg) in - DispatchQueue.main.async { - guard let weakSelf = self else { - return - } - weakSelf.continueButton.isBusy = false - if canPay { - payWindow.render(asset: asset, action: action, amount: amount, memo: memo, fiatMoneyAmount: fiatMoneyAmount, textfield: weakSelf.amountTextField).presentPopupControllerAnimated() - } else { - weakSelf.amountTextField.becomeFirstResponder() - if let error = errorMsg { - showAutoHiddenHud(style: .error, text: error) + let checkPay = { + DispatchQueue.global().async { [weak self] in + let action: PayWindow.PinAction = .transfer(trackId: traceId, user: user, fromWeb: false) + PayWindow.checkPay(traceId: traceId, asset: asset, action: action, opponentId: user.userId, amount: amount, fiatMoneyAmount: fiatMoneyAmount, memo: memo, fromWeb: false) { (canPay, errorMsg) in + DispatchQueue.main.async { + guard let weakSelf = self else { + return + } + weakSelf.continueButton.isBusy = false + if canPay { + payWindow.render(asset: asset, action: action, amount: amount, memo: memo, fiatMoneyAmount: fiatMoneyAmount, textfield: weakSelf.amountTextField).presentPopupControllerAnimated() + } else { + weakSelf.amountTextField.becomeFirstResponder() + if let error = errorMsg { + showAutoHiddenHud(style: .error, text: error) + } } } } } } + let isStranger = user.relationship == Relationship.STRANGER.rawValue + let strangerTransferConfirmation = AppGroupUserDefaults.User.strangerTransferConfirmation + let transferOverTenDollars = asset.priceUsd.doubleValue * amount.doubleValue >= 10 + if !ignoreStrangerTransferConfirmation && isStranger && strangerTransferConfirmation && transferOverTenDollars { + let window = StrangerTransferHintWindow.instance(userItem: user) + window.continueHandler = { + checkPay() + } + window.cancelHandler = { + DispatchQueue.main.async { + self.continueButton.isBusy = false + self.amountTextField.becomeFirstResponder() + } + } + window.presentPopupControllerAnimated() + } else { + checkPay() + } case .address(let address): DispatchQueue.global().async { [weak self] in guard let chainAsset = chainAsset ?? AssetDAO.shared.getAsset(assetId: asset.chainId) else { @@ -411,10 +432,11 @@ class TransferOutViewController: KeyboardBasedLayoutViewController { amountTextField.reloadInputViews() } - class func instance(asset: AssetItem?, type: Opponent) -> UIViewController { + class func instance(asset: AssetItem?, type: Opponent, ignoreStrangerTransferConfirmation: Bool = false) -> UIViewController { let vc = R.storyboard.wallet.send()! vc.opponent = type vc.asset = asset + vc.ignoreStrangerTransferConfirmation = ignoreStrangerTransferConfirmation let container = ContainerViewController.instance(viewController: vc, title: "") return container } diff --git a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift new file mode 100644 index 0000000000..c68bb582d9 --- /dev/null +++ b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift @@ -0,0 +1,33 @@ +import UIKit +import MixinServices + +final class StrangerTransferHintWindow: BottomSheetView { + + @IBOutlet weak var avatarImageView: AvatarImageView! + @IBOutlet weak var nameLabel: UILabel! + @IBOutlet weak var idLabel: UILabel! + @IBOutlet weak var hintLabel: LineHeightLabel! + + var continueHandler: (() -> Void)? + var cancelHandler: (() -> Void)? + + class func instance(userItem: UserItem) -> StrangerTransferHintWindow { + let window = R.nib.strangerTransferHintWindow(owner: self)! + window.avatarImageView.setImage(with: userItem) + window.nameLabel.text = userItem.fullName + window.idLabel.text = R.string.localizable.contact_identity_number(userItem.identityNumber) + window.hintLabel.text = R.string.localizable.wallet_transfer_stranger_hint(userItem.identityNumber) + return window + } + + @IBAction func continueAction(_ sender: Any) { + dismissPopupControllerAnimated() + continueHandler?() + } + + @IBAction func cancelAction(_ sender: Any) { + dismissPopupControllerAnimated() + cancelHandler?() + } + +} diff --git a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.xib b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.xib new file mode 100644 index 0000000000..bf3fa35408 --- /dev/null +++ b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.xib @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mixin/UserInterface/Windows/UrlWindow.swift b/Mixin/UserInterface/Windows/UrlWindow.swift index f30cabf41e..48aa302f3e 100644 --- a/Mixin/UserInterface/Windows/UrlWindow.swift +++ b/Mixin/UserInterface/Windows/UrlWindow.swift @@ -324,7 +324,7 @@ class UrlWindow { DispatchQueue.main.async { hud.hide() func push() { - let vc = TransferOutViewController.instance(asset: nil, type: .contact(user)) + let vc = TransferOutViewController.instance(asset: nil, type: .contact(user), ignoreStrangerTransferConfirmation: true) if clearNavigationStack { UIApplication.homeNavigationController?.pushViewController(withBackRoot: vc) } else { diff --git a/MixinServices/MixinServices/Foundation/User Defaults/AppGroupUserDefaults+User.swift b/MixinServices/MixinServices/Foundation/User Defaults/AppGroupUserDefaults+User.swift index 92549fe073..9e7b458135 100644 --- a/MixinServices/MixinServices/Foundation/User Defaults/AppGroupUserDefaults+User.swift +++ b/MixinServices/MixinServices/Foundation/User Defaults/AppGroupUserDefaults+User.swift @@ -24,6 +24,7 @@ extension AppGroupUserDefaults { case showMessagePreviewInNotification = "show_message_preview_in_notification" case duplicateTransferConfirmation = "duplicate_transfer_confirmation" + case strangerTransferConfirmation = "stranger_transfer_confirmation" case conversationDraft = "conversation_draft" case currentConversationId = "current_conversation_id" case reloadConversation = "reload_conversation" @@ -125,6 +126,9 @@ extension AppGroupUserDefaults { @Default(namespace: .user, key: Key.duplicateTransferConfirmation, defaultValue: true) public static var duplicateTransferConfirmation: Bool + @Default(namespace: .user, key: Key.strangerTransferConfirmation, defaultValue: true) + public static var strangerTransferConfirmation: Bool + @Default(namespace: .user, key: Key.conversationDraft, defaultValue: [:]) public static var conversationDraft: [String: String] From 634dde87f79f68d0bca930181bec9ec6db02ad2a Mon Sep 17 00:00:00 2001 From: fanyu Date: Mon, 27 Sep 2021 17:25:14 +0800 Subject: [PATCH 2/3] Handle background dismiss --- .../Windows/StrangerTransferHintWindow.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift index c68bb582d9..d003941349 100644 --- a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift +++ b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift @@ -11,6 +11,15 @@ final class StrangerTransferHintWindow: BottomSheetView { var continueHandler: (() -> Void)? var cancelHandler: (() -> Void)? + private var canDismiss = false + + override func dismissPopupControllerAnimated() { + guard canDismiss else { + return + } + super.dismissPopupControllerAnimated() + } + class func instance(userItem: UserItem) -> StrangerTransferHintWindow { let window = R.nib.strangerTransferHintWindow(owner: self)! window.avatarImageView.setImage(with: userItem) @@ -21,11 +30,13 @@ final class StrangerTransferHintWindow: BottomSheetView { } @IBAction func continueAction(_ sender: Any) { + canDismiss = true dismissPopupControllerAnimated() continueHandler?() } @IBAction func cancelAction(_ sender: Any) { + canDismiss = true dismissPopupControllerAnimated() cancelHandler?() } From 747b5116393fe200319b202cf01306260d79a1de Mon Sep 17 00:00:00 2001 From: fanyu Date: Tue, 28 Sep 2021 08:57:38 +0800 Subject: [PATCH 3/3] Fix --- Mixin/Resources/en.lproj/Localizable.strings | 2 +- .../Common/KeyboardBasedLayoutViewController.swift | 1 + .../Wallet/TransferOutViewController.swift | 12 ++++-------- .../Windows/StrangerTransferHintWindow.swift | 8 ++++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Mixin/Resources/en.lproj/Localizable.strings b/Mixin/Resources/en.lproj/Localizable.strings index a16d6cca74..73ae8a5f17 100644 --- a/Mixin/Resources/en.lproj/Localizable.strings +++ b/Mixin/Resources/en.lproj/Localizable.strings @@ -589,7 +589,7 @@ "wallet_face_id" = "Face ID"; "wallet_header_recent_searches" = "Recent searches"; "wallet_header_trending" = "Trending"; -"wallet_transfer_stranger_hint" = "Mixin ID %@ is not in your contacts,please check if the payee is correct. If you transfer to the wrong person, assets will not be recovered!"; +"wallet_transfer_stranger_hint" = "Mixin ID %@ is not in your contacts, please check if the payee is correct. If you transfer to the wrong person, assets will not be recovered!"; // Transaction "transaction_title" = "Transaction"; diff --git a/Mixin/UserInterface/Controllers/Common/KeyboardBasedLayoutViewController.swift b/Mixin/UserInterface/Controllers/Common/KeyboardBasedLayoutViewController.swift index 92f86df669..72c2ee2b96 100644 --- a/Mixin/UserInterface/Controllers/Common/KeyboardBasedLayoutViewController.swift +++ b/Mixin/UserInterface/Controllers/Common/KeyboardBasedLayoutViewController.swift @@ -61,6 +61,7 @@ class KeyboardBasedLayoutViewController: UIViewController { layout(for: frame) } else { UIView.performWithoutAnimation { + view.layoutIfNeeded() layout(for: frame) } } diff --git a/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift b/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift index af678a0369..39cb8d63e5 100644 --- a/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift +++ b/Mixin/UserInterface/Controllers/Wallet/TransferOutViewController.swift @@ -237,14 +237,10 @@ class TransferOutViewController: KeyboardBasedLayoutViewController { let transferOverTenDollars = asset.priceUsd.doubleValue * amount.doubleValue >= 10 if !ignoreStrangerTransferConfirmation && isStranger && strangerTransferConfirmation && transferOverTenDollars { let window = StrangerTransferHintWindow.instance(userItem: user) - window.continueHandler = { - checkPay() - } - window.cancelHandler = { - DispatchQueue.main.async { - self.continueButton.isBusy = false - self.amountTextField.becomeFirstResponder() - } + window.onContinue = checkPay + window.onCancel = { + self.continueButton.isBusy = false + self.amountTextField.becomeFirstResponder() } window.presentPopupControllerAnimated() } else { diff --git a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift index d003941349..dfe8db5e54 100644 --- a/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift +++ b/Mixin/UserInterface/Windows/StrangerTransferHintWindow.swift @@ -8,8 +8,8 @@ final class StrangerTransferHintWindow: BottomSheetView { @IBOutlet weak var idLabel: UILabel! @IBOutlet weak var hintLabel: LineHeightLabel! - var continueHandler: (() -> Void)? - var cancelHandler: (() -> Void)? + var onContinue: (() -> Void)? + var onCancel: (() -> Void)? private var canDismiss = false @@ -31,14 +31,14 @@ final class StrangerTransferHintWindow: BottomSheetView { @IBAction func continueAction(_ sender: Any) { canDismiss = true + onContinue?() dismissPopupControllerAnimated() - continueHandler?() } @IBAction func cancelAction(_ sender: Any) { canDismiss = true + onCancel?() dismissPopupControllerAnimated() - cancelHandler?() } }