-
-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathRootView.swift
More file actions
58 lines (53 loc) · 1.44 KB
/
Copy pathRootView.swift
File metadata and controls
58 lines (53 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// RootView.swift
// Meshtastic TV
//
// Copyright(c) Garth Vander Houwen 7/24/26.
//
import SwiftUI
import UIKit
struct RootView: View {
@Bindable var client: MeshClient
@Environment(\.scenePhase) private var scenePhase
var body: some View {
Group {
switch client.state {
case .connected:
MapScreen(client: client)
case .connecting:
ConnectingView(host: client.host) { client.disconnect() }
case .disconnected, .failed:
ConnectView(client: client)
}
}
// Meshtastic brand green (the Live Activity / widget tint).
.tint(Color("LightIndigo"))
// This app is a live wall display: keep the big screen awake so the tvOS
// screensaver never interrupts the mesh map while the app is foregrounded.
// Re-asserted on every active transition because the system can reset the
// flag when the app returns to the foreground.
.onAppear { UIApplication.shared.isIdleTimerDisabled = true }
.onChange(of: scenePhase) { _, phase in
UIApplication.shared.isIdleTimerDisabled = (phase == .active)
}
}
}
private struct ConnectingView: View {
let host: String
let onCancel: () -> Void
var body: some View {
VStack(spacing: 48) {
Image("m-logo-white")
.resizable()
.scaledToFit()
.frame(width: 280)
ProgressView()
.scaleEffect(1.6)
.tint(Color("LightIndigo"))
Text("Connecting to \(host)…")
.font(.title2)
.foregroundStyle(.secondary)
Button("Cancel", action: onCancel)
}
}
}