92d26c8f76
Replace the dashboard with a TabView containing Channels, Nodes, Messages and Unread tabs, each in its own NavigationStack with the Settings gear in the toolbar. Surface the previous Connection and Statistics dashboard as a Status section at the top of the Settings sheet so the data stays one tap away.
65 lines
1.5 KiB
Swift
65 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
enum RootTab: Hashable {
|
|
case channels, nodes, dms, unread
|
|
}
|
|
|
|
struct WelcomeView: View {
|
|
@Environment(Settings.self) private var settings
|
|
@Environment(APIClient.self) private var api
|
|
@Environment(MeshDataStore.self) private var store
|
|
|
|
@State private var selectedTab: RootTab = .channels
|
|
@State private var showSettings = false
|
|
|
|
var body: some View {
|
|
TabView(selection: $selectedTab) {
|
|
NavigationStack {
|
|
ChannelListView()
|
|
.toolbar { sharedToolbar }
|
|
}
|
|
.tabItem { Label("Channels", systemImage: "number") }
|
|
.tag(RootTab.channels)
|
|
|
|
NavigationStack {
|
|
NodeListView()
|
|
.toolbar { sharedToolbar }
|
|
}
|
|
.tabItem { Label("Nodes", systemImage: "antenna.radiowaves.left.and.right") }
|
|
.tag(RootTab.nodes)
|
|
|
|
NavigationStack {
|
|
DMListView()
|
|
.toolbar { sharedToolbar }
|
|
}
|
|
.tabItem { Label("Messages", systemImage: "bubble.left.and.bubble.right") }
|
|
.tag(RootTab.dms)
|
|
|
|
NavigationStack {
|
|
UnreadListView()
|
|
.toolbar { sharedToolbar }
|
|
}
|
|
.tabItem { Label("Unread", systemImage: "envelope.badge") }
|
|
.tag(RootTab.unread)
|
|
}
|
|
.task {
|
|
if store.status == nil { await store.refresh(api: api) }
|
|
}
|
|
.sheet(isPresented: $showSettings) {
|
|
SetupView(isInitial: false)
|
|
.environment(settings)
|
|
}
|
|
}
|
|
|
|
@ToolbarContentBuilder
|
|
private var sharedToolbar: some ToolbarContent {
|
|
ToolbarItem(placement: .topBarLeading) {
|
|
Button {
|
|
showSettings = true
|
|
} label: {
|
|
Image(systemName: "gearshape")
|
|
}
|
|
}
|
|
}
|
|
}
|