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

FC Networking: implemented broken account support #2578

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct FinancialConnectionsPartnerAccount: Decodable {
return nil
}
}
var isBroken: Bool {
return (status != "active")
}
}

struct FinancialConnectionsAuthSessionAccounts: Decodable {
Expand All @@ -41,4 +44,6 @@ struct FinancialConnectionsAuthSessionAccounts: Decodable {

struct FinancialConnectionsNetworkedAccountsResponse: Decodable {
let data: [FinancialConnectionsPartnerAccount]
let repairAuthorizationEnabled: Bool?
let partnerToCoreAuths: [String:String]?
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct FinancialConnectionsSessionManifest: Decodable {
case accountPicker = "account_picker"
case attachLinkedPaymentAccount = "attach_linked_payment_account"
case authOptions = "auth_options"
case bankAuthRepair = "bank_auth_repair"
case consent = "consent"
case institutionPicker = "institution_picker"
case linkAccountPicker = "link_account_picker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ extension FinancialConnectionsAnalyticsClient {
_ viewController: UIViewController?
) -> FinancialConnectionsSessionManifest.NextPane {
switch viewController {
// TODO(kgaidis): add bank repair
case is ConsentViewController:
return .consent
case is InstitutionPickerViewController:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
//
// FinancialConnectionsFont.swift
// StripeFinancialConnections
//
// Created by Krisjanis Gaidis on 5/2/23.
//

import Foundation
import UIKit

// A wrapper around `UIFont` that allows us to specify a `lineHeight`.
// `UIFont` does not support modifying `lineHeight` so this struct
// helps us to easily pass around font + line height.
struct FinancialConnectionsFont {

let uiFont: UIFont
let lineHeight: CGFloat

// An estimated "top padding of the font character"
var topPadding: CGFloat {
return max(0, ((lineHeight - uiFont.lineHeight) / 2)) + (uiFont.ascender - uiFont.capHeight)
}

enum HeadingToken {
/// 20 size / 28 line height / 700 weight
case medium
/// 24 size / 32 line height / 700 weight
case large
}
static func heading(_ token: HeadingToken) -> FinancialConnectionsFont {
let font: UIFont
let lineHeight: CGFloat
let appleTextStyle: UIFont.TextStyle
switch token {
case .medium:
font = UIFont.systemFont(ofSize: 20, weight: .bold)
lineHeight = 28
appleTextStyle = .title3
case .large:
font = UIFont.systemFont(ofSize: 24, weight: .bold)
lineHeight = 32
appleTextStyle = .title2
}
return .create(font: font, lineHeight: lineHeight, appleTextStyle: appleTextStyle)
}

enum BodyToken {
/// 14 size / 20 line height / 400 weight
case small
/// 14 size / 20 line height / 600 weight
case smallEmphasized
/// 16 size / 24 line height / 400 weight
case medium
/// 16 size / 24 line height / 600 weight
case mediumEmphasized
}
static func body(_ token: BodyToken) -> FinancialConnectionsFont {
let font: UIFont
let lineHeight: CGFloat
let appleTextStyle: UIFont.TextStyle
switch token {
case .small:
font = UIFont.systemFont(ofSize: 14, weight: .regular)
lineHeight = 20
appleTextStyle = .footnote
case .smallEmphasized:
font = UIFont.systemFont(ofSize: 14, weight: .semibold)
lineHeight = 20
appleTextStyle = .footnote
case .medium:
font = UIFont.systemFont(ofSize: 16, weight: .regular)
lineHeight = 24
appleTextStyle = .callout
case .mediumEmphasized:
font = UIFont.systemFont(ofSize: 16, weight: .semibold)
lineHeight = 24
appleTextStyle = .callout
}
return .create(font: font, lineHeight: lineHeight, appleTextStyle: appleTextStyle)
}

enum LabelToken {
/// 12 size / 16 line height / 400 weight
case small
/// 12 size / 16 line height / 600 weight
case smallEmphasized
/// 14 size / 20 line height / 400 weight
case medium
/// 14 size / 20 line height / 600 weight
case mediumEmphasized
/// 16 size / 24 line height / 400 weight
case large
/// 16 size / 24 line height / 600 weight
case largeEmphasized
}
static func label(_ token: LabelToken) -> FinancialConnectionsFont {
let font: UIFont
let lineHeight: CGFloat
let appleTextStyle: UIFont.TextStyle
switch token {
case .small:
font = UIFont.systemFont(ofSize: 12, weight: .regular)
lineHeight = 16
appleTextStyle = .caption1
case .smallEmphasized:
font = UIFont.systemFont(ofSize: 12, weight: .semibold)
lineHeight = 16
appleTextStyle = .caption1
case .medium:
font = UIFont.systemFont(ofSize: 14, weight: .regular)
lineHeight = 20
appleTextStyle = .footnote
case .mediumEmphasized:
font = UIFont.systemFont(ofSize: 14, weight: .semibold)
lineHeight = 20
appleTextStyle = .footnote
case .large:
font = UIFont.systemFont(ofSize: 16, weight: .regular)
lineHeight = 24
appleTextStyle = .callout
case .largeEmphasized:
font = UIFont.systemFont(ofSize: 16, weight: .semibold)
lineHeight = 24
appleTextStyle = .callout
}
return .create(font: font, lineHeight: lineHeight, appleTextStyle: appleTextStyle)
}

enum CodeToken {
/// 16 size / 24 line height / 600 weight
case largeEmphasized
}
static func code(_ token: CodeToken) -> FinancialConnectionsFont {
let font: UIFont
let lineHeight: CGFloat
let appleTextStyle: UIFont.TextStyle
switch token {
case .largeEmphasized:
font = UIFont.monospacedSystemFont(ofSize: 16, weight: .semibold)
lineHeight = 24
appleTextStyle = .body
}
return .create(font: font, lineHeight: lineHeight, appleTextStyle: appleTextStyle)
}

private static func create(font: UIFont, lineHeight: CGFloat, appleTextStyle: UIFont.TextStyle) -> FinancialConnectionsFont {
let scaledFont = scaleFont(font, appleTextStyle: appleTextStyle)
return FinancialConnectionsFont(
uiFont: scaledFont,
lineHeight: scaleLineHeight(lineHeight, font: font, scaledFont: scaledFont)
)
}

private static func scaleFont(_ font: UIFont, appleTextStyle: UIFont.TextStyle) -> UIFont {
let metrics = UIFontMetrics(forTextStyle: appleTextStyle)
let scaledFont = metrics.scaledFont(for: font)
return scaledFont
}

private static func scaleLineHeight(_ lineHeight: CGFloat, font: UIFont, scaledFont: UIFont) -> CGFloat {
return lineHeight * (scaledFont.pointSize / max(1, font.pointSize))
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ final class AccountPickerFooterView: UIView {

let verticalStackView = HitTestStackView(
arrangedSubviews: [
CreateDataAccessDisclosureView(
MerchantDataAccessView(
isStripeDirect: isStripeDirect,
businessName: businessName,
permissions: permissions,
isNetworking: false,
font: .body(.small),
boldFont: .body(.smallEmphasized),
alignCenter: true,
didSelectLearnMore: didSelectMerchantDataAccessLearnMore
),
linkAccountsButton,
]
)
verticalStackView.axis = .vertical
verticalStackView.spacing = 20
verticalStackView.spacing = 24
addSubview(verticalStackView)
addAndPinSubviewToSafeArea(verticalStackView)

Expand Down Expand Up @@ -100,33 +104,3 @@ final class AccountPickerFooterView: UIView {
}
}
}

@available(iOSApplicationExtension, unavailable)
private func CreateDataAccessDisclosureView(
isStripeDirect: Bool,
businessName: String?,
permissions: [StripeAPI.FinancialConnectionsAccount.Permissions],
didSelectLearnMore: @escaping () -> Void
) -> UIView {
let stackView = HitTestStackView(
arrangedSubviews: [
MerchantDataAccessView(
isStripeDirect: isStripeDirect,
businessName: businessName,
permissions: permissions,
isNetworking: false,
didSelectLearnMore: didSelectLearnMore
),
]
)
stackView.isLayoutMarginsRelativeArrangement = true
stackView.directionalLayoutMargins = NSDirectionalEdgeInsets(
top: 10,
leading: 12,
bottom: 10,
trailing: 12
)
stackView.backgroundColor = .backgroundContainer
stackView.layer.cornerRadius = 8
return stackView
}