Files
TUIkit/Sources/TUIkitExample/Pages/LayoutPage.swift
T
phranck df4ee3253b Feat: AppHeader — framework-managed header bar rendered outside the view tree
AppHeader is rendered at the top of the terminal by RenderLoop, similar to
StatusBar at the bottom. Views declare header content via .appHeader { }
ViewBuilder modifier. Supports standard (thin divider) and block (half-block
with appHeaderBackground) appearance. Hidden when no content is set.
Diff cache invalidates on header height changes to prevent ghosting.
2026-02-03 21:21:41 +01:00

79 lines
2.3 KiB
Swift

// 🖥️ TUIKit — Terminal UI Kit for Swift
// LayoutPage.swift
//
// Created by LAYERED.work
// CC BY-NC-SA 4.0
import TUIkit
/// Layout system demo page.
///
/// Shows various layout options including:
/// - VStack (vertical stacking)
/// - HStack (horizontal stacking)
/// - Spacer (flexible space)
/// - Padding and frame modifiers
struct LayoutPage: View {
var body: some View {
VStack(spacing: 1) {
DemoSection("VStack (Vertical)") {
// Box uses appearance default borderStyle
Box(color: .brightBlack) {
VStack(spacing: 0) {
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
}
}
DemoSection("HStack (Horizontal)") {
Box(color: .brightBlack) {
HStack(spacing: 2) {
Text("Left")
Text("Center")
Text("Right")
}
}
}
DemoSection("Spacer") {
Box(color: .brightBlack) {
HStack {
Text("Start")
Spacer()
Text("End")
}
}
}
DemoSection("Padding & Frame") {
HStack(spacing: 2) {
VStack {
Text(".padding()").dim()
Text("Padded")
.padding(EdgeInsets(all: 1))
.border() // Uses appearance default
}
VStack {
Text(".frame()").dim()
Text("Framed")
.frame(width: 15, alignment: .center)
.border() // Uses appearance default
}
}
}
Spacer()
}
.appHeader {
HStack {
Text("Layout System Demo").bold().foregroundColor(.palette.accent)
Spacer()
Text("TUIkit v\(tuiKitVersion)").foregroundColor(.palette.foregroundTertiary)
}
}
}
}