From 1b363c694a707cf680bc27f987499fca4cf9e3e0 Mon Sep 17 00:00:00 2001 From: Razvan Capra Date: Thu, 11 Apr 2024 11:42:30 +0300 Subject: [PATCH] fix(GiniHealthSDK): Remove isPaymentProviderInstalled logic where no more needed --- .../xcshareddata/swiftpm/Package.resolved | 9 ----- .../PaymentComponentView.swift | 7 ++-- .../PaymentPrimaryButton.swift | 6 ++-- .../PaymentSecondaryButton.swift | 34 +++++++------------ .../Core/PaymentReviewViewController.swift | 1 - 5 files changed, 17 insertions(+), 40 deletions(-) diff --git a/GiniMobile.xcworkspace/xcshareddata/swiftpm/Package.resolved b/GiniMobile.xcworkspace/xcshareddata/swiftpm/Package.resolved index f6a9a5435..28cb07b45 100644 --- a/GiniMobile.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/GiniMobile.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,15 +1,6 @@ { "object": { "pins": [ - { - "package": "Lottie", - "repositoryURL": "https://github.com/airbnb/lottie-ios.git", - "state": { - "branch": null, - "revision": "d6feea26a370019b4d3a85f5984cb95a2734776f", - "version": "4.2.0" - } - }, { "package": "TrustKit", "repositoryURL": "https://github.com/datatheorem/TrustKit.git", diff --git a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentView.swift b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentView.swift index 46eea51f4..6b31b3a7f 100644 --- a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentView.swift +++ b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentView.swift @@ -102,9 +102,7 @@ final class PaymentComponentView: UIView { button.customConfigure(labelText: viewModel.bankNameLabelText, leftImageIcon: viewModel.bankImageIcon, rightImageIcon: viewModel.chevronDownIconName, - rightImageTintColor: viewModel.chevronDownIconColor, - isPaymentProviderInstalled: true, - notInstalledTextColor: viewModel.notInstalledBankTextColor) + rightImageTintColor: viewModel.chevronDownIconColor) return button }() @@ -113,8 +111,7 @@ final class PaymentComponentView: UIView { button.translatesAutoresizingMaskIntoConstraints = false button.frame = CGRect(x: 0, y: 0, width: .greatestFiniteMagnitude, height: Constants.buttonViewHeight) button.configure(with: viewModel.giniHealthConfiguration.primaryButtonConfiguration) - button.customConfigure(paymentProviderColors: viewModel.paymentProviderColors, - isPaymentProviderInstalled: true, + button.customConfigure(paymentProviderColors: viewModel.paymentProviderColors, text: viewModel.payInvoiceLabelText) return button }() diff --git a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentPrimaryButton.swift b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentPrimaryButton.swift index a6263d7fc..94a911870 100644 --- a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentPrimaryButton.swift +++ b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentPrimaryButton.swift @@ -86,11 +86,11 @@ extension PaymentPrimaryButton { } } - func customConfigure(paymentProviderColors: ProviderColors?, isPaymentProviderInstalled: Bool, text: String, leftImageData: Data? = nil) { - if let backgroundHexColor = paymentProviderColors?.background.toColor(), isPaymentProviderInstalled { + func customConfigure(paymentProviderColors: ProviderColors?, text: String, leftImageData: Data? = nil) { + if let backgroundHexColor = paymentProviderColors?.background.toColor() { contentView.backgroundColor = backgroundHexColor } - contentView.isUserInteractionEnabled = isPaymentProviderInstalled + contentView.isUserInteractionEnabled = true titleLabel.text = text if let textHexColor = paymentProviderColors?.text.toColor() { diff --git a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentSecondaryButton.swift b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentSecondaryButton.swift index 0d0d7171a..10fb5414d 100644 --- a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentSecondaryButton.swift +++ b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentSecondaryButton.swift @@ -69,22 +69,15 @@ final class PaymentSecondaryButton: UIView { ]) } - private func activateBankImageViewConstraints(isPaymentProviderInstalled: Bool) { - if isPaymentProviderInstalled { - leftImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.contentLeadingPadding).isActive = true - leftImageView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true - leftImageView.widthAnchor.constraint(equalToConstant: leftImageView.frame.width).isActive = true - leftImageView.heightAnchor.constraint(equalToConstant: leftImageView.frame.height).isActive = true - let bankNameBankViewConstraint = titleLabel.leadingAnchor.constraint(equalTo: leftImageView.trailingAnchor, constant: Constants.contentLeadingPadding) - bankNameBankViewConstraint.priority = .required - 1 // fix needed because of embeded views in cells issue. We need this to silent the "Unable to simultaneously satisfy constraints" warning - bankNameBankViewConstraint.isActive = true - leftImageView.centerYAnchor.constraint(equalTo: titleLabel.centerYAnchor).isActive = true - } else { - let bankNameLeadingSuperviewConstraint = titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.contentLeadingPadding) - bankNameLeadingSuperviewConstraint.priority = .required - 1 - bankNameLeadingSuperviewConstraint.isActive = true - contentView.centerYAnchor.constraint(equalTo: titleLabel.centerYAnchor).isActive = true - } + private func activateBankImageViewConstraints() { + leftImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.contentLeadingPadding).isActive = true + leftImageView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true + leftImageView.widthAnchor.constraint(equalToConstant: leftImageView.frame.width).isActive = true + leftImageView.heightAnchor.constraint(equalToConstant: leftImageView.frame.height).isActive = true + let bankNameBankViewConstraint = titleLabel.leadingAnchor.constraint(equalTo: leftImageView.trailingAnchor, constant: Constants.contentLeadingPadding) + bankNameBankViewConstraint.priority = .required - 1 // fix needed because of embeded views in cells issue. We need this to silent the "Unable to simultaneously satisfy constraints" warning + bankNameBankViewConstraint.isActive = true + leftImageView.centerYAnchor.constraint(equalTo: titleLabel.centerYAnchor).isActive = true } @objc @@ -110,8 +103,8 @@ extension PaymentSecondaryButton { } } - func customConfigure(labelText: String, leftImageIcon: UIImage?, rightImageIcon: String?, rightImageTintColor: UIColor, isPaymentProviderInstalled: Bool, notInstalledTextColor: UIColor) { - if let leftImageIcon, isPaymentProviderInstalled { + func customConfigure(labelText: String, leftImageIcon: UIImage?, rightImageIcon: String?, rightImageTintColor: UIColor) { + if let leftImageIcon { leftImageView.image = leftImageIcon leftImageView.isHidden = false } else { @@ -125,10 +118,7 @@ extension PaymentSecondaryButton { rightImageView.isHidden = true } titleLabel.text = labelText - if !isPaymentProviderInstalled { - titleLabel.textColor = notInstalledTextColor - } - activateBankImageViewConstraints(isPaymentProviderInstalled: isPaymentProviderInstalled) + activateBankImageViewConstraints() } } diff --git a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentReviewViewController.swift b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentReviewViewController.swift index 472c83d1b..762a82eb0 100644 --- a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentReviewViewController.swift +++ b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentReviewViewController.swift @@ -236,7 +236,6 @@ public final class PaymentReviewViewController: UIViewController, UIGestureRecog guard let model else { return } payInvoiceButton.configure(with: giniHealthConfiguration.primaryButtonConfiguration) payInvoiceButton.customConfigure(paymentProviderColors: selectedPaymentProvider?.colors, - isPaymentProviderInstalled: true, text: model.payInvoiceLabelText, leftImageData: selectedPaymentProvider?.iconData) disablePayButtonIfNeeded()