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
//
|
|
// Box.swift
|
|
// TUIKit
|
|
//
|
|
// A simple bordered container view.
|
|
//
|
|
|
|
/// A simple bordered container view.
|
|
///
|
|
/// `Box` wraps content in a border without additional styling.
|
|
/// Use `Card` if you need padding and background as well.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// ```swift
|
|
/// Box {
|
|
/// Text("Boxed content")
|
|
/// }
|
|
///
|
|
/// Box(.doubleLine, color: .yellow) {
|
|
/// VStack {
|
|
/// Text("Line 1")
|
|
/// Text("Line 2")
|
|
/// }
|
|
/// }
|
|
/// ```
|
|
public struct Box<Content: View>: View {
|
|
/// The content of the box.
|
|
public let content: Content
|
|
|
|
/// The border style.
|
|
public let borderStyle: BorderStyle
|
|
|
|
/// The border color.
|
|
public let borderColor: Color?
|
|
|
|
/// Creates a box with the specified border.
|
|
///
|
|
/// - Parameters:
|
|
/// - borderStyle: The border style (default: .line).
|
|
/// - color: The border color (default: nil).
|
|
/// - content: The content of the box.
|
|
public init(
|
|
_ borderStyle: BorderStyle = .line,
|
|
color: Color? = nil,
|
|
@ViewBuilder content: () -> Content
|
|
) {
|
|
self.content = content()
|
|
self.borderStyle = borderStyle
|
|
self.borderColor = color
|
|
}
|
|
|
|
public var body: some View {
|
|
content.border(borderStyle, color: borderColor)
|
|
}
|
|
}
|