summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorMojgan <Mojgan.jelodar@codic.se>2023-09-04 12:55:02 +0200
committerAndrej Mihajlov <and@mullvad.net>2023-09-04 13:46:09 +0200
commit00875dd373d82be705249fb59a608408d697983a (patch)
treed9f3e4ec69ea59fe78e37d70e042f4717a9270be /ios
parentd6e0c53347254ea919685cf8af6380ff332dad5c (diff)
downloadmullvadvpn-00875dd373d82be705249fb59a608408d697983a.tar.xz
mullvadvpn-00875dd373d82be705249fb59a608408d697983a.zip
Fix UIKit nagging regarding to present alert top of keyboard
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift14
-rw-r--r--ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewController.swift15
-rw-r--r--ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift10
-rw-r--r--ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift16
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)