From 6fff7f5bc54cd2c668d94e06c1c01174e63c5134 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Tue, 23 May 2023 10:48:24 +0200 Subject: [PATCH] fix(ad-hoc): code field duplicate views (#105) --- .../Cells/NativeAlternativePaymentMethodCodeInputCell.swift | 5 +++-- .../DesignSystem/Views/CodeTextField/CodeTextField.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Cells/NativeAlternativePaymentMethodCodeInputCell.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Cells/NativeAlternativePaymentMethodCodeInputCell.swift index c60dec28b..7dd80a048 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Cells/NativeAlternativePaymentMethodCodeInputCell.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Cells/NativeAlternativePaymentMethodCodeInputCell.swift @@ -55,9 +55,10 @@ final class NativeAlternativePaymentMethodCodeInputCell: UICollectionViewCell, N // MARK: - Private Methods private func initialize(length: Int) { - if let item, item.length != length { - codeTextField.removeFromSuperview() + if let codeTextField, codeTextField.length == length { + return } + codeTextField?.removeFromSuperview() let codeTextField = CodeTextField(length: length) codeTextField.accessibilityIdentifier = Constants.accessibilityIdentifier codeTextField.delegate = self diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift index 2ec62e04c..aad1f91b1 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift @@ -28,6 +28,9 @@ final class CodeTextField: UIControl, UITextInput { fatalError("init(coder:) has not been implemented") } + /// Text field length. + let length: Int + weak var delegate: CodeTextFieldDelegate? var text: String? { @@ -341,8 +344,6 @@ final class CodeTextField: UIControl, UITextInput { // MARK: - Private Properties - private let length: Int - private lazy var contentView: UIView = { let view = UIView() view.backgroundColor = .clear