remote(client): improve flow when local network access is denied

This commit is contained in:
osy
2025-04-07 08:58:52 -07:00
parent a09fd8be67
commit 3cabe41027
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -21,6 +21,7 @@ private let kTimeoutSeconds: UInt64 = 15
struct UTMRemoteConnectView: View {
@ObservedObject var remoteClientState: UTMRemoteClient.State
@Environment(\.openURL) private var openURL
@Environment(\.scenePhase) private var scenePhase
@EnvironmentObject private var data: UTMRemoteData
@State private var selectedServer: UTMRemoteClient.State.SavedServer?
@State private var isAutoConnect: Bool = false
@@ -98,7 +99,9 @@ struct UTMRemoteConnectView: View {
}
}.listStyle(.insetGrouped)
}.alert(item: $remoteClientState.alertMessage) { item in
Alert(title: Text(item.message), dismissButton: .default(Text("Retry")) {
Alert(title: Text(item.message), primaryButton: .default(Text("Open Settings")) {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
}, secondaryButton: .cancel(Text("Retry")) {
if !remoteClientState.isScanning {
Task {
await remoteClient.startScanning()
@@ -124,6 +127,13 @@ struct UTMRemoteConnectView: View {
await remoteClient.stopScanning()
}
}
.onChange(of: scenePhase) { newValue in
if newValue == .active && !remoteClientState.isScanning {
Task {
await remoteClient.startScanning()
}
}
}
}
@ViewBuilder
+1 -1
View File
@@ -599,7 +599,7 @@ extension Connection.ConnectionError: @retroactive LocalizedError {
public var errorDescription: String? {
switch self {
case .localNetworkDenied:
return NSLocalizedString("Please allow this app to access your local network when prompted.", comment: "UTMRemoteClient")
return NSLocalizedString("Please allow this app to access your local network when prompted or in Settings.", comment: "UTMRemoteClient")
}
}
}