mirror of
https://github.com/phranck/TUIkit.git
synced 2026-06-20 09:54:37 +00:00
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.
57 lines
1.2 KiB
Swift
57 lines
1.2 KiB
Swift
//
|
|
// AppState.swift
|
|
// TUIKitExample
|
|
//
|
|
// Global state management for the example app.
|
|
//
|
|
|
|
import TUIKit
|
|
|
|
// MARK: - Demo Page Enum
|
|
|
|
/// The available demo pages in the example app.
|
|
enum DemoPage: Int, CaseIterable {
|
|
case menu = 0
|
|
case textStyles = 1
|
|
case colors = 2
|
|
case containers = 3
|
|
case overlays = 4
|
|
case layout = 5
|
|
case buttons = 6
|
|
}
|
|
|
|
// MARK: - App State
|
|
|
|
/// Global state for the example app.
|
|
///
|
|
/// This class manages the current page and menu selection.
|
|
/// Changes trigger automatic re-renders via `AppState`.
|
|
///
|
|
/// Status bar items are now managed declaratively via the
|
|
/// `.statusBarItems()` modifier in `ContentView`.
|
|
final class ExampleAppState: @unchecked Sendable {
|
|
static let shared = ExampleAppState()
|
|
|
|
/// The current page being displayed.
|
|
var currentPage: DemoPage = .menu {
|
|
didSet {
|
|
AppState.shared.setNeedsRender()
|
|
}
|
|
}
|
|
|
|
/// The selected menu index.
|
|
var menuSelection: Int = 0 {
|
|
didSet { AppState.shared.setNeedsRender() }
|
|
}
|
|
|
|
/// Binding for menu selection.
|
|
var menuSelectionBinding: Binding<Int> {
|
|
Binding(
|
|
get: { self.menuSelection },
|
|
set: { self.menuSelection = $0 }
|
|
)
|
|
}
|
|
|
|
private init() {}
|
|
}
|