Skip to content

Commit

Permalink
feat(GiniHealthSDK): Fix brand ingredient appearance after new accept…
Browse files Browse the repository at this point in the history
…ance criteria

IPC-507
  • Loading branch information
razvancapra committed Feb 11, 2025
1 parent c7e92cf commit 18ee4ad
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ public final class InstallAppBottomView: BottomSheetViewController {
contentStackView.addArrangedSubview(buttonsView)
contentStackView.addArrangedSubview(UIView())
bottomStackView.addArrangedSubview(UIView())
bottomStackView.addArrangedSubview(poweredByGiniView)
if viewModel.shouldShowBrandedView {
bottomStackView.addArrangedSubview(poweredByGiniView)
}
bottomView.addSubview(bottomStackView)
contentStackView.addArrangedSubview(bottomView)
self.setContent(content: contentStackView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,26 @@ public final class InstallAppBottomViewModel {
selectedPaymentProvider?.appSchemeIOS.canOpenURLString() == true
}

var clientConfiguration: ClientConfiguration?
var shouldShowBrandedView: Bool {
clientConfiguration?.ingredientBrandType == .fullVisible
}

public init(selectedPaymentProvider: PaymentProvider?,
installAppConfiguration: InstallAppConfiguration,
strings: InstallAppStrings,
primaryButtonConfiguration: ButtonConfiguration,
poweredByGiniConfiguration: PoweredByGiniConfiguration,
poweredByGiniStrings: PoweredByGiniStrings) {
poweredByGiniStrings: PoweredByGiniStrings,
clientConfiguration: ClientConfiguration?) {
self.selectedPaymentProvider = selectedPaymentProvider
self.bankImageIcon = selectedPaymentProvider?.iconData.toImage ?? UIImage()
self.paymentProviderColors = selectedPaymentProvider?.colors
self.configuration = installAppConfiguration
self.strings = strings
self.primaryButtonConfiguration = primaryButtonConfiguration
self.poweredByGiniViewModel = PoweredByGiniViewModel(configuration: poweredByGiniConfiguration, strings: poweredByGiniStrings)
self.clientConfiguration = clientConfiguration

titleText = strings.titlePattern.replacingOccurrences(of: bankToReplaceString, with: selectedPaymentProvider?.name ?? "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public final class PaymentInfoViewController: UIViewController {
setupViewHierarchy()
setupViewAttributes()
setupViewConstraints()
setupViewVisibility()
}

private func setupViewHierarchy() {
Expand All @@ -164,7 +165,11 @@ public final class PaymentInfoViewController: UIViewController {
setupPayBillsConstraints()
setupQuestionsConstraints()
}


private func setupViewVisibility() {
poweredByGiniView.isHidden = !viewModel.shouldShowBrandedView
}

private func setupContentViewConstraints() {
NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.topAnchor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ public final class PaymentInfoViewModel {
var payBillsDescriptionAttributedText: NSMutableAttributedString = NSMutableAttributedString()
var payBillsDescriptionLinkAttributes: [NSAttributedString.Key: Any]
var questions: [FAQSection] = []


var clientConfiguration: ClientConfiguration?
var shouldShowBrandedView: Bool {
clientConfiguration?.ingredientBrandType == .fullVisible
}

public init(paymentProviders: GiniHealthAPILibrary.PaymentProviders,
configuration: PaymentInfoConfiguration,
strings: PaymentInfoStrings,
poweredByGiniConfiguration: PoweredByGiniConfiguration,
poweredByGiniStrings: PoweredByGiniStrings) {
poweredByGiniStrings: PoweredByGiniStrings,
clientConfiguration: ClientConfiguration?) {
self.paymentProviders = paymentProviders
self.configuration = configuration
self.strings = strings
self.poweredByGiniViewModel = PoweredByGiniViewModel(configuration: poweredByGiniConfiguration, strings: poweredByGiniStrings)
self.clientConfiguration = clientConfiguration

payBillsDescriptionLinkAttributes = [.font: configuration.linksFont]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public final class ShareInvoiceBottomView: BottomSheetViewController {
contentStackView.addArrangedSubview(qrCodeView)

brandStackView.addArrangedSubview(UIView())
brandStackView.addArrangedSubview(poweredByGiniView)
if viewModel.shouldShowBrandedView {
brandStackView.addArrangedSubview(poweredByGiniView)
}
brandStackView.addArrangedSubview(UIView())
brandView.addSubview(brandStackView)
contentStackView.addArrangedSubview(brandView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public final class ShareInvoiceBottomViewModel {

var appsMocked: [SingleApp] = []

var clientConfiguration: ClientConfiguration?
var shouldShowBrandedView: Bool {
clientConfiguration?.ingredientBrandType == .fullVisible
}
/**
Initializes a new instance of `ShareInvoiceBottomViewModel`.

Expand All @@ -67,7 +71,8 @@ public final class ShareInvoiceBottomViewModel {
poweredByGiniStrings: PoweredByGiniStrings,
qrCodeData: Data,
paymentInfo: PaymentInfo?,
paymentRequestId: String) {
paymentRequestId: String,
clientConfiguration: ClientConfiguration?) {
self.selectedPaymentProvider = selectedPaymentProvider
self.bankImageIcon = selectedPaymentProvider?.iconData ?? Data()
self.paymentProviderColors = selectedPaymentProvider?.colors
Expand All @@ -78,6 +83,7 @@ public final class ShareInvoiceBottomViewModel {
self.qrCodeData = qrCodeData
self.paymentInfo = paymentInfo
self.paymentRequestId = paymentRequestId
self.clientConfiguration = clientConfiguration

titleText = strings.titleTextPattern.replacingOccurrences(of: bankToReplaceString, with: selectedPaymentProvider?.name ?? "")
descriptionLabelText = strings.descriptionTextPattern.replacingOccurrences(of: bankToReplaceString, with: selectedPaymentProvider?.name ?? "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension PaymentComponentsController {
case let .success(paymentProviders):
self?.paymentProviders = paymentProviders.map{ $0.toHealthPaymentProvider() }
self?.sortPaymentProviders()
self?.selectedPaymentProvider = self?.defaultInstalledPaymentProvider()
// self?.selectedPaymentProvider = self?.defaultInstalledPaymentProvider()
self?.delegate?.didFetchedPaymentProviders()
case let .failure(error):
GiniUtilites.Log("Couldn't load payment providers: \(error.localizedDescription)", event: .error)
Expand Down Expand Up @@ -287,7 +287,8 @@ extension PaymentComponentsController {
configuration: configurationProvider.paymentInfoConfiguration,
strings: stringsProvider.paymentInfoStrings,
poweredByGiniConfiguration: configurationProvider.poweredByGiniConfiguration,
poweredByGiniStrings: stringsProvider.poweredByGiniStrings)
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
clientConfiguration: configurationProvider.clientConfiguration)
return PaymentInfoViewController(viewModel: paymentInfoViewModel)
}

Expand All @@ -306,7 +307,8 @@ extension PaymentComponentsController {
strings: stringsProvider.installAppStrings,
primaryButtonConfiguration: configurationProvider.primaryButtonConfiguration,
poweredByGiniConfiguration: configurationProvider.poweredByGiniConfiguration,
poweredByGiniStrings: stringsProvider.poweredByGiniStrings)
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
clientConfiguration: configurationProvider.clientConfiguration)
installAppBottomViewModel.viewDelegate = self
let installAppBottomView = InstallAppBottomView(viewModel: installAppBottomViewModel, bottomSheetConfiguration: configurationProvider.bottomSheetConfiguration)
return installAppBottomView
Expand All @@ -333,7 +335,8 @@ extension PaymentComponentsController {
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
qrCodeData: qrCodeData,
paymentInfo: paymentInfo,
paymentRequestId: paymentRequestId)
paymentRequestId: paymentRequestId,
clientConfiguration: configurationProvider.clientConfiguration)
shareInvoiceBottomViewModel.viewDelegate = self
shareInvoiceBottomViewModel.documentId = documentId
let shareInvoiceBottomView = ShareInvoiceBottomView(viewModel: shareInvoiceBottomViewModel, bottomSheetConfiguration: configurationProvider.bottomSheetConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MockPaymentComponents: PaymentComponentsProtocol {
moreInformationStrings: stringsProvider.moreInformationStrings,
minimumButtonsHeight: configurationProvider.paymentComponentButtonsHeight,
paymentComponentConfiguration: configurationProvider.paymentComponentConfiguration,
clientConfiguration: nil
clientConfiguration: configurationProvider.clientConfiguration
)
paymentComponentViewModel.documentId = MockSessionManager.payableDocumentID
let view = PaymentComponentView(viewModel: paymentComponentViewModel)
Expand All @@ -99,7 +99,7 @@ class MockPaymentComponents: PaymentComponentsProtocol {
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
moreInformationConfiguration: configurationProvider.moreInformationConfiguration,
moreInformationStrings: stringsProvider.moreInformationStrings,
clientConfiguration: nil)
clientConfiguration: configurationProvider.clientConfiguration)
return BanksBottomView(viewModel: paymentProvidersBottomViewModel, bottomSheetConfiguration: configurationProvider.bottomSheetConfiguration)
}

Expand All @@ -114,7 +114,8 @@ class MockPaymentComponents: PaymentComponentsProtocol {
configuration: giniHealth.paymentInfoConfiguration,
strings: giniHealth.paymentInfoStrings,
poweredByGiniConfiguration: giniHealth.poweredByGiniConfiguration,
poweredByGiniStrings: giniHealth.poweredByGiniStrings)
poweredByGiniStrings: giniHealth.poweredByGiniStrings,
clientConfiguration: configurationProvider.clientConfiguration)
let paymentInfoViewController = PaymentInfoViewController(viewModel: paymentInfoViewModel)
return paymentInfoViewController
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final class PaymentComponentsControllerTests: XCTestCase {
moreInformationStrings: giniHealth.moreInformationStrings,
minimumButtonsHeight: giniHealth.paymentComponentButtonsHeight,
paymentComponentConfiguration: giniHealth.paymentComponentConfiguration,
clientConfiguration: nil)
clientConfiguration: giniHealth.clientConfiguration)

let expectedView = PaymentComponentView(viewModel: expectedViewModel)
expectedViewModel.documentId = documentId
Expand Down Expand Up @@ -171,7 +171,7 @@ final class PaymentComponentsControllerTests: XCTestCase {
moreInformationConfiguration: giniHealth.moreInformationConfiguration,
moreInformationStrings: giniHealth.moreInformationStrings,
urlOpener: URLOpener(MockUIApplication(canOpen: false)),
clientConfiguration: nil)
clientConfiguration: giniHealth.clientConfiguration)


XCTAssertEqual(bottomViewModel.paymentProviders.count, 11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ public final class PaymentComponentsController: PaymentComponentsProtocol, Botto
configuration: configurationProvider.paymentInfoConfiguration,
strings: stringsProvider.paymentInfoStrings,
poweredByGiniConfiguration: configurationProvider.poweredByGiniConfiguration,
poweredByGiniStrings: stringsProvider.poweredByGiniStrings)
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
clientConfiguration: nil)
return PaymentInfoViewController(viewModel: paymentInfoViewModel)
}

Expand All @@ -393,7 +394,8 @@ public final class PaymentComponentsController: PaymentComponentsProtocol, Botto
strings: stringsProvider.installAppStrings,
primaryButtonConfiguration: configurationProvider.primaryButtonConfiguration,
poweredByGiniConfiguration: configurationProvider.poweredByGiniConfiguration,
poweredByGiniStrings: stringsProvider.poweredByGiniStrings)
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
clientConfiguration: nil)
installAppBottomViewModel.viewDelegate = self
let installAppBottomView = InstallAppBottomView(viewModel: installAppBottomViewModel, bottomSheetConfiguration: configurationProvider.bottomSheetConfiguration)
return installAppBottomView
Expand All @@ -420,7 +422,8 @@ public final class PaymentComponentsController: PaymentComponentsProtocol, Botto
poweredByGiniStrings: stringsProvider.poweredByGiniStrings,
qrCodeData: qrCodeData,
paymentInfo: nil,
paymentRequestId: paymentRequestId)
paymentRequestId: paymentRequestId,
clientConfiguration: nil)
shareInvoiceBottomViewModel.viewDelegate = self
let shareInvoiceBottomView = ShareInvoiceBottomView(viewModel: shareInvoiceBottomViewModel, bottomSheetConfiguration: configurationProvider.bottomSheetConfiguration)
return shareInvoiceBottomView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class MockPaymentComponents: PaymentComponentsProtocol {
configuration: giniMerchant.paymentInfoConfiguration,
strings: giniMerchant.paymentInfoStrings,
poweredByGiniConfiguration: giniMerchant.poweredByGiniConfiguration,
poweredByGiniStrings: giniMerchant.poweredByGiniStrings)
poweredByGiniStrings: giniMerchant.poweredByGiniStrings,
clientConfiguration: nil)
let paymentInfoViewController = PaymentInfoViewController(viewModel: paymentInfoViewModel)
return paymentInfoViewController
}
Expand Down

0 comments on commit 18ee4ad

Please sign in to comment.