Add option for gap
Some checks failed
SwiftLint / SwiftLint (push) Successful in 4s
Deploy Docs / publish (push) Has been cancelled

This commit is contained in:
david-swift 2024-11-06 17:18:10 +01:00
parent 40146ebfdb
commit 4170728900
2 changed files with 13 additions and 15 deletions

View File

@ -28,8 +28,8 @@ public struct Window: WinUISceneElement {
var width: Meta.Binding<Int>?
/// The window's height.
var height: Meta.Binding<Int>?
/// Add a custom title.
var customTitle = false
/// Add a custom gap.
var gap = false
/// Create a window type with a certain identifier and user interface.
/// - Parameters:
@ -52,17 +52,15 @@ public struct Window: WinUISceneElement {
if extendContent ?? false {
ModifierWrapper(
view: Grid(columns: [.init()]) {
if customTitle {
ModifierWrapper(
view: Text(title)
.style(.caption),
verticalAlignment: .center
)
}
ModifierWrapper(
view: Text(title)
.style(.caption),
verticalAlignment: .center
)
}
.titleBar(),
height: customTitle ? 48 : 16,
margin: (48, 0, 0, 0),
height: 48,
margin: (gap ? 48 : 0, 0, 0, 0),
verticalAlignment: .top
)
}
@ -149,12 +147,12 @@ public struct Window: WinUISceneElement {
/// Whether to extend the content into the title bar.
/// - Parameters:
/// - enabled: Whether to extend the content.
/// - showTitle: Whether to add a custom title overlay.
/// - gap: Whether to insert a gap for the navigation view's main button.
/// - Returns: The window.
public func extendContentIntoTitleBar(_ enabled: Bool? = true, showTitle: Bool = true) -> Self {
public func extendContentIntoTitleBar(_ enabled: Bool? = true, gap: Bool = false) -> Self {
var newSelf = self
newSelf.extendContent = enabled
newSelf.customTitle = showTitle
newSelf.gap = gap
return newSelf
}

View File

@ -22,7 +22,7 @@ struct Demo: App {
Window("Demo", id: "main") { _ in
ContentView(app: app)
}
.extendContentIntoTitleBar()
.extendContentIntoTitleBar(gap: true)
.frame(width: $width, height: $height)
}