Skip to content

Commit

Permalink
Merge pull request #1561 from stripe-ios/kg-tintconsent
Browse files Browse the repository at this point in the history
Financial Connections: started client-side-tinting Consent and Data Access View icons.
  • Loading branch information
kgaidis-stripe authored Nov 1, 2022
2 parents 2469d9a + c263c2e commit f1e8633
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
6A0019D82880865E009D662A /* StringExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0019D72880865E009D662A /* StringExtensionsTests.swift */; };
6A0019DC2885EAAA009D662A /* stripe_logo@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6A0019DB2885EAAA009D662A /* stripe_logo@3x.png */; };
6A0019DE2886F3B9009D662A /* UIViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0019DD2886F3B9009D662A /* UIViewController+Extensions.swift */; };
6A019888291192FE00418064 /* AlwaysTemplateImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A019887291192FE00418064 /* AlwaysTemplateImageView.swift */; };
6A038F09288F040800D3331D /* ReusableInformationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A038F08288F040800D3331D /* ReusableInformationView.swift */; };
6A038F0C288F2CD300D3331D /* PartnerAuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A038F0B288F2CD300D3331D /* PartnerAuthViewController.swift */; };
6A038F0E28903F3D00D3331D /* PrepaneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A038F0D28903F3D00D3331D /* PrepaneView.swift */; };
Expand Down Expand Up @@ -282,6 +283,7 @@
6A0019D72880865E009D662A /* StringExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensionsTests.swift; sourceTree = "<group>"; };
6A0019DB2885EAAA009D662A /* stripe_logo@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "stripe_logo@3x.png"; sourceTree = "<group>"; };
6A0019DD2886F3B9009D662A /* UIViewController+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Extensions.swift"; sourceTree = "<group>"; };
6A019887291192FE00418064 /* AlwaysTemplateImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlwaysTemplateImageView.swift; sourceTree = "<group>"; };
6A038F08288F040800D3331D /* ReusableInformationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReusableInformationView.swift; sourceTree = "<group>"; };
6A038F0B288F2CD300D3331D /* PartnerAuthViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartnerAuthViewController.swift; sourceTree = "<group>"; };
6A038F0D28903F3D00D3331D /* PrepaneView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrepaneView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -821,6 +823,7 @@
6A99EF6528E708D200C76293 /* Button+Extensions.swift */,
6AE3F32E28EDF6B10079FD59 /* AuthFlowHelpers.swift */,
6A90861B290C82A20076CF12 /* TimeInterval+Extensions.swift */,
6A019887291192FE00418064 /* AlwaysTemplateImageView.swift */,
);
path = Shared;
sourceTree = "<group>";
Expand Down Expand Up @@ -1045,6 +1048,7 @@
6A50F0DF28F8649100214753 /* FinancialConnectionsAnalyticsClient.swift in Sources */,
3C3ADCBA2800C1E0008C24EF /* BankAccountToken.swift in Sources */,
6A99EF6428E5CFBD00C76293 /* AccountNumberRetrievalErrorView.swift in Sources */,
6A019888291192FE00418064 /* AlwaysTemplateImageView.swift in Sources */,
3CAD99C0284E438C00B163EB /* FinancialConnectionsNavigationController.swift in Sources */,
6A2318D928B57E5100F2A7D8 /* ManualEntryTextField.swift in Sources */,
6A59FCA628B7BD7100F0F33E /* ManualEntryFooterView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private func CreateLabelView(
iconUrl: String?,
action: @escaping (URL) -> Void
) -> UIView {
let imageView = UIImageView()
let imageView = AlwaysTemplateImageView(tintColor: .textPrimary)
imageView.contentMode = .scaleAspectFit
imageView.setImage(with: iconUrl)
imageView.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -89,7 +89,7 @@ private struct ConsentBodyViewUIViewRepresentable: UIViewRepresentable {
ConsentBodyView(
bulletItems: [
FinancialConnectionsConsent.Body.BulletItem(
icon: FinancialConnectionsImage(default: nil),
icon: FinancialConnectionsImage(default: "https://b.stripecdn.com/connections-statics-srv/assets/SailIcon--reserve-primary-3x.png"),
content: "Stripe will allow Goldilocks to access only the [data requested](https://www.stripe.com). We never share your login details with them."
),
FinancialConnectionsConsent.Body.BulletItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AlwaysTemplateImageView.swift
// StripeFinancialConnections
//
// Created by Krisjanis Gaidis on 11/1/22.
// Copyright © 2022 Stripe, Inc. All rights reserved.
//

import Foundation
import UIKit

// A simple `UIImageView` subclass that ensures that every image that
// is set is marked as `alwaysTemplate` so the `image` tint color could
// be adjusted.
//
// This is helpful when images are returned from backend and we want to tint them.
final class AlwaysTemplateImageView: UIImageView {

init(tintColor: UIColor) {
super.init(image: nil)
self.tintColor = tintColor
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override var image: UIImage? {
set {
super.image = newValue?.withRenderingMode(.alwaysTemplate)
}
get {
return super.image
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private func CreateBulletinView(
iconUrl: String?,
didSelectURL: @escaping (URL) -> Void
) -> UIView {
let imageView = UIImageView()
let imageView = AlwaysTemplateImageView(tintColor: .textSuccess)
imageView.contentMode = .scaleAspectFit
imageView.setImage(with: iconUrl)
imageView.translatesAutoresizingMaskIntoConstraints = false
Expand Down

0 comments on commit f1e8633

Please sign in to comment.