diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2023-09-04 13:46:51 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2023-09-04 13:46:51 +0200 |
| commit | 0742ff472e1e6460f405ab6f5f08d189b01928c0 (patch) | |
| tree | d9f3e4ec69ea59fe78e37d70e042f4717a9270be | |
| parent | d6e0c53347254ea919685cf8af6380ff332dad5c (diff) | |
| parent | 00875dd373d82be705249fb59a608408d697983a (diff) | |
| download | mullvadvpn-0742ff472e1e6460f405ab6f5f08d189b01928c0.tar.xz mullvadvpn-0742ff472e1e6460f405ab6f5f08d189b01928c0.zip | |
Merge branch 'crash-in-during-account-deletion-ios-295'
4 files changed, 24 insertions, 31 deletions
diff --git a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift index 7884904c06..bfdfea5892 100644 --- a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift +++ b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift @@ -187,9 +187,17 @@ class AccountDeletionContentView: UIView { } } - var isEditing = false { - didSet { - _ = isEditing ? accountTextField.becomeFirstResponder() : accountTextField.resignFirstResponder() + var isEditing: Bool { + get { + accountTextField.isEditing + } + set { + guard accountTextField.isFirstResponder != newValue else { return } + if newValue { + accountTextField.becomeFirstResponder() + } else { + accountTextField.resignFirstResponder() + } } } diff --git a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewController.swift b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewController.swift index 6469cb53ee..8fce5224aa 100644 --- a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewController.swift +++ b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewController.swift @@ -42,12 +42,12 @@ class AccountDeletionViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - enableEditing() + contentView.isEditing = true } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - disableEditing() + contentView.isEditing = false } override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { @@ -55,16 +55,6 @@ class AccountDeletionViewController: UIViewController { super.viewWillTransition(to: size, with: coordinator) } - private func enableEditing() { - guard !contentView.isEditing else { return } - contentView.isEditing = true - } - - private func disableEditing() { - guard contentView.isEditing else { return } - contentView.isEditing = false - } - private func configureUI() { view.addConstrainedSubviews([contentView]) { contentView.pinEdgesToSuperview(.all()) @@ -95,6 +85,7 @@ extension AccountDeletionViewController: AccountDeletionContentViewDelegate { func didTapDeleteButton(contentView: AccountDeletionContentView, button: AppButton) { switch interactor.validate(input: contentView.lastPartOfAccountNumber) { case let .success(accountNumber): + contentView.isEditing = false submit(accountNumber: accountNumber) case let .failure(error): contentView.state = .failure(error) diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift index b31b5c4999..a24942bf3a 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift @@ -192,9 +192,13 @@ final class RedeemVoucherContentView: UIView { } } - var isEditing = false { - didSet { - if isEditing { + var isEditing: Bool { + get { + textField.isEditing + } + set { + guard textField.isFirstResponder != newValue else { return } + if newValue { textField.becomeFirstResponder() } else { textField.resignFirstResponder() diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift index d5aa957ee6..cf96e55ae8 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift @@ -64,31 +64,21 @@ class RedeemVoucherViewController: UIViewController, UINavigationControllerDeleg override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - enableEditing() + contentView.isEditing = true } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - disableEditing() + contentView.isEditing = false } override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { - self.contentView.isEditing = false + contentView.isEditing = false super.viewWillTransition(to: size, with: coordinator) } // MARK: - private functions - private func enableEditing() { - guard !self.contentView.isEditing else { return } - self.contentView.isEditing = true - } - - private func disableEditing() { - guard contentView.isEditing else { return } - self.contentView.isEditing = false - } - private func addActions() { contentView.redeemAction = { [weak self] code in self?.submit(code: code) |
