Skip to content

Commit ba10203

Browse files
committed
Sync iOS with React Native 0.57.1
1 parent 7adf987 commit ba10203

36 files changed

+2104
-841
lines changed

packages/stripe_ios/ios/stripe_ios.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
33
# Run `pod lib lint stripe_ios.podspec' to validate before publishing.
44
#
5-
stripe_version = '~> 24.25.0'
5+
stripe_version = '~> 25.0.1'
66
Pod::Spec.new do |s|
77
s.name = 'stripe_ios'
88
s.version = '0.0.1'

packages/stripe_ios/ios/stripe_ios/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
.library(name: "stripe-ios", targets: ["stripe_ios"])
1313
],
1414
dependencies: [
15-
.package(url: "https://github.com/stripe/stripe-ios-spm", exact: "24.25.0")
15+
.package(url: "https://github.com/stripe/stripe-ios-spm", exact: "25.0.1")
1616
],
1717
targets: [
1818
.target(

packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/AddressSheet/AddressSheetUtils.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class AddressSheetUtils {
6767
}
6868

6969
internal class func getFieldConfiguration(input: String?, default: AddressViewController.Configuration.AdditionalFields.FieldConfiguration) -> AddressViewController.Configuration.AdditionalFields.FieldConfiguration {
70-
switch (input) {
70+
switch input {
7171
case "optional":
7272
return .optional
7373
case "required":
@@ -79,7 +79,7 @@ class AddressSheetUtils {
7979
}
8080
}
8181

82-
internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable : Any] {
82+
internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable: Any] {
8383
return [
8484
"result": [
8585
"name": address.name ?? NSNull(),
@@ -93,7 +93,7 @@ class AddressSheetUtils {
9393
],
9494
"phone": address.phone ?? NSNull(),
9595
"isCheckboxSelected": address.isCheckboxSelected ?? NSNull(),
96-
] as [AnyHashable : Any]
96+
] as [AnyHashable: Any],
9797
]
9898
}
9999

packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/AddressSheet/AddressSheetView.swift

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,39 @@
77

88
import Foundation
99
import StripePaymentSheet
10-
import UIKit
1110

1211
@objc(AddressSheetView)
1312
public class AddressSheetView: UIView {
1413
@objc public var visible = false
1514
@objc public var presentationStyle: String = "popover"
1615
@objc public var animationStyle: String = ""
17-
@objc public var appearance: NSDictionary? = nil
18-
@objc public var defaultValues: NSDictionary? = nil
19-
@objc public var additionalFields: NSDictionary? = nil
16+
@objc public var appearance: NSDictionary?
17+
@objc public var defaultValues: NSDictionary?
18+
@objc public var additionalFields: NSDictionary?
2019
@objc public var allowedCountries: [String] = []
2120
@objc public var autocompleteCountries: [String] = []
22-
@objc public var primaryButtonTitle: String? = nil
23-
@objc public var sheetTitle: String? = nil
21+
@objc public var primaryButtonTitle: String?
22+
@objc public var sheetTitle: String?
2423
@objc public var onSubmitAction: RCTDirectEventBlock?
2524
@objc public var onErrorAction: RCTDirectEventBlock?
2625

2726
private var wasVisible = false
28-
private var addressViewController: AddressViewController? = nil
29-
internal var addressDetails: AddressViewController.AddressDetails? = nil
30-
27+
private var addressViewController: AddressViewController?
28+
internal var addressDetails: AddressViewController.AddressDetails?
29+
3130
override public init(frame: CGRect) {
3231
super.init(frame: frame)
3332
}
3433

3534
required init?(coder: NSCoder) {
3635
fatalError("init(coder:) has not been implemented")
3736
}
38-
37+
3938
@objc public func didSetProps() {
40-
if (visible && !wasVisible) {
39+
if visible && !wasVisible {
4140
presentAddressSheet()
4241
wasVisible = true
43-
} else if (!visible && wasVisible) {
42+
} else if !visible && wasVisible {
4443
addressViewController?.dismiss(animated: true)
4544
wasVisible = false
4645
}
@@ -51,11 +50,11 @@ public class AddressSheetView: UIView {
5150
// by the view component.
5251
self.didSetProps()
5352
}
54-
53+
5554
private func presentAddressSheet() {
56-
if (STPAPIClient.shared.publishableKey == nil) {
55+
if STPAPIClient.shared.publishableKey == nil {
5756
onErrorAction!(
58-
Errors.createError(ErrorType.Failed, "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.") as? [AnyHashable : Any]
57+
Errors.createError(ErrorType.Failed, "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.") as? [AnyHashable: Any]
5958
)
6059
return
6160
}
@@ -64,38 +63,38 @@ public class AddressSheetView: UIView {
6463
config = try buildAddressSheetConfiguration()
6564
} catch {
6665
onErrorAction!(
67-
Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable : Any]
66+
Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable: Any]
6867
)
6968
return
7069
}
71-
70+
7271
self.addressViewController = AddressViewController(
7372
configuration: config,
7473
delegate: self
7574
)
76-
75+
7776
let navigationController = UINavigationController(rootViewController: addressViewController!)
7877
navigationController.modalPresentationStyle = getModalPresentationStyle()
7978
navigationController.modalTransitionStyle = getModalTransitionStyle()
80-
let vc = findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
79+
let vc = findViewControllerPresenter(from: RCTKeyWindow()?.rootViewController ?? UIViewController())
8180
vc.present(navigationController, animated: true)
8281
}
83-
82+
8483
private func buildAddressSheetConfiguration() throws -> AddressViewController.Configuration {
8584
let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
86-
85+
8786
return AddressViewController.Configuration(
8887
defaultValues: AddressSheetUtils.buildDefaultValues(params: defaultValues),
8988
additionalFields: AddressSheetUtils.buildAdditionalFieldsConfiguration(params: additionalFields),
9089
allowedCountries: allowedCountries,
9190
appearance: appearanceConfiguration,
9291
buttonTitle: primaryButtonTitle,
9392
title: sheetTitle
94-
)
93+
)
9594
}
96-
95+
9796
private func getModalPresentationStyle() -> UIModalPresentationStyle {
98-
switch (presentationStyle) {
97+
switch presentationStyle {
9998
case "fullscreen":
10099
return .fullScreen
101100
case "pageSheet":
@@ -112,9 +111,9 @@ public class AddressSheetView: UIView {
112111
return .popover
113112
}
114113
}
115-
114+
116115
private func getModalTransitionStyle() -> UIModalTransitionStyle {
117-
switch (animationStyle) {
116+
switch animationStyle {
118117
case "flip":
119118
return .flipHorizontal
120119
case "curl":
@@ -136,7 +135,7 @@ extension AddressSheetView: AddressViewControllerDelegate {
136135
Errors.createError(
137136
ErrorType.Canceled,
138137
"The flow has been canceled."
139-
) as? [AnyHashable : Any]
138+
) as? [AnyHashable: Any]
140139
)
141140
return
142141
}

0 commit comments

Comments
 (0)