Commit f302d0123a
f302d0123aef85506c2261b85643efdb5d7db1e9
parent: c1243198e4
Verified · cmc
cmc <hello@cleberg.net> · 2026-09-30 02:11 UTC
Badge the Dashboard tab with unread; push settings below the inbox
Layout: unified · split
gitbay/ContentView.swift
+3 −1
| @@ -10,6 +10,7 @@ struct ContentView: View { |
| 10 | |
10 | |
| 11 | @State private var selectedTab = Tabs.dashboard |
11 | @State private var selectedTab = Tabs.dashboard |
| 12 | @State private var dashboardPath = NavigationPath() |
12 | @State private var dashboardPath = NavigationPath() |
| |
13 | @State private var unread = 0 |
| 13 | |
14 | |
| 14 | /// whoami's admin flag, read on the My Profile tab, decides whether |
15 | /// whoami's admin flag, read on the My Profile tab, decides whether |
| 15 | /// the account menu offers Admin. |
16 | /// the account menu offers Admin. |
| @@ -29,10 +30,11 @@ struct ContentView: View { |
| 29 | TabView(selection: $selectedTab) { |
30 | TabView(selection: $selectedTab) { |
| 30 | Tab("Dashboard", systemImage: "square.grid.2x2", value: Tabs.dashboard) { |
31 | Tab("Dashboard", systemImage: "square.grid.2x2", value: Tabs.dashboard) { |
| 31 | NavigationStack(path: $dashboardPath) { |
32 | NavigationStack(path: $dashboardPath) { |
| 32 | DashboardView(client: client) |
33 | DashboardView(client: client, unread: $unread) |
| 33 | .navigationDestinations(client: client) |
34 | .navigationDestinations(client: client) |
| 34 | } |
35 | } |
| 35 | } |
36 | } |
| |
37 | .badge(unread) |
| 36 | Tab("Feed", systemImage: "bolt", value: Tabs.feed) { |
38 | Tab("Feed", systemImage: "bolt", value: Tabs.feed) { |
| 37 | NavigationStack { |
39 | NavigationStack { |
| 38 | FeedView(client: client) |
40 | FeedView(client: client) |
gitbay/Views/Account/NotificationsView.swift
+2 −2
| @@ -17,8 +17,6 @@ struct NotificationsView: View { |
| 17 | |
17 | |
| 18 | var body: some View { |
18 | var body: some View { |
| 19 | List { |
19 | List { |
| 20 | pushSection |
| |
| 21 | |
| |
| 22 | Picker("Filter", selection: Bindable(model).showAll) { |
20 | Picker("Filter", selection: Bindable(model).showAll) { |
| 23 | Text("Unread").tag(false) |
21 | Text("Unread").tag(false) |
| 24 | Text("All").tag(true) |
22 | Text("All").tag(true) |
| @@ -43,6 +41,8 @@ struct NotificationsView: View { |
| 43 | } |
41 | } |
| 44 | } |
42 | } |
| 45 | PageFooter(list: model.list) |
43 | PageFooter(list: model.list) |
| |
44 | |
| |
45 | pushSection |
| 46 | } |
46 | } |
| 47 | .overlay { LoadStateOverlay(state: model.state) } |
47 | .overlay { LoadStateOverlay(state: model.state) } |
| 48 | .navigationTitle("Notifications") |
48 | .navigationTitle("Notifications") |
gitbay/Views/Dashboard/DashboardView.swift
+7 −1
| @@ -8,8 +8,11 @@ struct DashboardView: View { |
| 8 | @State private var model: DashboardViewModel |
8 | @State private var model: DashboardViewModel |
| 9 | @State private var createModel: RepoCreateViewModel |
9 | @State private var createModel: RepoCreateViewModel |
| 10 | @State private var composing = false |
10 | @State private var composing = false |
| |
11 | /// The unread count, for the Dashboard tab's badge. |
| |
12 | @Binding var unread: Int |
| 11 | |
13 | |
| 12 | init(client: GitbayClient) { |
14 | init(client: GitbayClient, unread: Binding<Int>) { |
| |
15 | _unread = unread |
| 13 | _model = State(initialValue: DashboardViewModel(client: client)) |
16 | _model = State(initialValue: DashboardViewModel(client: client)) |
| 14 | _createModel = State(initialValue: RepoCreateViewModel(client: client)) |
17 | _createModel = State(initialValue: RepoCreateViewModel(client: client)) |
| 15 | } |
18 | } |
| @@ -78,6 +81,9 @@ struct DashboardView: View { |
| 78 | } |
81 | } |
| 79 | .task { await model.load() } |
82 | .task { await model.load() } |
| 80 | .refreshable { await model.load() } |
83 | .refreshable { await model.load() } |
| |
84 | .onChange(of: model.state.value?.unread) { _, count in |
| |
85 | if let count { unread = count } |
| |
86 | } |
| 81 | } |
87 | } |
| 82 | |
88 | |
| 83 | private var bellLabel: String { |
89 | private var bellLabel: String { |