Skip to content

Commit

Permalink
Merge branch 'missaligned-bottoms-on-redemption-voucher-311'
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Sep 13, 2023
2 parents d7e598d + 545b188 commit 6e7e58c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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>"; };
Expand Down Expand Up @@ -2623,6 +2625,7 @@
F09A29782A9F8A9B00EA3B6F /* LogoutDialogueView.swift */,
F09A297A2A9F8A9B00EA3B6F /* RedeemVoucherContentView.swift */,
F09A297F2A9F8AD200EA3B6F /* RedeemVoucherInteractor.swift */,
F0C6A8422AB08E54000777A8 /* RedeemVoucherViewConfiguration.swift */,
F028A5692A34D4E700C0CAA3 /* RedeemVoucherViewController.swift */,
F09A29792A9F8A9B00EA3B6F /* VoucherTextField.swift */,
);
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion ios/MullvadVPN/Coordinators/ProfileVoucherCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ final class RedeemVoucherContentView: UIView {

private var keyboardResponder: AutomaticKeyboardResponder?
private var bottomsOfButtonsConstraint: NSLayoutConstraint?
private let configuration: RedeemVoucherViewConfiguration

// MARK: - public

Expand Down Expand Up @@ -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()
}
Expand All @@ -245,7 +248,7 @@ final class RedeemVoucherContentView: UIView {
configureUI()
addButtonHandlers()
updateUI()
addKeyboardResponder()
addKeyboardResponderIfNeeded()
addObservers()
}

Expand Down Expand Up @@ -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()
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6e7e58c

Please sign in to comment.