mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-11 21:59:56 +00:00
remote(client): improve flow when local network access is denied
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user