Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Add Mint to PATH
run: echo "${{ github.workspace }}/.mint/bin" >> "$GITHUB_PATH"

- run: ./Scripts/lint check --verbose
- run: ./Scripts/lint check --verbose --skip-pod

check-license-headers:
name: License Headers
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Render accelerated checkout buttons](#render-accelerated-checkout-buttons)
- [Customize wallet options](#customize-wallet-options)
- [Modify the Apple Pay button label](#modify-the-apple-pay-button-label)
- [Customize the Apple Pay button style](#customize-the-apple-pay-button-style)
- [Customize button corners](#customize-button-corners)
- [Handle loading, errors, and lifecycle events](#handle-loading-errors-and-lifecycle-events)
- [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -735,6 +736,15 @@ AcceleratedCheckoutButtons(cartID: cartID)
.applePayLabel(.buy)
```

#### Customize the Apple Pay button style

Use `.applePayStyle(_:)` to set the color style of the Apple Pay button. The modifier accepts a `PayWithApplePayButtonStyle` value. The default is `.automatic`, which adapts to the current appearance (light/dark mode).

```swift
AcceleratedCheckoutButtons(cartID: cartID)
.applePayStyle(.whiteOutline)
```

#### Customize button corners

The `.cornerRadius(_:)` modifier lets you match the buttons to other calls-to-action in your app. Buttons default to an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
},
"Adding..." : {

},
"Apple Pay" : {

},
"Authentication" : {
"comment" : "A section header in the settings view.",
Expand Down Expand Up @@ -71,6 +74,9 @@
},
"Clear logs" : {

},
"Configures the visual style of the Apple Pay button." : {

},
"Events" : {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ class CartViewController: UIViewController, UITableViewDelegate, UITableViewData
private func setupAcceleratedCheckoutButtons() {
guard let cartId = CartManager.shared.cart?.id else { return }

let savedStyle = UserDefaults.standard.string(forKey: AppStorageKeys.applePayStyle.rawValue)
.flatMap(ApplePayStyleOption.init(rawValue:)) ?? .automatic

let acceleratedCheckoutButtonsView = AcceleratedCheckoutButtons(cartID: cartId)
.applePayStyle(savedStyle.style)
.wallets([.shopPay, .applePay])
.cornerRadius(10)
.onComplete { _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct CartView: View {
@ObservedObject var cartManager: CartManager = .shared
@ObservedObject var config: AppConfiguration = appConfiguration

@AppStorage(AppStorageKeys.applePayStyle.rawValue)
var applePayStyle: ApplePayStyleOption = .automatic

var body: some View {
if let lines = cartManager.cart?.lines.nodes {
ZStack(alignment: .bottom) {
Expand All @@ -51,6 +54,7 @@ struct CartView: View {
VStack(spacing: DesignSystem.buttonSpacing) {
if let cartId = cartManager.cart?.id {
AcceleratedCheckoutButtons(cartID: cartId)
.applePayStyle(applePayStyle.style)
.wallets([.shopPay, .applePay])
.cornerRadius(DesignSystem.cornerRadius)
.onComplete { _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct ProductView: View {
@State private var descriptionExpanded: Bool = false
@State private var addedToCart: Bool = false

@AppStorage(AppStorageKeys.applePayStyle.rawValue)
var applePayStyle: ApplePayStyleOption = .automatic

init(product: Product) {
_product = State(initialValue: product)
}
Expand Down Expand Up @@ -134,6 +137,7 @@ struct ProductView: View {

if variant.availableForSale {
AcceleratedCheckoutButtons(variantID: variant.id, quantity: 1)
.applePayStyle(applePayStyle.style)
.wallets([.applePay])
.cornerRadius(DesignSystem.cornerRadius)
.onFail { error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import Combine
import PassKit
@preconcurrency import ShopifyAcceleratedCheckouts
@preconcurrency import ShopifyCheckoutSheetKit
import SwiftUI
Expand All @@ -30,6 +31,7 @@ enum AppStorageKeys: String {
case acceleratedCheckoutsLogLevel
case checkoutSheetKitLogLevel
case buyerIdentityMode
case applePayStyle
}

struct SettingsView: View {
Expand All @@ -51,6 +53,9 @@ struct SettingsView: View {
}
}

@AppStorage(AppStorageKeys.applePayStyle.rawValue)
var applePayStyle: ApplePayStyleOption = .automatic

@State private var preloadingEnabled = ShopifyCheckoutSheetKit.configuration.preloading.enabled
@State private var logs: [String?] = LogReader.shared.readLogs() ?? []
@State private var selectedColorScheme = ShopifyCheckoutSheetKit.configuration.colorScheme
Expand Down Expand Up @@ -120,6 +125,26 @@ struct SettingsView: View {
}
}

Section(
header: Text("Apple Pay"),
footer: Text("Configures the visual style of the Apple Pay button.")
) {
ForEach(ApplePayStyleOption.allCases, id: \.self) { option in
HStack {
Text(option.title)
Spacer()
if option == applePayStyle {
Text("\u{2713}")
}
}
.background(Color.clear)
.contentShape(Rectangle())
.onTapGesture {
applePayStyle = option
}
}
}

Section(header: Text("Logging")) {
Picker(
"Accelerated Checkouts",
Expand Down Expand Up @@ -307,6 +332,31 @@ extension Configuration.ColorScheme {
}
}

enum ApplePayStyleOption: String, CaseIterable {
case automatic
case black
case white
case whiteOutline

var title: String {
switch self {
case .automatic: return "Automatic"
case .black: return "Black"
case .white: return "White"
case .whiteOutline: return "White Outline"
}
}

var style: PayWithApplePayButtonStyle {
switch self {
case .automatic: return .automatic
case .black: return .black
case .white: return .white
case .whiteOutline: return .whiteOutline
}
}
}

#Preview {
SettingsView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct ButtonSet: View {
variantID: productVariant.id,
quantity: firstVariantQuantity
)
.applePayStyle(.whiteOutline)
.applePayLabel(.buy)
.cornerRadius(24)
.wallets([.applePay, .shopPay])
Expand Down
23 changes: 23 additions & 0 deletions Scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,26 @@ if [ $FORMAT_STATUS -ne 0 ]; then
print_linting_error "SwiftFormat"
exit 1
fi

# Run CocoaPods lint (check mode only, not applicable to fix)
# Skip with --skip-pod (e.g. in CI where pod lint runs as a separate job)
SKIP_POD=false
if [[ "$*" == *"--skip-pod"* ]]; then
SKIP_POD=true
fi

if [[ "$MODE" == "check" && "$SKIP_POD" == "false" ]]; then
echo ""
echo "🔍 Running CocoaPods lint..."
bundle exec pod lib lint --allow-warnings
POD_STATUS=$?

if [ $POD_STATUS -eq 0 ]; then
echo "✅ CocoaPods lint exit status: $POD_STATUS"
else
echo "❌ CocoaPods lint exit status: $POD_STATUS"
echo "❌ CocoaPods detected issues that need to be fixed."
echo "🔧 Run 'bundle exec pod lib lint --allow-warnings --verbose' for details"
exit 1
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public struct AcceleratedCheckoutButtons: View {

/// The Apple Pay button label style
private var applePayLabel: PayWithApplePayButtonLabel = .plain
private var applePayStyle: PayWithApplePayButtonStyle = .automatic

@State private var shopSettings: ShopSettings?
@State private var currentRenderState: RenderState = .loading {
Expand Down Expand Up @@ -93,7 +94,8 @@ public struct AcceleratedCheckoutButtons: View {
ApplePayButton(
identifier: identifier,
eventHandlers: eventHandlers,
cornerRadius: cornerRadius
cornerRadius: cornerRadius,
style: applePayStyle
)
.label(applePayLabel)
case .shopPay:
Expand Down Expand Up @@ -137,6 +139,12 @@ public struct AcceleratedCheckoutButtons: View {

@available(iOS 16.0, *)
extension AcceleratedCheckoutButtons {
public func applePayStyle(_ color: PayWithApplePayButtonStyle) -> AcceleratedCheckoutButtons {
var view = self
view.applePayStyle = color
return view
}

public func applePayLabel(_ label: PayWithApplePayButtonLabel) -> AcceleratedCheckoutButtons {
var view = self
view.applePayLabel = label
Expand Down
Loading
Loading