Files
sing-box-for-apple/ApplicationLibrary/Views/Dashboard/Components/InstallProfileButton.swift
T
2025-12-01 18:22:06 +08:00

33 lines
747 B
Swift

import Library
import SwiftUI
@MainActor
public struct InstallProfileButton: View {
@State private var alert: AlertState?
private let callback: () async -> Void
public init(_ callback: @escaping (() async -> Void)) {
self.callback = callback
}
public var body: some View {
FormButton {
Task {
await installProfile()
}
} label: {
Label("Install Network Extension", systemImage: "lock.doc.fill")
}
.alert($alert)
}
private func installProfile() async {
do {
try await ExtensionProfile.install()
await callback()
} catch {
alert = AlertState(error: error)
}
}
}