Files
ios-client/NetBird/Source/App/ViewModels/PeerViewModel.swift
T
evgeniyChepelev 44da97bf04 Tv os changes (#63)
* fix ui state for airplaine mode

* fix slide bar

* Keep VPN tunnel alive during network unavailability

- Add isNetworkUnavailable flag to NetBirdAdapter to track network state
- Modify ConnectionListener to stay in 'connecting' state when network
  is unavailable instead of transitioning to 'disconnected'
- Update PacketTunnelProvider to set network unavailable flag and
  trigger automatic reconnect when network returns
- Fix CustomLottieView to show grey 'Disconnected' state immediately
  when network is lost, without closing the VPN tunnel
- Ensure UI shows correct state after app foreground/background cycle

This allows the VPN tunnel to survive temporary network outages
(e.g. airplane mode) and automatically reconnect when network returns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix UI state after app foreground/background cycle

Show correct connected/disconnected state immediately when app returns
from background, without replaying animations. Use extensionStatus
(iOS VPN state) as the source of truth for UI state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* netbird credential

* Update MainView.swift

* Separate button by state

* Add gogoleServiceInfo plist reference

* Remove dead code in animation state machine and fix copy-to-clipboard UX  - Remove unreachable shouldForceReset block in CustomLottieView (already handled by earlier return) - Guard against copying empty fqdn/ip strings when disconnected - Use consistent .smooth animation for both fqdn and ip copy feedback

- Remove unreachable shouldForceReset block in CustomLottieView (already handled by earlier return)
- Guard against copying empty fqdn/ip strings when disconnected
- Use consistent .smooth animation for both fqdn and ip copy feedback

* Tab bar

* Update peer view

* Update fonts

* Redesign tvOS connection screen and add peer search

- Move logo to top-left brand anchor (smaller, semi-transparent)
- Restyle connect button with gradient fill, glow shadow, and
  press-down scale animation (TVConnectButtonStyle)
- Add search bar with clear button to peers list view

* Redesign tvOS UI with gradient backgrounds

* Update logo position

* Redesign tvOS peers & resources lists to match settings UI style

* Add color-coded connection status indicator and debug state overlay

* Stabilize connection screen layout and remove debug overlay

* Update project.pbxproj

* Delete mock data

* Update info plist

* Update project.pbxproj

* add go get

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: mlsmaycon <mlsmaycon@gmail.com>
2026-03-06 08:58:24 +01:00

61 lines
1.6 KiB
Swift

//
// PeerViewModel.swift
// NetBird
//
// Created by Pascal Fischer on 25.04.24.
//
import Foundation
import Combine
class PeerViewModel: ObservableObject {
@Published var peerInfo: [PeerInfo] = []
@Published var selectionFilter: String = "All"
@Published var peerFilter: String = ""
@Published var tappedPeer: PeerInfo? = nil
@Published var selectedPeerId: UUID?
@Published var freezeDisplayedPeers: Bool = false
private var displayedPeersBackup: [PeerInfo] = []
var lockID: String = UUID().uuidString
var filteredPeers: [PeerInfo] {
return peerInfo.filter { peer in
switch selectionFilter {
case "All": return true
case "Connected": return peer.connStatus == "Connected"
case "Connecting": return peer.connStatus == "Connecting"
case "Idle": return peer.connStatus == "Idle"
default: return false
}
}
.filter { peer in
peer.fqdn.lowercased().contains(peerFilter.lowercased()) ||
peer.ip.contains(peerFilter) ||
peerFilter.isEmpty
}
}
var displayedPeers: [PeerInfo] {
if freezeDisplayedPeers {
return displayedPeersBackup
} else {
displayedPeersBackup = filteredPeers
return filteredPeers
}
}
func freezeDisplayedPeerList() {
self.freezeDisplayedPeers = true
print("Freezing displayed peer list")
}
func unfreezeDisplayedPeerList() {
self.freezeDisplayedPeers = false
print("Unfreezing displayed peer list")
}
}