Skip to content

Commit f49bf0d

Browse files
committed
refactor: insetGrouped list, cleaner row cards, glass pagination bar
1 parent 4a3434c commit f49bf0d

1 file changed

Lines changed: 42 additions & 28 deletions

File tree

TableProMobile/TableProMobile/Views/DataBrowserView.swift

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ struct DataBrowserView: View {
122122
}
123123
.disabled(!pagination.hasNextPage || isLoading)
124124
}
125-
.padding(.horizontal)
126-
.padding(.vertical, 10)
127-
.background(.bar)
125+
.padding(.horizontal, 20)
126+
.padding(.vertical, 12)
127+
.background(.ultraThinMaterial)
128128
}
129129
}
130130
.task { await loadData(isInitial: true) }
@@ -213,7 +213,7 @@ struct DataBrowserView: View {
213213
}
214214
}
215215
}
216-
.listStyle(.plain)
216+
.listStyle(.insetGrouped)
217217
.refreshable { await loadData() }
218218
}
219219

@@ -319,42 +319,56 @@ private struct RowCard: View {
319319
let row: [String?]
320320
let maxPreviewColumns: Int
321321

322-
private var sortedPairs: [(column: ColumnInfo, value: String?)] {
323-
let paired = zip(columns, row).map { ($0, $1) }
324-
let pkPairs = paired.filter { $0.0.isPrimaryKey }
325-
let nonPkPairs = paired.filter { !$0.0.isPrimaryKey }
326-
return (pkPairs + nonPkPairs).prefix(maxPreviewColumns).map { ($0.0, $0.1) }
322+
private var pkPair: (name: String, value: String)? {
323+
for (col, val) in zip(columns, row) where col.isPrimaryKey {
324+
return (col.name, val ?? "NULL")
325+
}
326+
if let first = columns.first {
327+
return (first.name, row.first.flatMap { $0 } ?? "NULL")
328+
}
329+
return nil
330+
}
331+
332+
private var previewPairs: [(name: String, value: String)] {
333+
let paired = zip(columns, row)
334+
return paired
335+
.filter { !$0.0.isPrimaryKey }
336+
.prefix(maxPreviewColumns - 1)
337+
.map { ($0.0.name, $0.1 ?? "NULL") }
327338
}
328339

329340
var body: some View {
330-
VStack(alignment: .leading, spacing: 6) {
331-
ForEach(Array(sortedPairs.enumerated()), id: \.offset) { _, pair in
332-
HStack(spacing: 8) {
333-
Text(pair.column.name)
341+
VStack(alignment: .leading, spacing: 4) {
342+
if let pk = pkPair {
343+
HStack(spacing: 6) {
344+
Text(pk.name)
345+
.font(.caption2)
346+
.foregroundStyle(.tertiary)
347+
Text(verbatim: pk.value)
348+
.font(.subheadline)
349+
.fontWeight(.medium)
350+
.lineLimit(1)
351+
}
352+
}
353+
354+
ForEach(Array(previewPairs.enumerated()), id: \.offset) { _, pair in
355+
HStack(spacing: 6) {
356+
Text(pair.name)
357+
.font(.caption2)
358+
.foregroundStyle(.tertiary)
359+
Text(verbatim: pair.value)
334360
.font(.caption)
335361
.foregroundStyle(.secondary)
336-
.frame(minWidth: 60, alignment: .leading)
337-
338-
if let value = pair.value {
339-
Text(verbatim: value)
340-
.font(.subheadline)
341-
.fontWeight(pair.column.isPrimaryKey ? .semibold : .regular)
342-
.lineLimit(1)
343-
} else {
344-
Text(verbatim: "NULL")
345-
.font(.subheadline)
346-
.foregroundStyle(.secondary)
347-
.italic()
348-
}
362+
.lineLimit(1)
349363
}
350364
}
351365

352366
if columns.count > maxPreviewColumns {
353367
Text("+\(columns.count - maxPreviewColumns) more columns")
354368
.font(.caption2)
355-
.foregroundStyle(.tertiary)
369+
.foregroundStyle(.quaternary)
356370
}
357371
}
358-
.padding(.vertical, 4)
372+
.padding(.vertical, 2)
359373
}
360374
}

0 commit comments

Comments
 (0)