mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-25 15:56:02 +00:00
Fix router address button
This commit is contained in:
1 parent
c18a240ab3
commit
6ea0782565
3 files changed
+56
-29
No files matched your search
@@ -17,27 +17,33 @@ struct ApIsolationIssueView: View {
|
||||
var body: some View {
|
||||
|
||||
IssueView(image: .router, header: "ApIsolationHeader".localized(), description: "ApIsolationDescription".localized(), actionLabel: "ApIsolationAction".localized()) {
|
||||
openRouterSettingsPage()
|
||||
await openRouterSettingsPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let routerCheckQueue = DispatchQueue(label: "routerCheckQueue")
|
||||
|
||||
func openRouterSettingsPage() {
|
||||
guard let routerIP = getDefaultGatewayIP() else {
|
||||
|
||||
|
||||
func openRouterSettingsPage() async {
|
||||
let routerIP: String? = await withCheckedContinuation { continuation in
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let ip = getDefaultGatewayIP()
|
||||
continuation.resume(returning: ip)
|
||||
}
|
||||
}
|
||||
|
||||
guard let routerIP else {
|
||||
DispatchQueue.main.async {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .critical
|
||||
|
||||
|
||||
alert.messageText = "ApIsolationFindRouterFailedHeader".localized()
|
||||
alert.informativeText = "ApIsolationFindRouterFailedDescription".localized()
|
||||
|
||||
alert.addButton(withTitle: "CloseAlert".localized())
|
||||
|
||||
let _ = alert.runModal()
|
||||
alert.runModal()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ struct IssueView: View {
|
||||
let description: String
|
||||
|
||||
var actionLabel: String? = nil
|
||||
var action: (() -> Void)? = nil
|
||||
var action: (() async -> Void)? = nil
|
||||
|
||||
@State var isLoading = false
|
||||
|
||||
var body: some View {
|
||||
|
||||
@@ -67,8 +69,25 @@ struct IssueView: View {
|
||||
|
||||
if let actionLabel = actionLabel, let action = action {
|
||||
Button(actionLabel) {
|
||||
action()
|
||||
|
||||
withAnimation {
|
||||
isLoading = true
|
||||
}
|
||||
|
||||
Task {
|
||||
await action()
|
||||
|
||||
withAnimation {
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.opacity(isLoading ? 0 : 1)
|
||||
.overlay(
|
||||
ProgressView()
|
||||
.opacity(isLoading ? 1 : 0)
|
||||
.scaleEffect(0.7)
|
||||
)
|
||||
.padding(.bottom, 30)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user