Files
ios-client/NetBirdWidgetExtension/Intents/NetBirdShortcuts.swift
evgeniyChepelev 315283822c iOS home screen widget (#78)
* 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
2026-04-14 10:30:08 +02:00

40 lines
1.2 KiB
Swift

import AppIntents
@available(iOS 16.0, *)
struct NetBirdShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: ConnectVPNIntent(),
phrases: [
"Connect \(.applicationName) VPN",
"Turn on \(.applicationName) VPN",
"Enable \(.applicationName) VPN"
],
shortTitle: "Connect VPN",
systemImageName: "lock.shield"
)
AppShortcut(
intent: DisconnectVPNIntent(),
phrases: [
"Disconnect \(.applicationName) VPN",
"Turn off \(.applicationName) VPN",
"Disable \(.applicationName) VPN"
],
shortTitle: "Disconnect VPN",
systemImageName: "lock.slash"
)
AppShortcut(
intent: VPNStatusIntent(),
phrases: [
"\(.applicationName) VPN status",
"Is \(.applicationName) VPN connected",
"Check \(.applicationName) VPN"
],
shortTitle: "VPN Status",
systemImageName: "network"
)
}
}