Skip to content

Commit 4c5b94c

Browse files
authored
feat: Accelerated Checkouts (#230)
* Add support for Accelerated Checkouts * Handle version checkout in tsx component, update tests * Bump package version to 3.4.0-rc.1 * Improvements * Handle runtime config validation errors, add tests * Export RenderStateChangeEvent
1 parent 84ac5f2 commit 4c5b94c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2313
-384
lines changed

.github/actions/install-cocoapods/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ runs:
2323
with:
2424
path: |
2525
sample/ios/Pods
26-
key: ${{ runner.os }}-cocoapods-ruby-${{ inputs.ruby-version }}-${{ hashFiles('sample/ios/Podfile.lock', 'sample/Gemfile.lock', 'package.json', 'sample/package.json', 'modules/@shopify/checkout-sheet-kit/package.json', 'yarn.lock') }}
26+
key: ${{ runner.os }}-cocoapods-ruby-${{ inputs.ruby-version }}-${{ hashFiles('sample/ios/Podfile.lock', 'sample/Gemfile.lock', 'sample/Gemfile', 'package.json', 'sample/package.json', 'modules/@shopify/checkout-sheet-kit/package.json', 'yarn.lock') }}
2727

2828
- name: Install cocoapods
29-
if: steps.cache-cocoapods.outputs.cache-hit != 'true'
3029
shell: bash
3130
env:
3231
NO_FLIPPER: "1"
@@ -36,5 +35,5 @@ runs:
3635
cd sample
3736
bundle install
3837
cd ios
39-
NO_FLIPPER=1 bundle exec pod install --deployment --repo-update
38+
bundle exec pod install --deployment --repo-update
4039
cd $ROOT

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,5 @@ jobs:
160160
ruby-version: ${{ env.RUBY_VERSION }}
161161

162162
- name: Run Swift tests
163-
timeout-minutes: 15
164-
# If turbo has already cached the build it will return instantly here
165163
run: |
166-
yarn turbo run test:ios --cache-dir=".turbo" --no-daemon
164+
yarn sample test:ios

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ disabled_rules:
88
- opening_brace
99
- function_body_length
1010
- trailing_comma
11+
- function_parameter_count
1112

1213
opt_in_rules:
1314
- array_init

dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ up:
2525
2626
packages:
2727
- xcode
28+
- swiftlint
2829

2930
check:
30-
lint_swift: yarn module lint:swift
31+
lint_swift: ./scripts/lint_swift
3132
lint_module: yarn module lint
3233
lint_sample: yarn sample lint
3334

modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Pod::Spec.new do |s|
2020
s.source_files = "ios/*.{h,m,mm,swift}"
2121

2222
s.dependency "React-Core"
23-
s.dependency "ShopifyCheckoutSheetKit", "~> 3.3.0"
23+
s.dependency "ShopifyCheckoutSheetKit", "~> 3.4.0-rc.5"
24+
s.dependency "ShopifyCheckoutSheetKit/AcceleratedCheckouts", "~> 3.4.0-rc.5"
2425

2526
if fabric_enabled
2627
install_modules_dependencies(s)
@@ -38,5 +39,5 @@ Pod::Spec.new do |s|
3839
s.dependency "RCTRequired"
3940
s.dependency "RCTTypeSafety"
4041
s.dependency "ReactCommon/turbomodule/core"
41-
end
42+
end
4243
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BasedOnStyle: LLVM
2+
Language: ObjC
3+
UseTab: Never
4+
IndentWidth: 2
5+
ContinuationIndentWidth: 2
6+
ColumnLimit: 120
7+
8+
# Keep long macro calls (e.g., RCT_EXTERN_METHOD) readable
9+
AlignAfterOpenBracket: DontAlign
10+
BinPackArguments: false
11+
BinPackParameters: false
12+
PenaltyBreakBeforeFirstCallParameter: 200
13+
ReflowComments: false
14+
15+
# Objective-C specifics
16+
ObjCSpaceAfterProperty: true
17+
ObjCSpaceBeforeProtocolList: true
18+
ObjCBreakBeforeNestedBlockParam: true
19+
PointerAlignment: Left
20+
BreakBeforeBraces: Attach
21+
SpaceBeforeParens: ControlStatements
22+
SortIncludes: false
23+
24+
# Treat common React Native macros as statements for nicer wrapping
25+
StatementMacros:
26+
- RCT_EXTERN_METHOD
27+
- RCT_EXTERN_MODULE
28+
- RCT_EXPORT_VIEW_PROPERTY
29+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
MIT License
3+
4+
Copyright 2023 - Present, Shopify Inc.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
import _PassKit_SwiftUI
25+
import Foundation
26+
import PassKit
27+
import SwiftUI
28+
29+
// MARK: - Apple Pay Button
30+
31+
@available(iOS 16.0, *)
32+
extension PayWithApplePayButtonLabel {
33+
static func from(_ string: String?, fallback: PayWithApplePayButtonLabel = .plain) -> PayWithApplePayButtonLabel {
34+
guard let string else {
35+
return fallback
36+
}
37+
return map[string] ?? .plain
38+
}
39+
40+
init?(fromString string: String?) {
41+
guard let string,
42+
let label = Self.map[string]
43+
else {
44+
return nil
45+
}
46+
self = label
47+
}
48+
49+
private static let map: [String: PayWithApplePayButtonLabel] = [
50+
"addMoney": .addMoney,
51+
"book": .book,
52+
"buy": .buy,
53+
"checkout": .checkout,
54+
"continue": .continue,
55+
"contribute": .contribute,
56+
"donate": .donate,
57+
"inStore": .inStore,
58+
"order": .order,
59+
"plain": .plain,
60+
"reload": .reload,
61+
"rent": .rent,
62+
"setUp": .setUp,
63+
"subscribe": .subscribe,
64+
"support": .support,
65+
"tip": .tip,
66+
"topUp": .topUp
67+
]
68+
}

0 commit comments

Comments
 (0)