Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WCM] Cocoapods support - backport APIs #1222

Merged
merged 2 commits into from
Nov 8, 2023
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
22 changes: 21 additions & 1 deletion Sources/WalletConnectModal/Extensions/View+Backport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

extension View {

#if os(iOS)
#if os(iOS) || os(tvOS)

/// A backwards compatible wrapper for iOS 14 `onChange`
@ViewBuilder
Expand All @@ -27,4 +27,24 @@ extension View {
}

#endif

#if os(iOS) || os(macOS)

@ViewBuilder
func onTapGestureBackported(count: Int = 1, perform action: @escaping () -> Void) -> some View {
self
}

#elseif os(tvOS)

@ViewBuilder
func onTapGestureBackported(count: Int = 1, perform action: @escaping () -> Void) -> some View {
if #available(tvOS 16.0, *) {
self.onTapGesture(count: count, perform: action)
} else {
self
}
}

#endif
}
12 changes: 4 additions & 8 deletions Sources/WalletConnectModal/Modal/ModalContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ struct ModalContainerView: View {
Color.thickOverlay
.colorScheme(.light)
.opacity(showModal ? 1 : 0)
.transform {
#if os(iOS)
$0.onTapGesture {
withAnimation {
showModal = false
}
}
#endif
.onTapGestureBackported {
withAnimation {
showModal = false
}
}
)
.edgesIgnoringSafeArea(.all)
Expand Down
10 changes: 7 additions & 3 deletions Sources/WalletConnectModal/Modal/Screens/QRCodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ struct QRCodeView: View {
)
)

return doc.imageUI(
size, label: Text("QR code with URI")
)!
if #available(macOS 11, *) {
return doc.imageUI(
size, label: Text("QR code with URI")
)!
} else {
return Image.init(sfSymbolName: "qrcode")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct WalletDetail: View {
.contentShape(Rectangle())
.padding(.horizontal, 8)
.padding(.vertical, 8)
.onTapGesture {
.onTapGestureBackported {
withAnimation(.easeInOut(duration: 0.15)) {
viewModel.preferredPlatform = item
}
Expand Down Expand Up @@ -185,7 +185,7 @@ struct WalletDetail: View {
.foregroundColor(.foreground2)
}
}
.onTapGesture {
.onTapGestureBackported {
viewModel.handle(.didTapAppStore)
}
}
Expand Down
32 changes: 12 additions & 20 deletions Sources/WalletConnectModal/Modal/Screens/WalletList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ struct WalletList: View {

if wallets.count > numberOfColumns * 2 {
viewAllItem()
.transform {
#if os(iOS)
$0.onTapGesture {
withAnimation {
navigateTo(.viewAll)
}
}
#endif
.onTapGestureBackported {
withAnimation {
navigateTo(.viewAll)
}
}
}
}
Expand Down Expand Up @@ -181,19 +177,15 @@ struct WalletList: View {
.padding(.horizontal, 12)
}
.frame(maxWidth: 80, maxHeight: 96)
.transform {
#if os(iOS)
$0.onTapGesture {
withAnimation {
navigateTo(.walletDetail(wallet))

// Small delay to let detail screen present before actually deeplinking
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
onListingTap(wallet)
}
}
.onTapGestureBackported {
withAnimation {
navigateTo(.walletDetail(wallet))

// Small delay to let detail screen present before actually deeplinking
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
onListingTap(wallet)
}
#endif
}
}
}
}
2 changes: 1 addition & 1 deletion Sources/WalletConnectModal/UI/Common/Web3ModalPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct PreviewWeb3ModalPicker: View {
.contentShape(Rectangle())
.padding(.horizontal, 8)
.padding(.vertical, 8)
.onTapGesture {
.onTapGestureBackported {
withAnimation(.easeInOut(duration: 0.15)) {
selectedItem = item
}
Expand Down
4 changes: 4 additions & 0 deletions WalletConnectSwiftV2.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,9 @@ Pod::Spec.new do |spec|
ss.source_files = 'Sources/WalletConnectModal/**/*.{h,m,swift}'
ss.dependency 'WalletConnectSwiftV2/WalletConnectSign'
ss.dependency 'DSF_QRCode', '~> 16.1.1'
ss.ios.deployment_target = ios_deployment_target
ss.tvos.deployment_target = tvos_deployment_target
# TODO: Re-add macOS support once
ss.osx.deployment_target = ''
end
end