git.iko.soy/parseable-macos
on master help sign in
Move "Add Connection" into instance picker dropdown, remove gear menu (#32)
c7e5d4eiko
ParseableViewer/Views/SidebarView.swift+12−23
@@ -199,6 +199,7 @@ struct SidebarView: View {
199
199
200struct ConnectionStatusView: View {
200struct ConnectionStatusView: View {
201 @Environment(AppState.self) private var appState
201 @Environment(AppState.self) private var appState
202+ static let addConnectionID = UUID(uuidString: "00000000-0000-0000-0000-000000000000")!
202
203
203 var body: some View {
204 var body: some View {
204 VStack(alignment: .leading, spacing: 4) {
205 VStack(alignment: .leading, spacing: 4) {
@@ -211,38 +212,26 @@ struct ConnectionStatusView: View {
211 Picker("Connection", selection: Binding<UUID>(
212 Picker("Connection", selection: Binding<UUID>(
212 get: { connection.id },
213 get: { connection.id },
213 set: { newID in
214 set: { newID in
215+ if newID == ConnectionStatusView.addConnectionID {
216+ appState.editingConnection = nil
217+ appState.showConnectionSheet = true
214− if let conn = appState.connections.first(where: { $0.id == newID }) {
218+ } else if let conn = appState.connections.first(where: { $0.id == newID }) {
215 Task { await appState.connect(to: conn) }
219 Task { await appState.connect(to: conn) }
216 }
220 }
217 }
221 }
218 )) {
222 )) {
223+ Section {
219− ForEach(appState.connections) { conn in
224+ ForEach(appState.connections) { conn in
220− Text(conn.name).tag(conn.id)
225+ Text(conn.name).tag(conn.id)
226+ }
227+ }
228+ Section {
229+ Text("Add Connection...").tag(ConnectionStatusView.addConnectionID)
221 }
230 }
222 }
231 }
223 .labelsHidden()
232 .labelsHidden()
224 .pickerStyle(.menu)
233 .pickerStyle(.menu)
225 .accessibilityLabel("Connection selector")
234 .accessibilityLabel("Connection selector")
226− Spacer()
227− Menu {
228− Button("Add Connection...") {
229− appState.editingConnection = nil
230− appState.showConnectionSheet = true
231− }
232− Button("Edit Connection...") {
233− appState.editingConnection = connection
234− appState.showConnectionSheet = true
235− }
236− Divider()
237− Button("Disconnect") {
238− appState.disconnect()
239− }
240− } label: {
241− Image(systemName: "gear")
242− }
243− .menuStyle(.borderlessButton)
244− .frame(width: 24)
245− .accessibilityLabel("Connection options")
246 }
235 }
247 } else if appState.isConnecting {
236 } else if appState.isConnecting {
248 HStack {
237 HStack {