From e11072312e5cd2aa9ce18eb212643994c6725dd0 Mon Sep 17 00:00:00 2001 From: Tomasz Regdos Date: Wed, 2 Oct 2024 11:48:08 +0200 Subject: [PATCH] Hidden card data on screenshot (#13) * Hidden card data on screenshot * Bump Requirements --- .../xcshareddata/swiftpm/Package.resolved | 4 +-- .../Widget/PaymentCardWidget.swift | 30 ++++++++++++++++++- .../PUPaymentCard/Widget/SecureField.swift | 30 +++++++++++++++++++ PUSDK.podspec | 4 +-- Package.resolved | 4 +-- Package.swift | 6 ++-- README.md | 2 +- 7 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 PUPaymentCard/Sources/PUPaymentCard/Widget/SecureField.swift diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f9cbf455..6a5aec61 100644 --- a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher.git", "state" : { - "revision" : "5b92f029fab2cce44386d28588098b5be0824ef5", - "version" : "7.11.0" + "revision" : "2ef543ee21d63734e1c004ad6c870255e8716c50", + "version" : "7.12.0" } }, { diff --git a/PUPaymentCard/Sources/PUPaymentCard/Widget/PaymentCardWidget.swift b/PUPaymentCard/Sources/PUPaymentCard/Widget/PaymentCardWidget.swift index ed3d83d0..dfb8a1f9 100644 --- a/PUPaymentCard/Sources/PUPaymentCard/Widget/PaymentCardWidget.swift +++ b/PUPaymentCard/Sources/PUPaymentCard/Widget/PaymentCardWidget.swift @@ -329,7 +329,15 @@ private extension PaymentCardWidget { stackView.spacing = 16.0 stackView.distribution = .fill stackView.alignment = .fill - addSubview(stackView) + + if let secureView = SecureField().secureContainer { + secureView.addSubview(stackView) + stackView.pinEdges() + addSubview(secureView) + secureView.pinEdges() + } else { + addSubview(stackView) + } stackView.translatesAutoresizingMaskIntoConstraints = false stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -343,3 +351,23 @@ private extension PaymentCardWidget { if configuration.shouldDisplayTermsAndConditions { stackView.addArrangedSubview(makeTermsAndConditionsView()) } } } + +extension UIView { + func pin(_ type: NSLayoutConstraint.Attribute) { + translatesAutoresizingMaskIntoConstraints = false + let constraint = NSLayoutConstraint(item: self, attribute: type, + relatedBy: .equal, + toItem: superview, attribute: type, + multiplier: 1, constant: 0) + + constraint.priority = UILayoutPriority.init(999) + constraint.isActive = true + } + + func pinEdges() { + pin(.top) + pin(.bottom) + pin(.leading) + pin(.trailing) + } +} diff --git a/PUPaymentCard/Sources/PUPaymentCard/Widget/SecureField.swift b/PUPaymentCard/Sources/PUPaymentCard/Widget/SecureField.swift new file mode 100644 index 00000000..39f00a2b --- /dev/null +++ b/PUPaymentCard/Sources/PUPaymentCard/Widget/SecureField.swift @@ -0,0 +1,30 @@ +import UIKit + +class SecureField: UITextField { + + // MARK: - Initialization + override init(frame: CGRect) { + super.init(frame: .zero) + self.isSecureTextEntry = true + self.translatesAutoresizingMaskIntoConstraints = false + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Public Properties + weak var secureContainer: UIView? { + let secureView = self.subviews.filter({ subview in + type(of: subview).description().contains("CanvasView") + }).first + secureView?.translatesAutoresizingMaskIntoConstraints = false + secureView?.isUserInteractionEnabled = true + + return secureView + } + + // MARK: - Overrides + override var canBecomeFirstResponder: Bool {false} + override func becomeFirstResponder() -> Bool {false} +} diff --git a/PUSDK.podspec b/PUSDK.podspec index a0197a7a..60c84fed 100644 --- a/PUSDK.podspec +++ b/PUSDK.podspec @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/PayU-EMEA/PayU-iOS-Swift.git', :tag => s.version } s.platform = :ios - s.swift_version = '5.3' - s.ios.deployment_target = '11.0' + s.swift_version = '5.10' + s.ios.deployment_target = '12.0' s.subspec 'PUAPI' do |ss| ss.source_files = 'PUAPI/Sources/PUAPI/**/*' diff --git a/Package.resolved b/Package.resolved index f9cbf455..6a5aec61 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher.git", "state" : { - "revision" : "5b92f029fab2cce44386d28588098b5be0824ef5", - "version" : "7.11.0" + "revision" : "2ef543ee21d63734e1c004ad6c870255e8716c50", + "version" : "7.12.0" } }, { diff --git a/Package.swift b/Package.swift index 3cf89646..ed8580ba 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -7,7 +7,7 @@ let package = Package( name: "PUSDK", defaultLocalization: "pl", platforms: [ - .iOS(.v11) + .iOS(.v12) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. @@ -89,7 +89,7 @@ let package = Package( // .package(url: /* package url */, from: "1.0.0"), .package( url: "https://github.com/onevcat/Kingfisher.git", - .upToNextMinor(from: .init(7, 11, 0)) + .upToNextMinor(from: .init(7, 12, 0)) ), .package( url: "https://github.com/birdrides/mockingbird", diff --git a/README.md b/README.md index 3e7ce9d9..dfe76651 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Allows to make payments in PayU ecosystem. ## Requirements -* iOS 11.0 or higher +* iOS 12.0 or higher ## Getting Started