summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMojgan <Mojgan.jelodar@codic.se>2023-09-12 17:08:49 +0200
committerMojgan <Mojgan.jelodar@codic.se>2023-09-12 17:08:49 +0200
commit545b188b7fb0c0a9542e99c47be4195328737921 (patch)
tree4930375e07a76dc5a229c89534fd7d16284550e3
parentd7e598d6ff5993096cbc82c33d6d6d850b976429 (diff)
downloadmullvadvpn-545b188b7fb0c0a9542e99c47be4195328737921.tar.xz
mullvadvpn-545b188b7fb0c0a9542e99c47be4195328737921.zip
fix misalignment buttons at the bottom of voucher view
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj4
-rw-r--r--ios/MullvadVPN/Coordinators/CreateAccountVoucherCoordinator.swift6
-rw-r--r--ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift5
-rw-r--r--ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift2
-rw-r--r--ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift13
-rw-r--r--ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewConfiguration.swift12
-rw-r--r--ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift8
7 files changed, 40 insertions, 10 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index 1345a4e32d..7aab178ca5 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -495,6 +495,7 @@
F09A297D2A9F8A9B00EA3B6F /* RedeemVoucherContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F09A297A2A9F8A9B00EA3B6F /* RedeemVoucherContentView.swift */; };
F09A29822A9F8AD200EA3B6F /* RedeemVoucherInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = F09A297F2A9F8AD200EA3B6F /* RedeemVoucherInteractor.swift */; };
F0C2AEFD2A0BB5CC00986207 /* NotificationProviderIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0C2AEFC2A0BB5CC00986207 /* NotificationProviderIdentifier.swift */; };
+ F0C6A8432AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0C6A8422AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift */; };
F0C6FA812A66E23300F521F0 /* DeleteAccountOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0C6FA802A66E23300F521F0 /* DeleteAccountOperation.swift */; };
F0C6FA852A6A733700F521F0 /* InAppPurchaseInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0C6FA842A6A733700F521F0 /* InAppPurchaseInteractor.swift */; };
F0DA87472A9CB9A2006044F1 /* AccountExpiryRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0DA87462A9CB9A2006044F1 /* AccountExpiryRow.swift */; };
@@ -1392,6 +1393,7 @@
F09A297A2A9F8A9B00EA3B6F /* RedeemVoucherContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedeemVoucherContentView.swift; sourceTree = "<group>"; };
F09A297F2A9F8AD200EA3B6F /* RedeemVoucherInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedeemVoucherInteractor.swift; sourceTree = "<group>"; };
F0C2AEFC2A0BB5CC00986207 /* NotificationProviderIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationProviderIdentifier.swift; sourceTree = "<group>"; };
+ F0C6A8422AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedeemVoucherViewConfiguration.swift; sourceTree = "<group>"; };
F0C6FA802A66E23300F521F0 /* DeleteAccountOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteAccountOperation.swift; sourceTree = "<group>"; };
F0C6FA822A6A729500F521F0 /* InAppPurchaseCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppPurchaseCoordinator.swift; sourceTree = "<group>"; };
F0C6FA842A6A733700F521F0 /* InAppPurchaseInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppPurchaseInteractor.swift; sourceTree = "<group>"; };
@@ -2623,6 +2625,7 @@
F09A29782A9F8A9B00EA3B6F /* LogoutDialogueView.swift */,
F09A297A2A9F8A9B00EA3B6F /* RedeemVoucherContentView.swift */,
F09A297F2A9F8AD200EA3B6F /* RedeemVoucherInteractor.swift */,
+ F0C6A8422AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift */,
F028A5692A34D4E700C0CAA3 /* RedeemVoucherViewController.swift */,
F09A29792A9F8A9B00EA3B6F /* VoucherTextField.swift */,
);
@@ -3931,6 +3934,7 @@
F0E8CC0A2A4EE127007ED3B4 /* SetupAccountCompletedContentView.swift in Sources */,
581DA2752A1E283E0046ED47 /* WgKeyRotation.swift in Sources */,
7A83C4022A57FAA800DFB83A /* SettingsDNSInfoCell.swift in Sources */,
+ F0C6A8432AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift in Sources */,
06410DFE292CE18F00AFC18C /* KeychainSettingsStore.swift in Sources */,
58FB865526E8BF3100F188BC /* StorePaymentManagerError.swift in Sources */,
58FD5BF42428C67600112C88 /* InAppPurchaseButton.swift in Sources */,
diff --git a/ios/MullvadVPN/Coordinators/CreateAccountVoucherCoordinator.swift b/ios/MullvadVPN/Coordinators/CreateAccountVoucherCoordinator.swift
index 2234af0b03..1407c61808 100644
--- a/ios/MullvadVPN/Coordinators/CreateAccountVoucherCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/CreateAccountVoucherCoordinator.swift
@@ -25,7 +25,11 @@ public class CreateAccountVoucherCoordinator: Coordinator {
) {
self.navigationController = navigationController
self.interactor = interactor
- viewController = RedeemVoucherViewController(interactor: interactor)
+
+ viewController = RedeemVoucherViewController(
+ configuration: RedeemVoucherViewConfiguration(adjustViewWhenKeyboardAppears: true),
+ interactor: interactor
+ )
}
func start() {
diff --git a/ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift b/ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift
index 02aed1dea2..8e166985b9 100644
--- a/ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift
@@ -23,7 +23,10 @@ final class ProfileVoucherCoordinator: Coordinator, Presentable {
interactor: RedeemVoucherInteractor
) {
self.navigationController = navigationController
- viewController = RedeemVoucherViewController(interactor: interactor)
+ viewController = RedeemVoucherViewController(
+ configuration: RedeemVoucherViewConfiguration(adjustViewWhenKeyboardAppears: false),
+ interactor: interactor
+ )
}
var presentedViewController: UIViewController {
diff --git a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
index e3fce9f69b..05ef64925a 100644
--- a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
+++ b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
@@ -359,7 +359,7 @@ class AccountDeletionContentView: UIView {
targetView: self,
handler: { [weak self] _, offset in
guard let self else { return }
- self.bottomsOfButtonsConstraint?.constant = self.accountTextField.isFirstResponder ? -offset : 0
+ self.bottomsOfButtonsConstraint?.constant = isEditing ? -offset : 0
self.layoutIfNeeded()
self.scrollView.flashScrollIndicators()
}
diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift
index 650ced232b..f5061d570d 100644
--- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift
+++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift
@@ -197,6 +197,7 @@ final class RedeemVoucherContentView: UIView {
private var keyboardResponder: AutomaticKeyboardResponder?
private var bottomsOfButtonsConstraint: NSLayoutConstraint?
+ private let configuration: RedeemVoucherViewConfiguration
// MARK: - public
@@ -230,12 +231,14 @@ final class RedeemVoucherContentView: UIView {
}
}
- init() {
+ init(configuration: RedeemVoucherViewConfiguration) {
+ self.configuration = configuration
super.init(frame: .zero)
commonInit()
}
required init?(coder: NSCoder) {
+ self.configuration = RedeemVoucherViewConfiguration(adjustViewWhenKeyboardAppears: true)
super.init(coder: coder)
commonInit()
}
@@ -245,7 +248,7 @@ final class RedeemVoucherContentView: UIView {
configureUI()
addButtonHandlers()
updateUI()
- addKeyboardResponder()
+ addKeyboardResponderIfNeeded()
addObservers()
}
@@ -331,13 +334,13 @@ final class RedeemVoucherContentView: UIView {
updateUI()
}
- private func addKeyboardResponder() {
+ private func addKeyboardResponderIfNeeded() {
+ guard configuration.adjustViewWhenKeyboardAppears else { return }
keyboardResponder = AutomaticKeyboardResponder(
targetView: self,
handler: { [weak self] _, offset in
guard let self else { return }
- guard self.textField.isFirstResponder else { return }
- self.bottomsOfButtonsConstraint?.constant = -offset
+ self.bottomsOfButtonsConstraint?.constant = isEditing ? -offset : 0
self.layoutIfNeeded()
}
)
diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewConfiguration.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewConfiguration.swift
new file mode 100644
index 0000000000..32052230da
--- /dev/null
+++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewConfiguration.swift
@@ -0,0 +1,12 @@
+//
+// RedeemVoucherViewConfiguration.swift
+// MullvadVPN
+//
+// Created by Mojgan on 2023-09-12.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+struct RedeemVoucherViewConfiguration {
+ let adjustViewWhenKeyboardAppears: Bool
+}
diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift
index f7921f2c6e..9195e5c5d4 100644
--- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift
+++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift
@@ -19,12 +19,16 @@ protocol RedeemVoucherViewControllerDelegate: AnyObject {
}
class RedeemVoucherViewController: UIViewController, UINavigationControllerDelegate, RootContainment {
- private let contentView = RedeemVoucherContentView()
+ private let contentView: RedeemVoucherContentView
private var interactor: RedeemVoucherInteractor
weak var delegate: RedeemVoucherViewControllerDelegate?
- init(interactor: RedeemVoucherInteractor) {
+ init(
+ configuration: RedeemVoucherViewConfiguration,
+ interactor: RedeemVoucherInteractor
+ ) {
+ self.contentView = RedeemVoucherContentView(configuration: configuration)
self.interactor = interactor
super.init(nibName: nil, bundle: nil)
}