@@ -9,6 +9,7 @@ import TableProSync
99
1010struct ConnectionListView : View {
1111 @Environment ( AppState . self) private var appState
12+ @Environment ( \. horizontalSizeClass) private var sizeClass
1213 @State private var showingAddConnection = false
1314 @State private var editingConnection : DatabaseConnection ?
1415 @State private var selectedConnectionId : UUID ?
@@ -132,6 +133,32 @@ struct ConnectionListView: View {
132133 }
133134 }
134135
136+ @ViewBuilder
137+ private var connectionList : some View {
138+ let list = List ( selection: $selectedConnectionId) {
139+ if groupByGroup {
140+ groupedContent
141+ } else {
142+ ForEach ( displayedConnections) { connection in
143+ connectionRow ( connection)
144+ }
145+ . onMove { source, destination in
146+ var items = displayedConnections
147+ items. move ( fromOffsets: source, toOffset: destination)
148+ for index in items. indices {
149+ items [ index] . sortOrder = index
150+ }
151+ appState. reorderConnections ( items)
152+ }
153+ }
154+ }
155+ if sizeClass == . regular {
156+ list. listStyle ( . sidebar)
157+ } else {
158+ list. listStyle ( . insetGrouped)
159+ }
160+ }
161+
135162 @ViewBuilder
136163 private var sidebar : some View {
137164 if appState. connections. isEmpty && !isSyncing {
@@ -149,24 +176,7 @@ struct ConnectionListView: View {
149176 ProgressView ( " Syncing from iCloud... " )
150177 . frame ( maxWidth: . infinity, maxHeight: . infinity)
151178 } else {
152- List ( selection: $selectedConnectionId) {
153- if groupByGroup {
154- groupedContent
155- } else {
156- ForEach ( displayedConnections) { connection in
157- connectionRow ( connection)
158- }
159- . onMove { source, destination in
160- var items = displayedConnections
161- items. move ( fromOffsets: source, toOffset: destination)
162- for index in items. indices {
163- items [ index] . sortOrder = index
164- }
165- appState. reorderConnections ( items)
166- }
167- }
168- }
169- . listStyle ( . insetGrouped)
179+ connectionList
170180 . overlay {
171181 if !appState. connections. isEmpty && displayedConnections. isEmpty {
172182 ContentUnavailableView (
@@ -403,12 +413,12 @@ private struct ConnectionRow: View {
403413 if let tag {
404414 Text ( tag. name)
405415 . font ( . caption)
406- . foregroundStyle ( ConnectionColorPicker . swiftUIColor ( for : tag . color ) )
416+ . foregroundStyle ( . white )
407417 . padding ( . horizontal, 8 )
408418 . padding ( . vertical, 3 )
409419 . background (
410420 Capsule ( )
411- . fill ( ConnectionColorPicker . swiftUIColor ( for: tag. color) . opacity ( 0.15 ) )
421+ . fill ( ConnectionColorPicker . swiftUIColor ( for: tag. color) )
412422 )
413423 }
414424 }
0 commit comments