adwaita-swift/Sources/Adwaita/View/OverlaySplitView+.swift
david-swift 04c77831b5
Some checks are pending
Deploy Docs / publish (push) Waiting to run
SwiftLint / SwiftLint (push) Waiting to run
Remove Core library
2025-10-30 21:36:13 +01:00

40 lines
1.1 KiB
Swift

//
// OverlaySplitView+.swift
// Adwaita
//
// Created by david-swift on 21.01.23.
//
import CAdw
extension OverlaySplitView {
/// Initialize an overlay split view.
/// - Parameters:
/// - visible: Whether the sidebar is visible.
/// - sidebar: The sidebar content.
/// - content: The main content.
public init(
visible: Binding<Bool> = .constant(true),
@ViewBuilder sidebar: @escaping () -> Body,
@ViewBuilder content: @escaping () -> Body
) {
self.init()
self = self.sidebar(sidebar)
self = self.content(content)
self = self.showSidebar(visible)
}
/// The position of the sidebar.
/// - Parameter trailing: Whether the sidebar is at the trailing position.
/// - Returns: The navigation split view.
public func trailingSidebar(_ trailing: Bool = true) -> Self {
var newSelf = self
newSelf.updateFunctions.append { storage, _, _ in
adw_overlay_split_view_set_sidebar_position(storage.opaquePointer, trailing ? GTK_PACK_END : GTK_PACK_START)
}
return newSelf
}
}