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 | 11 | @State private var selectedTab = Tabs.dashboard |
| 12 | 12 | @State private var dashboardPath = NavigationPath() |
| 13 | @State private var unread = 0 |
| 13 | 14 | |
| 14 | 15 | /// whoami's admin flag, read on the My Profile tab, decides whether |
| 15 | 16 | /// the account menu offers Admin. |
| @@ -29,10 +30,11 @@ struct ContentView: View { |
| 29 | 30 | TabView(selection: $selectedTab) { |
| 30 | 31 | Tab("Dashboard", systemImage: "square.grid.2x2", value: Tabs.dashboard) { |
| 31 | 32 | NavigationStack(path: $dashboardPath) { |
| 32 | | DashboardView(client: client) |
| 33 | DashboardView(client: client, unread: $unread) |
| 33 | 34 | .navigationDestinations(client: client) |
| 34 | 35 | } |
| 35 | 36 | } |
| 37 | .badge(unread) |
| 36 | 38 | Tab("Feed", systemImage: "bolt", value: Tabs.feed) { |
| 37 | 39 | NavigationStack { |
| 38 | 40 | FeedView(client: client) |
gitbay/Views/Account/NotificationsView.swift
+2 −2
| @@ -17,8 +17,6 @@ struct NotificationsView: View { |
| 17 | 17 | |
| 18 | 18 | var body: some View { |
| 19 | 19 | List { |
| 20 | | pushSection |
| 21 | | |
| 22 | 20 | Picker("Filter", selection: Bindable(model).showAll) { |
| 23 | 21 | Text("Unread").tag(false) |
| 24 | 22 | Text("All").tag(true) |
| @@ -43,6 +41,8 @@ struct NotificationsView: View { |
| 43 | 41 | } |
| 44 | 42 | } |
| 45 | 43 | PageFooter(list: model.list) |
| 44 | |
| 45 | pushSection |
| 46 | 46 | } |
| 47 | 47 | .overlay { LoadStateOverlay(state: model.state) } |
| 48 | 48 | .navigationTitle("Notifications") |
gitbay/Views/Dashboard/DashboardView.swift
+7 −1
| @@ -8,8 +8,11 @@ struct DashboardView: View { |
| 8 | 8 | @State private var model: DashboardViewModel |
| 9 | 9 | @State private var createModel: RepoCreateViewModel |
| 10 | 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 | 16 | _model = State(initialValue: DashboardViewModel(client: client)) |
| 14 | 17 | _createModel = State(initialValue: RepoCreateViewModel(client: client)) |
| 15 | 18 | } |
| @@ -78,6 +81,9 @@ struct DashboardView: View { |
| 78 | 81 | } |
| 79 | 82 | .task { await model.load() } |
| 80 | 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 | 89 | private var bellLabel: String { |