diff --git a/Sources/WalletConnectModal/Extensions/View+Backport.swift b/Sources/WalletConnectModal/Extensions/View+Backport.swift index b93de0e16..3c40e44ba 100644 --- a/Sources/WalletConnectModal/Extensions/View+Backport.swift +++ b/Sources/WalletConnectModal/Extensions/View+Backport.swift @@ -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 @@ -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 } diff --git a/Sources/WalletConnectModal/Modal/ModalContainerView.swift b/Sources/WalletConnectModal/Modal/ModalContainerView.swift index ab24e444b..ba5ffb9cf 100644 --- a/Sources/WalletConnectModal/Modal/ModalContainerView.swift +++ b/Sources/WalletConnectModal/Modal/ModalContainerView.swift @@ -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) diff --git a/Sources/WalletConnectModal/Modal/Screens/QRCodeView.swift b/Sources/WalletConnectModal/Modal/Screens/QRCodeView.swift index ab78e24cb..e889fd5c7 100644 --- a/Sources/WalletConnectModal/Modal/Screens/QRCodeView.swift +++ b/Sources/WalletConnectModal/Modal/Screens/QRCodeView.swift @@ -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") + } } } diff --git a/Sources/WalletConnectModal/Modal/Screens/WalletDetail/WalletDetail.swift b/Sources/WalletConnectModal/Modal/Screens/WalletDetail/WalletDetail.swift index 2fb5f1bff..6ff5a740a 100644 --- a/Sources/WalletConnectModal/Modal/Screens/WalletDetail/WalletDetail.swift +++ b/Sources/WalletConnectModal/Modal/Screens/WalletDetail/WalletDetail.swift @@ -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 } @@ -185,7 +185,7 @@ struct WalletDetail: View { .foregroundColor(.foreground2) } } - .onTapGesture { + .onTapGestureBackported { viewModel.handle(.didTapAppStore) } } diff --git a/Sources/WalletConnectModal/Modal/Screens/WalletList.swift b/Sources/WalletConnectModal/Modal/Screens/WalletList.swift index 7ea02d286..55ba54c2a 100644 --- a/Sources/WalletConnectModal/Modal/Screens/WalletList.swift +++ b/Sources/WalletConnectModal/Modal/Screens/WalletList.swift @@ -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) + } } } } @@ -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 + } } } } diff --git a/Sources/WalletConnectModal/UI/Common/Web3ModalPicker.swift b/Sources/WalletConnectModal/UI/Common/Web3ModalPicker.swift index 31ba098ad..49ce87219 100644 --- a/Sources/WalletConnectModal/UI/Common/Web3ModalPicker.swift +++ b/Sources/WalletConnectModal/UI/Common/Web3ModalPicker.swift @@ -104,7 +104,7 @@ struct PreviewWeb3ModalPicker: View { .contentShape(Rectangle()) .padding(.horizontal, 8) .padding(.vertical, 8) - .onTapGesture { + .onTapGestureBackported { withAnimation(.easeInOut(duration: 0.15)) { selectedItem = item } diff --git a/WalletConnectSwiftV2.podspec b/WalletConnectSwiftV2.podspec index 29cf98ffe..9cf68e052 100644 --- a/WalletConnectSwiftV2.podspec +++ b/WalletConnectSwiftV2.podspec @@ -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