From 61eaa3a95704c8326ed1b426316552e8828d608a Mon Sep 17 00:00:00 2001 From: NachoSoto Date: Tue, 23 May 2023 12:45:27 -0700 Subject: [PATCH] `PurchaseTesterSwiftUI`: added `ProxyView` to `iOS` Follow up to #2518. Also fixed the `CustomerInfo` `Picker`, which wasn't working on iOS due to its design. --- .../Shared/Proxy/ProxyManager.swift | 4 ---- .../Shared/Proxy/ProxyView.swift | 5 +---- .../Shared/Proxy/ProxyViewModel.swift | 4 ---- .../Shared/PurchaseTesterApp.swift | 19 ++++++++++++++++++- .../Shared/Views/HomeView.swift | 6 ++++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyManager.swift b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyManager.swift index c16a188865..1444d8b65e 100644 --- a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyManager.swift +++ b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyManager.swift @@ -7,8 +7,6 @@ import Foundation -#if os(macOS) || targetEnvironment(macCatalyst) - enum ProxyStatus { enum Mode: String, Decodable, CaseIterable { @@ -105,5 +103,3 @@ private struct ProxyChangeModeResponse: Decodable { let mode: ProxyStatus.Mode } - -#endif diff --git a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyView.swift b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyView.swift index bf2b7c8f27..6c26e819f5 100644 --- a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyView.swift +++ b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyView.swift @@ -8,8 +8,6 @@ import Foundation import SwiftUI -#if os(macOS) || targetEnvironment(macCatalyst) - struct ProxyView: View { @StateObject @@ -53,9 +51,8 @@ struct ProxyView: View { } label: { Text(mode.description) } + .buttonStyle(.borderedProminent) .disabled(self.changingMode) } } - -#endif diff --git a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyViewModel.swift b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyViewModel.swift index b1ba72e96f..63240aa488 100644 --- a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyViewModel.swift +++ b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyViewModel.swift @@ -7,8 +7,6 @@ import Foundation -#if os(macOS) || targetEnvironment(macCatalyst) - @MainActor final class ProxyViewModel: NSObject, ObservableObject { @@ -30,5 +28,3 @@ final class ProxyViewModel: NSObject, ObservableObject { } } - -#endif diff --git a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/PurchaseTesterApp.swift b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/PurchaseTesterApp.swift index 62f32c7a44..5f6489c856 100644 --- a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/PurchaseTesterApp.swift +++ b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/PurchaseTesterApp.swift @@ -112,12 +112,21 @@ struct PurchaseTesterApp: App { ContentView(configuration: configuration) .environmentObject(self.revenueCatCustomerData) .toolbar { - ToolbarItem(placement: .principal) { + ToolbarItemGroup(placement: Self.toolbarPlacement) { Button { self.configuration = nil } label: { Text("Reconfigure") } + + #if os(iOS) + NavigationLink { + ProxyView(proxyURL: self.configuration?.proxyURL) + .navigationTitle("Proxy Status") + } label: { + Text("Proxy") + } + #endif } } } @@ -126,4 +135,12 @@ struct PurchaseTesterApp: App { return self.configuration != nil } + private static var toolbarPlacement: ToolbarItemPlacement { + #if os(iOS) + return .navigation + #else + return .principal + #endif + } + } diff --git a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Views/HomeView.swift b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Views/HomeView.swift index 28838ce278..9d085b71a2 100644 --- a/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Views/HomeView.swift +++ b/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Views/HomeView.swift @@ -78,7 +78,13 @@ struct HomeView: View { Text(policy.label).tag(policy) } } + #if os(iOS) + .pickerStyle(WheelPickerStyle()) + .frame(height: 80) + #endif + Spacer() + Button { Task { do {