feat: wire list view models into AppModel, add strings, list helpers and debug snapshot mode
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import SstUI
|
||||
import SwiftUI
|
||||
|
||||
/// Debug snapshots (`Sst --snapshot`) are drawn by `ImageRenderer`, which cannot draw scroll views or text fields.
|
||||
/// While rendering one, the views below fall back to plain stacks and text.
|
||||
@MainActor
|
||||
enum SnapshotMode {
|
||||
static var isActive = false
|
||||
}
|
||||
|
||||
/// A scrolling, lazily built list (a plain stack while a snapshot is rendered).
|
||||
struct ScrollList<Content: View>: View {
|
||||
@ViewBuilder var content: Content
|
||||
|
||||
var body: some View {
|
||||
if SnapshotMode.isActive {
|
||||
VStack(alignment: .leading, spacing: 0) { content }
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
} else {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 0, pinnedViews: .sectionHeaders) { content }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The recessed "ZOEK" field.
|
||||
struct SearchField: View {
|
||||
@Binding var text: String
|
||||
var focused: FocusState<Bool>.Binding
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: Space.s4) {
|
||||
SilkLabel(Strings.search)
|
||||
Group {
|
||||
if SnapshotMode.isActive {
|
||||
Text(text).frame(maxWidth: .infinity, alignment: .leading)
|
||||
} else {
|
||||
TextField("", text: $text)
|
||||
.textFieldStyle(.plain)
|
||||
.focused(focused)
|
||||
}
|
||||
}
|
||||
.textStyle(Typography.body)
|
||||
.foregroundStyle(Palette.inkPrimary)
|
||||
.padding(Space.s3)
|
||||
.background(WellBackground())
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user