Skip to content

Commit

Permalink
Merge pull request #4975 from wikimedia/fix-apple-pay-button
Browse files Browse the repository at this point in the history
Fix Apple Pay button tap gesture bug
  • Loading branch information
l-olson1214 authored Sep 18, 2024
2 parents 13eefa2 + 3ea3b68 commit ee6667d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 36 deletions.
2 changes: 1 addition & 1 deletion WMFComponents/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "WMFComponents",
platforms: [.iOS(.v15)],
platforms: [.iOS(.v16)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import _PassKit_SwiftUI

public protocol WMFDonateDelegate: AnyObject {
func donateDidTapProblemsDonatingLink()
Expand Down Expand Up @@ -53,16 +54,18 @@ struct WMFDonateView: View {
}

Group {
WMFApplePayDonateButton(configuration: WMFApplePayDonateButton.Configuration(paymentButtonStyle: appEnvironment.theme.paymentButtonStyle))
.onTapGesture {
viewModel.textfieldViewModel.hasFocus = false
viewModel.logTappedApplePayButton()
viewModel.validateAndSubmit()
if let errorViewModel = viewModel.errorViewModel {
errorViewModel.hasAccessibilityFocus = true
}
PayWithApplePayButton(.donate) {
viewModel.textfieldViewModel.hasFocus = false
viewModel.logTappedApplePayButton()
viewModel.validateAndSubmit()
if let errorViewModel = viewModel.errorViewModel {
errorViewModel.hasAccessibilityFocus = true
}
.accessibilityHint(viewModel.accessibilityDonateButtonHint ?? "")
} fallback: {

}
.payWithApplePayButtonStyle(appEnvironment.theme.applePayPaymentButtonStyle)
.accessibilityHint(viewModel.accessibilityDonateButtonHint ?? "")
.frame(height: 42)
.padding([.leading, .trailing], sizeClassDonateButtonPadding)
Spacer()
Expand Down

This file was deleted.

9 changes: 4 additions & 5 deletions WMFComponents/Sources/WMFComponents/Style/WMFTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public struct WMFTheme: Equatable {
public let name: String
public let userInterfaceStyle: UIUserInterfaceStyle
public let keyboardAppearance: UIKeyboardAppearance
public let paymentButtonStyle: PKPaymentButtonStyle
public let text: UIColor
public let secondaryText: UIColor
public let link: UIColor
Expand Down Expand Up @@ -43,12 +42,15 @@ public struct WMFTheme: Equatable {
public var preferredColorScheme: ColorScheme {
return (self == WMFTheme.light || self == WMFTheme.sepia) ? .light : .dark
}

public var applePayPaymentButtonStyle: PayWithApplePayButtonStyle {
return (self == WMFTheme.light || self == WMFTheme.sepia) ? .black : .white
}

public static let light = WMFTheme(
name: "Light",
userInterfaceStyle: .light,
keyboardAppearance: .light,
paymentButtonStyle: .black,
text: WMFColor.gray700,
secondaryText: WMFColor.gray500,
link: WMFColor.blue600,
Expand Down Expand Up @@ -86,7 +88,6 @@ public struct WMFTheme: Equatable {
name: "Sepia",
userInterfaceStyle: .light,
keyboardAppearance: .light,
paymentButtonStyle: .black,
text: WMFColor.gray700,
secondaryText: WMFColor.taupe600,
link: WMFColor.blue600,
Expand Down Expand Up @@ -124,7 +125,6 @@ public struct WMFTheme: Equatable {
name: "Dark",
userInterfaceStyle: .dark,
keyboardAppearance: .dark,
paymentButtonStyle: .white,
text: WMFColor.gray100,
secondaryText: WMFColor.gray300,
link: WMFColor.blue300,
Expand Down Expand Up @@ -162,7 +162,6 @@ public struct WMFTheme: Equatable {
name: "Black",
userInterfaceStyle: .dark,
keyboardAppearance: .dark,
paymentButtonStyle: .white,
text: WMFColor.gray100,
secondaryText: WMFColor.gray300,
link: WMFColor.blue300,
Expand Down

0 comments on commit ee6667d

Please sign in to comment.