Files
purchases-ios/Tests/TestingApps/PurchaseTesterSwiftUI/Shared/Proxy/ProxyViewModel.swift
T
NachoSoto aca79ae6c7 PurchaseTesterSwiftUI: added ProxyView to iOS (#2531)
Follow up to #2518.

Also fixed the `CustomerInfo` `Picker`, which wasn't working on iOS due
to its design.
2023-05-24 09:49:16 -07:00

31 lines
710 B
Swift

//
// ProxyViewModel.swift
// PurchaseTester
//
// Created by Nacho Soto on 5/19/23.
//
import Foundation
@MainActor
final class ProxyViewModel: NSObject, ObservableObject {
@Published var proxyStatus: ProxyStatus?
override init() {}
func refreshStatus(proxyURL: URL) async {
self.proxyStatus = await ProxyManager.fetchProxyStatus(proxyURL: proxyURL)
}
func changeMode(to newMode: ProxyStatus.Mode, proxyURL: URL) async {
do {
try await ProxyManager.changeMode(proxyURL: proxyURL, to: newMode)
self.proxyStatus = .enabled(newMode)
} catch {
print("Failed changing mode: \(error.localizedDescription)")
}
}
}