Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure appearance for every SFSafariViewController instance #4515

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private extension HostController {
clientSecret: clientSecret,
apiClient: apiClient,
manifest: manifest,
configuration: configuration,
sessionFetcher: sessionFetcher,
returnURL: returnURL,
elementsSessionContext: elementsSessionContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class AccountPickerAccountLoadErrorView: UIView {
init(
institution: FinancialConnectionsInstitution,
appearance: FinancialConnectionsAppearance,
configuration: FinancialConnectionsSheet.Configuration,
didSelectAnotherBank: @escaping () -> Void,
didSelectTryAgain: (() -> Void)?, // if nil, don't show button
didSelectEnterBankDetailsManually: (() -> Void)? // if nil, don't show button
Expand Down Expand Up @@ -76,7 +77,8 @@ final class AccountPickerAccountLoadErrorView: UIView {
institution.name
),
subtitle: subtitle,
contentView: nil
contentView: nil,
configuration: configuration
),
footerView: PaneLayoutView.createFooterView(
primaryButtonConfiguration: primaryButtonConfiguration,
Expand Down Expand Up @@ -113,6 +115,7 @@ private struct AccountPickerAccountLoadErrorViewUIViewRepresentable: UIViewRepre
logo: nil
),
appearance: appearance,
configuration: .init(),
didSelectAnotherBank: {},
didSelectTryAgain: didSelectTryAgain,
didSelectEnterBankDetailsManually: didSelectEnterBankDetailsManually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protocol AccountPickerDataSource: AnyObject {

var delegate: AccountPickerDataSourceDelegate? { get set }
var manifest: FinancialConnectionsSessionManifest { get }
var configuration: FinancialConnectionsSheet.Configuration { get }
var accountPickerPane: FinancialConnectionsAccountPickerPane? { get }
var authSession: FinancialConnectionsAuthSession { get }
var institution: FinancialConnectionsInstitution { get }
Expand All @@ -44,6 +45,7 @@ final class AccountPickerDataSourceImplementation: AccountPickerDataSource {
let accountPickerPane: FinancialConnectionsAccountPickerPane?
let authSession: FinancialConnectionsAuthSession
let manifest: FinancialConnectionsSessionManifest
let configuration: FinancialConnectionsSheet.Configuration
let institution: FinancialConnectionsInstitution
let analyticsClient: FinancialConnectionsAnalyticsClient
let reduceManualEntryProminenceInErrors: Bool
Expand All @@ -63,6 +65,7 @@ final class AccountPickerDataSourceImplementation: AccountPickerDataSource {
accountPickerPane: FinancialConnectionsAccountPickerPane?,
authSession: FinancialConnectionsAuthSession,
manifest: FinancialConnectionsSessionManifest,
configuration: FinancialConnectionsSheet.Configuration,
institution: FinancialConnectionsInstitution,
analyticsClient: FinancialConnectionsAnalyticsClient,
reduceManualEntryProminenceInErrors: Bool,
Expand All @@ -74,6 +77,7 @@ final class AccountPickerDataSourceImplementation: AccountPickerDataSource {
self.accountPickerPane = accountPickerPane
self.authSession = authSession
self.manifest = manifest
self.configuration = configuration
self.institution = institution
self.analyticsClient = analyticsClient
self.reduceManualEntryProminenceInErrors = reduceManualEntryProminenceInErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class AccountPickerNoAccountEligibleErrorView: UIView {
numberOfIneligibleAccounts: Int,
paymentMethodType: FinancialConnectionsPaymentMethodType,
appearance: FinancialConnectionsAppearance,
configuration: FinancialConnectionsSheet.Configuration,
didSelectAnotherBank: @escaping () -> Void
) {
super.init(frame: .zero)
Expand Down Expand Up @@ -127,7 +128,8 @@ final class AccountPickerNoAccountEligibleErrorView: UIView {
}
}(),
subtitle: subtitleFirstSentence + " " + subtitleSecondSentence,
contentView: nil
contentView: nil,
configuration: configuration
),
footerView: PaneLayoutView.createFooterView(
primaryButtonConfiguration: PaneLayoutView.ButtonConfiguration(
Expand Down Expand Up @@ -180,6 +182,7 @@ private struct AccountPickerNoAccountEligibleErrorViewUIViewRepresentable: UIVie
numberOfIneligibleAccounts: numberOfIneligibleAccounts,
paymentMethodType: paymentMethodType,
appearance: .stripe,
configuration: .init(),
didSelectAnotherBank: {}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,22 @@ final class AccountPickerViewController: UIViewController {
let dataAccessNoticeViewController = DataAccessNoticeViewController(
dataAccessNotice: dataAccessNotice,
appearance: self.dataSource.manifest.appearance,
configuration: self.dataSource.configuration,
didSelectUrl: { [weak self] url in
guard let self = self else { return }
AuthFlowHelpers.handleURLInTextFromBackend(
url: url,
pane: .accountPicker,
analyticsClient: self.dataSource.analyticsClient,
configuration: self.dataSource.configuration,
handleURL: { _, _ in }
)
}
)
self.dataSource.configuration.style.configure(dataAccessNoticeViewController)
dataAccessNoticeViewController.present(on: self)
} else {
SFSafariViewController.present(url: url)
SFSafariViewController.present(url: url, configuration: self.dataSource.configuration)
}
}
)
Expand All @@ -141,7 +144,8 @@ final class AccountPickerViewController: UIViewController {

private func pollAuthSessionAccounts() {
let retreivingAccountsLoadingView = RetrieveAccountsLoadingView(
institutionIconUrl: dataSource.institution.icon?.default
institutionIconUrl: dataSource.institution.icon?.default,
configuration: dataSource.configuration
)
view.addAndPinSubviewToSafeArea(retreivingAccountsLoadingView)

Expand Down Expand Up @@ -265,6 +269,7 @@ final class AccountPickerViewController: UIViewController {
numberOfIneligibleAccounts: numberOfIneligibleAccounts,
paymentMethodType: self.dataSource.manifest.paymentMethodType ?? .usBankAccount,
appearance: self.dataSource.manifest.appearance,
configuration: self.dataSource.configuration,
didSelectAnotherBank: self.didSelectAnotherBank
)
// the user will never enter this instance of `AccountPickerViewController`
Expand Down Expand Up @@ -318,7 +323,8 @@ final class AccountPickerViewController: UIViewController {
}
}(),
subtitle: nil,
contentView: accountPickerSelectionView
contentView: accountPickerSelectionView,
configuration: dataSource.configuration
),
footerView: footerView
)
Expand Down Expand Up @@ -352,6 +358,7 @@ final class AccountPickerViewController: UIViewController {
let errorView = AccountPickerAccountLoadErrorView(
institution: dataSource.institution,
appearance: dataSource.manifest.appearance,
configuration: dataSource.configuration,
didSelectAnotherBank: didSelectAnotherBank,
didSelectTryAgain: didSelectTryAgain,
didSelectEnterBankDetailsManually: didSelectManualEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

final class RetrieveAccountsLoadingView: UIView {

init(institutionIconUrl: String?) {
init(institutionIconUrl: String?, configuration: FinancialConnectionsSheet.Configuration) {
super.init(frame: .zero)
let paneLayoutView = PaneLayoutView(
contentView: PaneLayoutView.createContentView(
Expand Down Expand Up @@ -40,7 +40,8 @@ final class RetrieveAccountsLoadingView: UIView {
verticalStackView.axis = .vertical
verticalStackView.spacing = 16
return verticalStackView
}()
}(),
configuration: configuration
),
footerView: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class AccountNumberRetrievalErrorView: UIView {
init(
institution: FinancialConnectionsInstitution,
appearance: FinancialConnectionsAppearance,
configuration: FinancialConnectionsSheet.Configuration,
didSelectAnotherBank: @escaping () -> Void,
didSelectEnterBankDetailsManually: (() -> Void)? // if nil, don't show button
) {
Expand Down Expand Up @@ -45,7 +46,8 @@ final class AccountNumberRetrievalErrorView: UIView {
)
}
}(),
contentView: nil
contentView: nil,
configuration: configuration
),
footerView: PaneLayoutView.createFooterView(
primaryButtonConfiguration: PaneLayoutView.ButtonConfiguration(
Expand Down Expand Up @@ -93,6 +95,7 @@ private struct AccountNumberRetrievalErrorViewUIViewRepresentable: UIViewReprese
logo: nil
),
appearance: appearance,
configuration: .init(),
didSelectAnotherBank: {},
didSelectEnterBankDetailsManually: didSelectEnterBankDetailsManually
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
protocol AttachLinkedPaymentAccountDataSource: AnyObject {

var manifest: FinancialConnectionsSessionManifest { get }
var configuration: FinancialConnectionsSheet.Configuration { get }
var institution: FinancialConnectionsInstitution { get }
var analyticsClient: FinancialConnectionsAnalyticsClient { get }
var authSessionId: String? { get }
Expand All @@ -24,6 +25,7 @@ final class AttachLinkedPaymentAccountDataSourceImplementation: AttachLinkedPaym
private let apiClient: any FinancialConnectionsAPI
private let clientSecret: String
let manifest: FinancialConnectionsSessionManifest
let configuration: FinancialConnectionsSheet.Configuration
let institution: FinancialConnectionsInstitution
private let linkedAccountId: String
let analyticsClient: FinancialConnectionsAnalyticsClient
Expand All @@ -35,6 +37,7 @@ final class AttachLinkedPaymentAccountDataSourceImplementation: AttachLinkedPaym
apiClient: any FinancialConnectionsAPI,
clientSecret: String,
manifest: FinancialConnectionsSessionManifest,
configuration: FinancialConnectionsSheet.Configuration,
institution: FinancialConnectionsInstitution,
linkedAccountId: String,
analyticsClient: FinancialConnectionsAnalyticsClient,
Expand All @@ -45,6 +48,7 @@ final class AttachLinkedPaymentAccountDataSourceImplementation: AttachLinkedPaym
self.apiClient = apiClient
self.clientSecret = clientSecret
self.manifest = manifest
self.configuration = configuration
self.institution = institution
self.linkedAccountId = linkedAccountId
self.analyticsClient = analyticsClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ final class AttachLinkedPaymentAccountViewController: UIViewController {
let errorView = AccountNumberRetrievalErrorView(
institution: self.dataSource.institution,
appearance: self.dataSource.manifest.appearance,
configuration: self.dataSource.configuration,
didSelectAnotherBank: self.didSelectAnotherBank,
didSelectEnterBankDetailsManually: self.didSelectManualEntry
)
Expand All @@ -144,6 +145,7 @@ final class AttachLinkedPaymentAccountViewController: UIViewController {
let errorView = AccountPickerAccountLoadErrorView(
institution: self.dataSource.institution,
appearance: self.dataSource.manifest.appearance,
configuration: self.dataSource.configuration,
didSelectAnotherBank: self.didSelectAnotherBank,
didSelectTryAgain: self.didSelectTryAgain,
didSelectEnterBankDetailsManually: self.didSelectManualEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

protocol ConsentDataSource: AnyObject {
var manifest: FinancialConnectionsSessionManifest { get }
var configuration: FinancialConnectionsSheet.Configuration { get }
var consent: FinancialConnectionsConsent { get }
var merchantLogo: [String]? { get }
var analyticsClient: FinancialConnectionsAnalyticsClient { get }
Expand All @@ -20,6 +21,7 @@ protocol ConsentDataSource: AnyObject {
final class ConsentDataSourceImplementation: ConsentDataSource {

let manifest: FinancialConnectionsSessionManifest
let configuration: FinancialConnectionsSheet.Configuration
let consent: FinancialConnectionsConsent
let merchantLogo: [String]?
private let apiClient: any FinancialConnectionsAPI
Expand All @@ -28,13 +30,15 @@ final class ConsentDataSourceImplementation: ConsentDataSource {

init(
manifest: FinancialConnectionsSessionManifest,
configuration: FinancialConnectionsSheet.Configuration,
consent: FinancialConnectionsConsent,
merchantLogo: [String]?,
apiClient: any FinancialConnectionsAPI,
clientSecret: String,
analyticsClient: FinancialConnectionsAnalyticsClient
) {
self.manifest = manifest
self.configuration = configuration
self.consent = consent
self.merchantLogo = merchantLogo
self.apiClient = apiClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class ConsentViewController: UIViewController {
url: url,
pane: .consent,
analyticsClient: dataSource.analyticsClient,
configuration: dataSource.configuration,
handleURL: { urlHost, nextPaneOrDrawerOnSecondaryCta in
guard let urlHost, let address = StripeSchemeAddress(rawValue: urlHost) else {
self.dataSource
Expand All @@ -193,21 +194,25 @@ class ConsentViewController: UIViewController {
let dataAccessNoticeViewController = DataAccessNoticeViewController(
dataAccessNotice: dataAccessNotice,
appearance: dataSource.manifest.appearance,
configuration: dataSource.configuration,
didSelectUrl: { [weak self] url in
self?.didSelectURLInTextFromBackend(url)
}
)
dataSource.configuration.style.configure(dataAccessNoticeViewController)
dataAccessNoticeViewController.present(on: self)
}
case .legalDatailsNotice:
let legalDetailsNoticeModel = dataSource.consent.legalDetailsNotice
let legalDetailsNoticeViewController = LegalDetailsNoticeViewController(
legalDetailsNotice: legalDetailsNoticeModel,
appearance: dataSource.manifest.appearance,
configuration: dataSource.configuration,
didSelectUrl: { [weak self] url in
self?.didSelectURLInTextFromBackend(url)
}
)
dataSource.configuration.style.configure(legalDetailsNoticeViewController)
legalDetailsNoticeViewController.present(on: self)
case .linkAccountPicker:
delegate?.consentViewController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class ErrorDataSource {
let error: Error
let referrerPane: FinancialConnectionsSessionManifest.NextPane
let manifest: FinancialConnectionsSessionManifest
var configuration: FinancialConnectionsSheet.Configuration
let reduceManualEntryProminenceInErrors: Bool
let analyticsClient: FinancialConnectionsAnalyticsClient
let institution: FinancialConnectionsInstitution?
Expand All @@ -21,13 +22,15 @@ final class ErrorDataSource {
error: Error,
referrerPane: FinancialConnectionsSessionManifest.NextPane,
manifest: FinancialConnectionsSessionManifest,
configuration: FinancialConnectionsSheet.Configuration,
reduceManualEntryProminenceInErrors: Bool,
analyticsClient: FinancialConnectionsAnalyticsClient,
institution: FinancialConnectionsInstitution?
) {
self.error = error
self.referrerPane = referrerPane
self.manifest = manifest
self.configuration = configuration
self.reduceManualEntryProminenceInErrors = reduceManualEntryProminenceInErrors
self.analyticsClient = analyticsClient
self.institution = institution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ final class ErrorViewController: UIViewController {
}()
return beginningOfSubtitle + " " + endOfSubtitle
}(),
contentView: nil
contentView: nil,
configuration: dataSource.configuration
),
footerView: PaneLayoutView.createFooterView(
primaryButtonConfiguration: primaryButtonConfiguration,
Expand Down Expand Up @@ -167,7 +168,8 @@ final class ErrorViewController: UIViewController {
)
}
}(),
contentView: nil
contentView: nil,
configuration: dataSource.configuration
),
footerView: PaneLayoutView.createFooterView(
primaryButtonConfiguration: primaryButtonConfiguration,
Expand Down Expand Up @@ -202,6 +204,7 @@ final class ErrorViewController: UIViewController {
errorView = TerminalErrorView(
allowManualEntry: dataSource.manifest.allowManualEntry,
appearance: dataSource.manifest.appearance,
configuration: dataSource.configuration,
didSelectManualEntry: { [weak self] in
guard let self else { return }
self.delegate?.errorViewControllerDidSelectManualEntry(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
protocol InstitutionDataSource: AnyObject {

var manifest: FinancialConnectionsSessionManifest { get }
var configuration: FinancialConnectionsSheet.Configuration { get }
var analyticsClient: FinancialConnectionsAnalyticsClient { get }
var featuredInstitutions: [FinancialConnectionsInstitution] { get }

Expand All @@ -24,6 +25,7 @@ class InstitutionAPIDataSource: InstitutionDataSource {
// MARK: - Properties

let manifest: FinancialConnectionsSessionManifest
let configuration: FinancialConnectionsSheet.Configuration
private let apiClient: any FinancialConnectionsAPI
private let clientSecret: String
let analyticsClient: FinancialConnectionsAnalyticsClient
Expand All @@ -33,11 +35,13 @@ class InstitutionAPIDataSource: InstitutionDataSource {

init(
manifest: FinancialConnectionsSessionManifest,
configuration: FinancialConnectionsSheet.Configuration,
apiClient: any FinancialConnectionsAPI,
clientSecret: String,
analyticsClient: FinancialConnectionsAnalyticsClient
) {
self.manifest = manifest
self.configuration = configuration
self.apiClient = apiClient
self.clientSecret = clientSecret
self.analyticsClient = analyticsClient
Expand Down
Loading