mirror of
https://github.com/netbirdio/ios-client.git
synced 2026-09-23 09:28:33 -07:00
* feat(widget): replace action button with toggle switch control All connection states now render as a unified toggle-style control: green (connected), red (disconnected), orange with spinner (transitioning). * fix(widget+auth): toggle UI, VPN state sync, and login flow fixes * fix(widget+sdk): update Go SDK to fix/ios-debug-bundle, fix Control Center transitioning state and app disconnect flash * fix(widget): remove transitioning states, update toggle colors and UI * Change color indicator * fix(widget+auth): toggle UI, VPN state sync, and login flow fixes * fix framework version
50 lines
1.5 KiB
Swift
50 lines
1.5 KiB
Swift
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct SmallWidgetView: View {
|
|
let entry: VPNStatusEntry
|
|
|
|
var body: some View {
|
|
VStack(spacing: 8) {
|
|
Image("logo-onboarding")
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: 65, height: 65)
|
|
|
|
StatusIndicator(status: entry.status)
|
|
|
|
if #available(iOS 17.0, *) {
|
|
WidgetActionButton(entry: entry) {
|
|
transitionPill()
|
|
} label: { isConnected in
|
|
pillLabel(isConnected: isConnected)
|
|
}
|
|
} else if let url = entry.fallbackDeepLink {
|
|
Link(destination: url) {
|
|
pillLabel(isConnected: entry.isConnected)
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
}
|
|
|
|
private func transitionPill() -> some View {
|
|
pillLabel(isConnected: false)
|
|
}
|
|
|
|
private func pillLabel(isConnected: Bool) -> some View {
|
|
ZStack(alignment: isConnected ? .trailing : .leading) {
|
|
Capsule()
|
|
.fill(isConnected ? Color.netbirdOrange : Color(.systemGray3))
|
|
Circle()
|
|
.fill(Color.white)
|
|
.shadow(color: .black.opacity(0.2), radius: 2, x: 0, y: 1)
|
|
.padding(3)
|
|
}
|
|
.frame(width: 54, height: 30)
|
|
.accessibilityLabel(isConnected ? "Disconnect VPN" : "Connect VPN")
|
|
.accessibilityValue(isConnected ? "On" : "Off")
|
|
.accessibilityAddTraits(.isButton)
|
|
}
|
|
}
|