mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
45e73faafb
BREAKING CHANGE: Package name changed due to name collision with existing rensbreur/SwiftTUI package. Changes: - Rename package from SwiftTUI to TUIKit in Package.swift - Rename Sources/SwiftTUI to Sources/TUIKit - Rename Sources/SwiftTUIExample to Sources/TUIKitExample - Rename Tests/SwiftTUITests to Tests/TUIKitTests - Rename SwiftTUI.swift to TUIKit.swift - Update all imports: import SwiftTUI -> import TUIKit - Update all code references: SwiftTUI.renderToBuffer -> TUIKit.renderToBuffer - Update documentation comments - Rename swiftTUIVersion to tuiKitVersion All 181 tests passing.
74 lines
2.1 KiB
Swift
74 lines
2.1 KiB
Swift
//
|
|
// ButtonsPage.swift
|
|
// TUIKitExample
|
|
//
|
|
// Demonstrates button and focus system capabilities.
|
|
//
|
|
|
|
import TUIKit
|
|
|
|
/// Buttons and focus demo page.
|
|
///
|
|
/// Shows interactive button features including:
|
|
/// - Different button styles (default, primary, success, destructive)
|
|
/// - Disabled buttons
|
|
/// - Plain style (no border)
|
|
/// - ButtonRow for horizontal groups
|
|
/// - Focus navigation with Tab
|
|
struct ButtonsPage: View {
|
|
var body: some View {
|
|
VStack(spacing: 1) {
|
|
HeaderView(title: "Buttons & Focus Demo")
|
|
|
|
DemoSection("Button Styles") {
|
|
HStack(spacing: 2) {
|
|
Button("Default") {
|
|
// Default style button action
|
|
}
|
|
Button("Primary", style: .primary) {
|
|
// Primary button action
|
|
}
|
|
Button("Success", style: .success) {
|
|
// Success button action
|
|
}
|
|
Button("Destructive", style: .destructive) {
|
|
// Destructive button action
|
|
}
|
|
}
|
|
}
|
|
|
|
DemoSection("Disabled Button") {
|
|
HStack(spacing: 2) {
|
|
Button("Enabled") { }
|
|
Button("Disabled") { }.disabled()
|
|
}
|
|
}
|
|
|
|
DemoSection("Plain Style (No Border)") {
|
|
HStack(spacing: 2) {
|
|
Button("Link 1", style: .plain) { }
|
|
Button("Link 2", style: .plain) { }
|
|
}
|
|
}
|
|
|
|
DemoSection("ButtonRow (Horizontal Group)") {
|
|
ButtonRow(spacing: 3) {
|
|
Button("Cancel") { }
|
|
Button("Save", style: .primary) { }
|
|
}
|
|
}
|
|
|
|
DemoSection("Focus Navigation") {
|
|
VStack {
|
|
Text("Use [Tab] to move focus between buttons")
|
|
.dim()
|
|
Text("Use [Enter] or [Space] to press the focused button")
|
|
.dim()
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|