Skip to content

Commit

Permalink
Merge pull request #451 from gini/IPC-110_payment-component-bank-avai…
Browse files Browse the repository at this point in the history
…lable

feat(GiniHealthSDK): Payment providers added to payment component IPC-97
  • Loading branch information
razvancapra authored Feb 26, 2024
2 parents 55c9b65 + 4eea771 commit 19aeda5
Show file tree
Hide file tree
Showing 22 changed files with 829 additions and 450 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// ButtonConfiguration.swift
//
// Copyright © 2024 Gini GmbH. All rights reserved.
//


import UIKit

public struct ButtonConfiguration {
let backgroundColor: UIColor
let borderColor: UIColor
let titleColor: UIColor
let shadowColor: UIColor
let cornerRadius: CGFloat
let borderWidth: CGFloat
let shadowRadius: CGFloat

let withBlurEffect: Bool

/// Button configuration initalizer
/// - Parameters:
/// - backgroundColor: the button's background color
/// - borderColor: the button's border color
/// - titleColor: the button's title color
/// - shadowColor: the button's color of the shadow
/// - cornerRadius: the button's corner radius
/// - borderWidth: the button's border width
/// - shadowRadius: the button's shadow radius
/// - withBlurEffect: adds a blur effect on the button ignoring the background color and making it translucent
public init(backgroundColor: UIColor,
borderColor: UIColor,
titleColor: UIColor,
shadowColor: UIColor,
cornerRadius: CGFloat,
borderWidth: CGFloat,
shadowRadius: CGFloat,
withBlurEffect: Bool) {
self.backgroundColor = backgroundColor
self.borderColor = borderColor
self.titleColor = titleColor
self.shadowColor = shadowColor
self.cornerRadius = cornerRadius
self.borderWidth = borderWidth
self.shadowRadius = shadowRadius
self.withBlurEffect = withBlurEffect
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// String.swift
//
// Copyright © 2024 Gini GmbH. All rights reserved.
//


import UIKit

extension String {
func toColor() -> UIColor? {
return UIColor(hex: String.rgbaHexFrom(rgbHex: self))
}
}
45 changes: 8 additions & 37 deletions HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/GiniColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,14 @@
//

import UIKit
/**
The `Color` class allows us decode and encode the color
*/

public struct CodableColor: Codable {
private var red: CGFloat = 0.0
private var green: CGFloat = 0.0
private var blue: CGFloat = 0.0
private var alpha: CGFloat = 0.0

public var uiColor: UIColor {
UIColor(red: red,
green: green,
blue: blue,
alpha: alpha)
}

public var giniColor: GiniColor {
GiniColor(lightModeColor: uiColor,
darkModeColor: uiColor)
}

public init(uiColor: UIColor) {
uiColor.getRed(&red,
green: &green,
blue: &blue,
alpha: &alpha)
}
}

/**
The `GiniColor` class allows to customize color for the light and the dark modes.
*/

@objc public class GiniColor : NSObject, Codable {
var lightModeColor: CodableColor
var darkModeColor: CodableColor
@objc public class GiniColor : NSObject {
var lightModeColor: UIColor
var darkModeColor: UIColor

/**
Creates a GiniColor with the colors for the light and dark modes
Expand All @@ -51,24 +22,24 @@ public struct CodableColor: Codable {
- parameter darkModeColor: color for the dark mode
*/
public init(lightModeColor: UIColor, darkModeColor: UIColor) {
self.lightModeColor = CodableColor(uiColor: lightModeColor)
self.darkModeColor = CodableColor(uiColor: darkModeColor)
self.lightModeColor = lightModeColor
self.darkModeColor = darkModeColor
}

func uiColor() -> UIColor {
if #available(iOS 13, *) {
return UIColor { (UITraitCollection: UITraitCollection) -> UIColor in
if UITraitCollection.userInterfaceStyle == .dark {
/// Return the color for Dark Mode
return self.darkModeColor.uiColor
return self.darkModeColor
} else {
/// Return the color for Light Mode
return self.lightModeColor.uiColor
return self.lightModeColor
}
}
} else {
/// Return a fallback color for iOS 12 and lower.
return self.lightModeColor.uiColor
return self.lightModeColor
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ public struct DataForReview {
In case of failure error that there are no supported banking apps installed.

*/
private func getInstalledBankingApps(completion: @escaping (Result<PaymentProviders, GiniHealthError>) -> Void){
paymentService.paymentProviders { result in
private func fetchInstalledBankingApps(completion: @escaping (Result<PaymentProviders, GiniHealthError>) -> Void) {
fetchBankingApps { result in
switch result {
case let .success(providers):
self.bankProviders = []
case .success(let providers):
for provider in providers {
DispatchQueue.main.async {
if let url = URL(string:provider.appSchemeIOS) {
Expand All @@ -110,12 +109,33 @@ public struct DataForReview {
}
case let .failure(error):
DispatchQueue.main.async {
completion(.failure(.apiError(error)))

completion(.failure(error))
}
}
}
}

/**
Getting a list of the banking apps supported by SDK

- Parameters:
- completion: An action for processing asynchronous data received from the service with Result type as a paramater.
Result is a value that represents either a success or a failure, including an associated value in each case.
In success case it includes array of payment providers supported by SDK.
In case of failure error provided by API.
*/

public func fetchBankingApps(completion: @escaping (Result<PaymentProviders, GiniHealthError>) -> Void) {
paymentService.paymentProviders { result in
switch result {
case let .success(providers):
self.bankProviders = providers
completion(.success(self.bankProviders))
case let .failure(error):
completion(.failure(.apiError(error)))
}
}
}

/**
Checks if there are any banking app which support Gini Pay Connect functionality installed.
Expand All @@ -126,7 +146,7 @@ public struct DataForReview {
In case of failure error that there are no supported banking apps installed.
*/
public func checkIfAnyPaymentProviderAvailable(completion: @escaping (Result<PaymentProviders, GiniHealthError>) -> Void){
self.getInstalledBankingApps(completion: completion)
self.fetchInstalledBankingApps(completion: completion)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,50 @@ public final class GiniHealthConfiguration: NSObject {
*/
@objc public var infoBarCornerRadius: CGFloat = 12.0

// MARK: - Button configuration options
/**
A configuration that defines the appearance of the primary button, including its background color, border color, title color, shadow color, corner radius, border width, shadow radius, and whether to apply a blur effect. It is used for buttons on different UI elements: Payment Component View, Payment Review Screen.
*/
public lazy var primaryButtonConfiguration = ButtonConfiguration(backgroundColor: .GiniHealthColors.accent1.withAlphaComponent(0.4),
borderColor: .clear,
titleColor: .white,
shadowColor: .clear,
cornerRadius: 12,
borderWidth: 0,
shadowRadius: 0,
withBlurEffect: false)
/**
A configuration that defines the appearance of the secondary button, including its background color, border color, title color, shadow color, corner radius, border width, shadow radius, and whether to apply a blur effect. It is used for buttons on different UI elements: Payment Component View.
*/
public lazy var secondaryButtonConfiguration = ButtonConfiguration(backgroundColor: GiniColor(lightModeColor: UIColor.GiniHealthColors.dark6,
darkModeColor: UIColor.GiniHealthColors.light6).uiColor(),
borderColor: GiniColor(lightModeColor: UIColor.GiniHealthColors.dark5,
darkModeColor: UIColor.GiniHealthColors.light5).uiColor(),
titleColor: GiniColor(lightModeColor: UIColor.GiniHealthColors.dark1,
darkModeColor: UIColor.GiniHealthColors.light1).uiColor(),
shadowColor: .clear,
cornerRadius: 12,
borderWidth: 1,
shadowRadius: 0,
withBlurEffect: true)

// MARK: - Shared properties

/**
Sets the font used in the screens by default.
*/

@objc public lazy var customFont = GiniFont(regular: UIFont.systemFont(ofSize: 14,
weight: .regular),
bold: UIFont.systemFont(ofSize: 14,
weight: .bold),
light: UIFont.systemFont(ofSize: 14,
weight: .light),
thin: UIFont.systemFont(ofSize: 14,
weight: .thin),
medium: UIFont.systemFont(ofSize: 14,
weight: .medium),
isEnabled: false)
weight: .regular),
bold: UIFont.systemFont(ofSize: 14,
weight: .bold),
light: UIFont.systemFont(ofSize: 14,
weight: .light),
thin: UIFont.systemFont(ofSize: 14,
weight: .thin),
medium: UIFont.systemFont(ofSize: 14,
weight: .medium),
isEnabled: false)
/**
Sets the color of the loading indicator to the specified color.
*/
Expand All @@ -254,13 +281,13 @@ public final class GiniHealthConfiguration: NSObject {
*/
@objc public var loadingIndicatorScale: CGFloat = 1.0

private var textStyleFonts: [UIFont.TextStyle: UIFont] = [
.caption1: UIFontMetrics(forTextStyle: .caption1).scaledFont(for: UIFont.systemFont(ofSize: 12)),
.caption2: UIFontMetrics(forTextStyle: .caption2).scaledFont(for: UIFont.systemFont(ofSize: 11)),
.linkBold: UIFontMetrics(forTextStyle: .linkBold).scaledFont(for: UIFont.systemFont(ofSize: 14)),
.subtitle2: UIFontMetrics(forTextStyle: .subtitle2).scaledFont(for: UIFont.systemFont(ofSize: 14)),
.input: UIFontMetrics(forTextStyle: .input).scaledFont(for: UIFont.systemFont(ofSize: 16)),
.button: UIFontMetrics(forTextStyle: .button).scaledFont(for: UIFont.systemFont(ofSize: 16))
var textStyleFonts: [UIFont.TextStyle: UIFont] = [
.caption1: UIFontMetrics(forTextStyle: .caption1).scaledFont(for: UIFont.systemFont(ofSize: 13, weight: .regular)),
.caption2: UIFontMetrics(forTextStyle: .caption2).scaledFont(for: UIFont.systemFont(ofSize: 12, weight: .regular)),
.linkBold: UIFontMetrics(forTextStyle: .linkBold).scaledFont(for: UIFont.systemFont(ofSize: 14, weight: .bold)),
.subtitle2: UIFontMetrics(forTextStyle: .subtitle2).scaledFont(for: UIFont.systemFont(ofSize: 14, weight: .medium)),
.input: UIFontMetrics(forTextStyle: .input).scaledFont(for: UIFont.systemFont(ofSize: 16, weight: .medium)),
.button: UIFontMetrics(forTextStyle: .button).scaledFont(for: UIFont.systemFont(ofSize: 16, weight: .bold))
]

}
Loading

0 comments on commit 19aeda5

Please sign in to comment.