You've already forked ios-client
mirror of
https://github.com/netbirdio/ios-client.git
synced 2026-05-22 17:10:12 -07:00
315283822c
* Add Home Screen widget with VPN toggle and refactor app activation logic - Add NetBirdWidgetExtension target with small/medium widget sizes - Support direct connect/disconnect from widget via interactive buttons (iOS 17+) - Detect missing VPN config or login-required state and open app via deep link - Poll for stable VPN state after toggle to prevent loader getting stuck - Add widget shared state keys to GlobalConstants and sync status from MainViewModel - Fix false "authentication required" alert on app resume after widget disconnect - Deduplicate app activation logic into shared startActivation/stopActivation - Extract polling helpers: updateDetailsIfChanged, updatePeersIfChanged, applyExtensionStatus
26 lines
1014 B
Swift
26 lines
1014 B
Swift
import AppIntents
|
|
import NetworkExtension
|
|
|
|
@available(iOS 16.0, *)
|
|
struct VPNStatusIntent: AppIntent {
|
|
static var title: LocalizedStringResource = "Get NetBird VPN Status"
|
|
static var description: IntentDescription = "Check whether NetBird VPN is connected."
|
|
static var openAppWhenRun: Bool = false
|
|
|
|
func perform() async throws -> some IntentResult & ProvidesDialog {
|
|
guard let manager = try await VPNIntentHelpers.loadManager() else {
|
|
return .result(dialog: "NetBird VPN is not configured.")
|
|
}
|
|
|
|
if VPNIntentHelpers.isLoginRequired {
|
|
return .result(dialog: "NetBird VPN requires sign-in.")
|
|
}
|
|
|
|
let status = WidgetVPNStatus(neStatus: manager.connection.status)
|
|
let ip = VPNIntentHelpers.defaults?.string(forKey: WidgetConstants.keyIP) ?? ""
|
|
let detail = status == .connected && !ip.isEmpty ? " Your IP is \(ip)." : ""
|
|
|
|
return .result(dialog: "NetBird VPN is \(status.displayText.lowercased()).\(detail)")
|
|
}
|
|
}
|