Skip to content

Commit bbd7bfe

Browse files
committed
Save and restore sidebar width (initial value: 220)
1 parent 4876a88 commit bbd7bfe

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: Planet/Views/Sidebar/PlanetSidebarView.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct PlanetSidebarView: View {
161161
.sheet(isPresented: $planetStore.isCreatingPlanet) {
162162
CreatePlanetView()
163163
}
164-
.frame(minWidth: 220)
164+
.frame(minWidth: 220, idealWidth: UserDefaults.standard.double(forKey: "sidebarWidth") > 0 ? UserDefaults.standard.double(forKey: "sidebarWidth") : 220) // See https://github.com/Planetable/Planet/issues/393
165165
.toolbar {
166166
Button(action: toggleSidebar) {
167167
Image(systemName: "sidebar.left")
@@ -219,6 +219,10 @@ struct PlanetSidebarView: View {
219219
await planetStore.aggregate()
220220
}
221221
}
222+
.onWidthChange { newWidth in
223+
@AppStorage("sidebarWidth") var sidebarWidth = 220.0
224+
sidebarWidth = newWidth
225+
}
222226
}
223227

224228
private func toggleSidebar() {

Diff for: Planet/versioning.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 2324
1+
CURRENT_PROJECT_VERSION = 2325

0 commit comments

Comments
 (0)