Files
TUIkit/Sources/TUIkitExample/Pages/TogglePage.swift
T
phranck 5ad97132b8 Feat: Add @Observable support with Observation framework
- Replace custom Observable protocol and @Published with Apple's @Observable macro
- Add withObservationTracking in renderToBuffer for automatic per-property dependency tracking
- Add type-based @Environment(Type.self) and .environment(object) for observable objects
- Add ObjectEnvironmentModifier for injecting observable objects into the environment
- Add needsCacheClear flag to AppState for thread-safe cache invalidation
- Add cross-platform test script (scripts/test-linux.sh) for Docker-based Linux verification
- Add DemoAppHeader with system info display (OS, version, architecture)
- Consolidate Example App: extract ImageDemoHelpers, KeyboardHelpSection, ValueDisplayRow
- Add pre-push verification rule to CLAUDE.md
- Verified on both macOS and Linux (swift:6.0 container), 1155 tests passing
2026-02-15 23:49:34 +01:00

42 lines
1.2 KiB
Swift

// TUIKit - Terminal UI Kit for Swift
// TogglePage.swift
//
// Created by LAYERED.work
// License: MIT
import TUIkit
/// Toggle demo page.
struct TogglePage: View {
@State var notificationsEnabled: Bool = false
@State var darkModeEnabled: Bool = true
@State var showHiddenFiles: Bool = false
var body: some View {
VStack(alignment: .leading, spacing: 1) {
DemoSection("Toggles") {
VStack(alignment: .leading, spacing: 1) {
Toggle("Enable Notifications", isOn: $notificationsEnabled)
Toggle("Dark Mode", isOn: $darkModeEnabled)
Toggle("Show Hidden Files", isOn: $showHiddenFiles)
Toggle("Disabled (OFF)", isOn: .constant(false)).disabled()
Toggle("Disabled (ON)", isOn: .constant(true)).disabled()
}
}
DemoSection("Keyboard Controls") {
VStack(alignment: .leading) {
Text("[Tab] Move focus between toggles").dim()
Text("[Space] or [Enter] Toggle the focused item").dim()
}
}
Spacer()
}
.appHeader {
DemoAppHeader("Toggle Demo")
}
}
}