Skip to content

Commit 99cf93c

Browse files
authored
Reorganize settings navigation and tab customization (#553)
1 parent a18ab33 commit 99cf93c

13 files changed

Lines changed: 289 additions & 367 deletions

LoopFollow/Alarm/AlarmsContainerView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import SwiftUI
55

66
struct AlarmsContainerView: View {
7-
var onDismiss: (() -> Void)?
7+
var onBack: (() -> Void)?
88

99
var body: some View {
1010
NavigationStack {
1111
AlarmListView()
1212
.toolbar {
13-
if let onDismiss {
13+
if let onBack {
1414
ToolbarItem(placement: .navigationBarLeading) {
15-
Button(action: onDismiss) {
16-
Image(systemName: "checkmark")
15+
Button(action: onBack) {
16+
Image(systemName: "chevron.left")
1717
}
1818
}
1919
}

LoopFollow/Helpers/TabPosition.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ enum TabItem: String, CaseIterable, Codable, Identifiable {
8989
}
9090
}
9191

92+
/// Canonical feature order used by menus and customization screens.
93+
static var featureOrder: [TabItem] {
94+
[.home, .alarms, .nightscout, .remote, .snoozer, .stats, .treatments]
95+
}
96+
9297
/// Items that can be moved between tab bar and menu (all except settings which doesn't exist as a tab)
9398
static var movableItems: [TabItem] {
94-
[.home, .alarms, .remote, .nightscout, .snoozer, .treatments, .stats]
99+
featureOrder
95100
}
96101
}

LoopFollow/Log/LogView.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import SwiftUI
55

66
struct LogView: View {
7+
var onBack: (() -> Void)?
78
@ObservedObject var viewModel = LogViewModel()
89

910
var body: some View {
@@ -35,8 +36,17 @@ struct LogView: View {
3536
.onAppear {
3637
viewModel.loadLogEntries()
3738
}
39+
.navigationBarTitle("Today's Logs", displayMode: .inline)
40+
.toolbar {
41+
if let onBack {
42+
ToolbarItem(placement: .navigationBarLeading) {
43+
Button(action: onBack) {
44+
Image(systemName: "chevron.left")
45+
}
46+
}
47+
}
48+
}
3849
}
3950
.preferredColorScheme(Storage.shared.appearanceMode.value.colorScheme)
40-
.navigationBarTitle("Today's Logs", displayMode: .inline)
4151
}
4252
}

LoopFollow/Settings/HomeContentView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ struct HomeModalView: View {
5555
.navigationTitle("Home")
5656
.navigationBarTitleDisplayMode(.inline)
5757
.toolbar {
58-
ToolbarItem(placement: .navigationBarTrailing) {
58+
ToolbarItem(placement: .cancellationAction) {
5959
Button {
6060
dismiss()
6161
} label: {
62-
Image(systemName: "checkmark")
62+
Image(systemName: "xmark")
6363
}
64-
.foregroundColor(.blue)
6564
}
6665
}
6766
}

LoopFollow/Settings/ImportExport/ImportExportSettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct ImportExportSettingsView: View {
9898
}
9999
.navigationTitle("Export \(viewModel.exportType.rawValue)")
100100
.navigationBarTitleDisplayMode(.inline)
101-
.navigationBarItems(trailing: Button("Done") {
101+
.navigationBarItems(trailing: Button("Close") {
102102
viewModel.isShowingQRCodeDisplay = false
103103
})
104104
}

LoopFollow/Settings/SettingsMenuView.swift

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ struct SettingsMenuView: View {
1212

1313
// MARK: – Local state
1414

15-
@State private var showingTabCustomization = false
16-
var onDismiss: (() -> Void)?
15+
var onBack: (() -> Void)?
1716

1817
// MARK: – Observed objects
1918

@@ -24,33 +23,40 @@ struct SettingsMenuView: View {
2423
var body: some View {
2524
NavigationStack(path: $settingsPath.value) {
2625
List {
27-
// ───────── Data settings ─────────
2826
dataSection
2927

30-
// ───────── App settings ─────────
31-
Section("App Settings") {
32-
NavigationRow(title: "Background Refresh",
33-
icon: "arrow.clockwise")
34-
{
35-
settingsPath.value.append(Sheet.backgroundRefresh)
36-
}
37-
28+
Section("Display Settings") {
3829
NavigationRow(title: "General",
3930
icon: "gearshape")
4031
{
4132
settingsPath.value.append(Sheet.general)
4233
}
43-
4434
NavigationRow(title: "Graph",
4535
icon: "chart.xyaxis.line")
4636
{
4737
settingsPath.value.append(Sheet.graph)
4838
}
4939

50-
NavigationRow(title: "Tab Settings",
40+
if !nightscoutURL.value.isEmpty {
41+
NavigationRow(title: "Information Display",
42+
icon: "info.circle")
43+
{
44+
settingsPath.value.append(Sheet.infoDisplay)
45+
}
46+
}
47+
48+
NavigationRow(title: "Tabs",
5149
icon: "rectangle.3.group")
5250
{
53-
showingTabCustomization = true
51+
settingsPath.value.append(Sheet.tabSettings)
52+
}
53+
}
54+
55+
Section("App Settings") {
56+
NavigationRow(title: "Background Refresh",
57+
icon: "arrow.clockwise")
58+
{
59+
settingsPath.value.append(Sheet.backgroundRefresh)
5460
}
5561

5662
NavigationRow(title: "Import/Export",
@@ -60,12 +66,6 @@ struct SettingsMenuView: View {
6066
}
6167

6268
if !nightscoutURL.value.isEmpty {
63-
NavigationRow(title: "Information Display",
64-
icon: "info.circle")
65-
{
66-
settingsPath.value.append(Sheet.infoDisplay)
67-
}
68-
6969
NavigationRow(title: "Remote",
7070
icon: "antenna.radiowaves.left.and.right")
7171
{
@@ -74,7 +74,6 @@ struct SettingsMenuView: View {
7474
}
7575
}
7676

77-
// ───────── Alarms ─────────
7877
Section("Alarms") {
7978
NavigationRow(title: "Alarms",
8079
icon: "bell.badge")
@@ -83,7 +82,6 @@ struct SettingsMenuView: View {
8382
}
8483
}
8584

86-
// ───────── Integrations ─────────
8785
Section("Integrations") {
8886
NavigationRow(title: "Calendar",
8987
icon: "calendar")
@@ -98,7 +96,6 @@ struct SettingsMenuView: View {
9896
}
9997
}
10098

101-
// ───────── Advanced ─────────
10299
Section("Advanced Settings") {
103100
NavigationRow(title: "Advanced",
104101
icon: "exclamationmark.shield")
@@ -108,24 +105,17 @@ struct SettingsMenuView: View {
108105
}
109106
}
110107
.navigationTitle("Settings")
108+
.navigationBarTitleDisplayMode(.large)
111109
.navigationDestination(for: Sheet.self) { $0.destination }
112110
.toolbar {
113-
if let onDismiss {
114-
ToolbarItem(placement: .navigationBarTrailing) {
115-
Button(action: onDismiss) {
116-
Image(systemName: "checkmark")
111+
if let onBack {
112+
ToolbarItem(placement: .navigationBarLeading) {
113+
Button(action: onBack) {
114+
Image(systemName: "chevron.left")
117115
}
118116
}
119117
}
120118
}
121-
.sheet(isPresented: $showingTabCustomization) {
122-
TabCustomizationModal(
123-
isPresented: $showingTabCustomization,
124-
onApply: {
125-
// No-op - changes are applied silently via observers
126-
}
127-
)
128-
}
129119
}
130120
}
131121

@@ -157,11 +147,6 @@ struct SettingsMenuView: View {
157147
}
158148
}
159149
}
160-
161-
private func handleTabReorganization() {
162-
// Rebuild the tab bar with the new configuration
163-
MainViewController.rebuildTabsIfNeeded()
164-
}
165150
}
166151

167152
// MARK: – Sheet routing
@@ -170,6 +155,7 @@ private enum Sheet: Hashable, Identifiable {
170155
case nightscout, dexcom
171156
case backgroundRefresh
172157
case general, graph
158+
case tabSettings
173159
case infoDisplay
174160
case alarmSettings
175161
case remote
@@ -188,6 +174,7 @@ private enum Sheet: Hashable, Identifiable {
188174
case .backgroundRefresh: BackgroundRefreshSettingsView(viewModel: .init())
189175
case .general: GeneralSettingsView()
190176
case .graph: GraphSettingsView()
177+
case .tabSettings: TabCustomizationModal()
191178
case .infoDisplay: InfoDisplaySettingsView(viewModel: .init())
192179
case .alarmSettings: AlarmSettingsView()
193180
case .remote: RemoteSettingsView(viewModel: .init())

0 commit comments

Comments
 (0)