Skip to content

Commit

Permalink
PurchaseTesterSwiftUI: added ProxyView to iOS (#2531)
Browse files Browse the repository at this point in the history
Follow up to #2518.

Also fixed the `CustomerInfo` `Picker`, which wasn't working on iOS due
to its design.
  • Loading branch information
NachoSoto authored May 24, 2023
1 parent c2ec8a1 commit aca79ae
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import Foundation

#if os(macOS) || targetEnvironment(macCatalyst)

enum ProxyStatus {

enum Mode: String, Decodable, CaseIterable {
Expand Down Expand Up @@ -105,5 +103,3 @@ private struct ProxyChangeModeResponse: Decodable {
let mode: ProxyStatus.Mode

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import Foundation
import SwiftUI

#if os(macOS) || targetEnvironment(macCatalyst)

struct ProxyView: View {

@StateObject
Expand Down Expand Up @@ -53,9 +51,8 @@ struct ProxyView: View {
} label: {
Text(mode.description)
}
.buttonStyle(.borderedProminent)
.disabled(self.changingMode)
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import Foundation

#if os(macOS) || targetEnvironment(macCatalyst)

@MainActor
final class ProxyViewModel: NSObject, ObservableObject {

Expand All @@ -30,5 +28,3 @@ final class ProxyViewModel: NSObject, ObservableObject {
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ struct HomeView: View {
Text(policy.label).tag(policy)
}
}
#if os(iOS)
.pickerStyle(WheelPickerStyle())
.frame(height: 80)
#endif

Spacer()

Button {
Task<Void, Never> {
do {
Expand Down

0 comments on commit aca79ae

Please sign in to comment.