portico/Sources/Portico/Generated/BottomSheet.swift

923 lines
49 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Adw.BottomSheet
/// A bottom sheet with an optional bottom bar.
///
/// <picture>
/// <source srcset="bottom-sheet-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="bottom-sheet.png" alt="bottom-sheet">
/// </picture>
///
/// `AdwBottomSheet` has three child widgets. [property`BottomSheet`:content] is
/// shown persistently. [property`BottomSheet`:sheet] is displayed above it when
/// it's open, and [property`BottomSheet`:bottom-bar] is displayed when it's not.
///
/// Bottom sheet and bottom bar are attached to the bottom edge of the widget.
/// They take the full width by default, but can only take a portion of it if
/// [property`BottomSheet`:full-width] is set to `FALSE`. In this case,
/// [property`BottomSheet`:align] determines where along the bottom edge they are
/// placed.
///
/// Bottom bar can be hidden using the [property`BottomSheet`:reveal-bottom-bar]
/// property.
///
/// `AdwBottomSheet` can be useful for applications such as music players, that
/// want to have a persistent bottom bar that expands into a bottom sheet when
/// clicked. It's meant for cases where a bottom sheet is tightly integrated into
/// the UI. For more transient bottom sheets, see [class`Dialog`].
///
/// To open or close the bottom sheet, use the [property`BottomSheet`:open]
/// property.
///
/// By default, the bottom sheet has an overlaid drag handle. It can be disabled
/// by setting [property`BottomSheet`:show-drag-handle] to `FALSE`. Note that the
/// handle also controls whether the sheet can be dragged using a pointer.
///
/// Bottom sheets are modal by default, meaning that the content is dimmed and
/// cannot be accessed while the sheet is open. Set [property`BottomSheet`:modal]
/// to `FALSE` if this behavior is unwanted.
///
/// To disable user interactions for opening or closing the bottom sheet (such as
/// swipes or clicking the bottom bar or close button), set
/// [property`BottomSheet`:can-open] or [property`BottomSheet`:can-close] to
/// `FALSE`.
///
/// In some cases, particularly when using a full-width bottom bar, it may be
/// necessary to shift [property`BottomSheet`:content] upwards. Use the
/// [property`BottomSheet`:bottom-bar-height] and
/// [property`BottomSheet`:sheet-height] for that.
///
/// `AdwBottomSheet` is not adaptive, and for larger window sizes applications
/// may want to replace it with another UI, such as a sidebar. This can be done
/// using [class`MultiLayoutView`].
///
/// ## Sizing
///
/// Unlike [class`Dialog`] presented as a bottom sheet, `AdwBottomSheet` just
/// follows the content's natural size, and it's up to the applications to make
/// sure their content provides one. For example, when using
/// [class`Gtk`.ScrolledWindow], make sure to set
/// [property`Gtk`.ScrolledWindow:propagate-natural-height] to `TRUE`.
///
/// ## Header Bar Integration
///
/// When placed inside an `AdwBottomSheet`, [class`HeaderBar`] will not show the
/// title when [property`BottomSheet`:show-drag-handle] is `TRUE`, regardless of
/// [property`HeaderBar`:show-title]. This only applies to the default title,
/// titles set with [property`HeaderBar`:title-widget] will still be shown.
///
/// ## `AdwBottomSheet` as `GtkBuildable`:
///
/// The `AdwBottomSheet` implementation of the [iface`Gtk`.Buildable] interface
/// supports setting the sheet widget by specifying sheet as the type
/// attribute of a `<child>` element, and the bottom bar by specifying
/// bottom-bar. Specifying content or omitting the child type results in
/// setting the content child.
///
/// A Portico view that mounts a `Adw.BottomSheet`.
@MainActor public struct BottomSheet: View {
private let make: (MountContext) -> Adw.BottomSheet
private var configure: [(Adw.BottomSheet, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.BottomSheet.init()
/// Creates a new `AdwBottomSheet`.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter align: Horizontal alignment of the bottom sheet.
/// - Parameter canClose: Whether the bottom sheet can be closed by user.
/// - Parameter canOpen: Whether the bottom sheet can be opened by user.
/// - Parameter fullWidth: Whether the bottom sheet takes the full width.
/// - Parameter modal: Whether the bottom sheet is modal.
/// - Parameter `open`: Whether the bottom sheet is open.
/// - Parameter revealBottomBar: Whether to reveal the bottom bar.
/// - Parameter showDragHandle: Whether to overlay a drag handle in the bottom sheet.
/// - Parameter content: A `ViewBuilder` closure whose first view is mounted into the `content` slot.
/// - Parameter bottomBar: A `ViewBuilder` closure whose first view is mounted into the `bottomBar` slot.
/// - Parameter sheet: A `ViewBuilder` closure whose first view is mounted into the `sheet` slot.
/// - Parameter onCloseAttempt: Invoked when the widget emits the `close-attempt` signal.
public init(align: Float? = nil, canClose: Bool? = nil, canOpen: Bool? = nil, fullWidth: Bool? = nil, modal: Bool? = nil, `open`: Bool? = nil, revealBottomBar: Bool? = nil, showDragHandle: Bool? = nil, @ViewBuilder content: @escaping () -> [AnyView] = { [] }, @ViewBuilder bottomBar: @escaping () -> [AnyView] = { [] }, @ViewBuilder sheet: @escaping () -> [AnyView] = { [] }, onCloseAttempt: (() -> Void)? = nil) {
make = { _ in Adw.BottomSheet() }
configure.append { w, ctx in
if let align { w.setAlign(align: align) }
if let canClose { w.setCanClose(canClose: canClose) }
if let canOpen { w.setCanOpen(canOpen: canOpen) }
if let fullWidth { w.setFullWidth(fullWidth: fullWidth) }
if let modal { w.setModal(modal: modal) }
if let `open` { w.setOpen(`open`: `open`) }
if let revealBottomBar { w.setRevealBottomBar(reveal: revealBottomBar) }
if let showDragHandle { w.setShowDragHandle(showDragHandle: showDragHandle) }
if let v = Portico.mountSlotChild(content, ctx, onUpdate: { v in w.setContent(content: v) }) { w.setContent(content: v) }
if let v = Portico.mountSlotChild(bottomBar, ctx, onUpdate: { v in w.setBottomBar(bottomBar: v) }) { w.setBottomBar(bottomBar: v) }
if let v = Portico.mountSlotChild(sheet, ctx, onUpdate: { v in w.setSheet(sheet: v) }) { w.setSheet(sheet: v) }
if let onCloseAttempt { ctx.registry.add(w.connectCloseAttempt { _ in onCloseAttempt() }) }
}
}
}
extension BottomSheet: WidgetView {
public typealias Target = Adw.BottomSheet
@_spi(Portico) public func appending(
_ step: @escaping (Adw.BottomSheet, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension BottomSheet: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Adw.BottomSheet
/// Modifiers for `Adw.BottomSheet`, available on every Portico view whose
/// backing widget is `Adw.BottomSheet` or one of its subclasses.
extension WidgetView where Target: Adw.BottomSheet {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setAlign(align:)
/// Sets horizontal alignment of the bottom sheet.
///
/// 0 means the bottom sheet is flush with the start edge, 1 means it's flush
/// with the end edge. 0.5 means it's centered.
///
/// Only used when [property`BottomSheet`:full-width] is set to `FALSE`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter align: Horizontal alignment of the bottom sheet.
/// - Returns: A copy of this view with the modifier applied.
public func align(_ align: Float) -> Self {
appending { w, _ in
w.setAlign(align: align)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setAlign(align:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getAlign()
/// Sets horizontal alignment of the bottom sheet.
///
/// 0 means the bottom sheet is flush with the start edge, 1 means it's flush
/// with the end edge. 0.5 means it's centered.
///
/// Only used when [property`BottomSheet`:full-width] is set to `FALSE`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Float` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func align(_ align: Portico.Binding<Float>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, align, registry: ctx.registry, notifyDetail: "align",
read: { [w] in w.getAlign() },
write: { [w] v in w.setAlign(align: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setAlign(align:)
/// Sets horizontal alignment of the bottom sheet.
///
/// 0 means the bottom sheet is flush with the start edge, 1 means it's flush
/// with the end edge. 0.5 means it's centered.
///
/// Only used when [property`BottomSheet`:full-width] is set to `FALSE`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setAlign(align:)`.
///
/// - Parameter align: Horizontal alignment of the bottom sheet.
/// - Returns: A copy of this view with the modifier applied.
public func align(_ align: @escaping () -> Float) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAlign(align: align()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setBottomBar(bottomBar:)
/// Sets the bottom bar widget for `self`.
///
/// Shown when [property`BottomSheet`:open] is `FALSE`. When open, morphs into
/// the [property`BottomSheet`:sheet].
///
/// Bottom bar can be temporarily hidden using the
/// [property`BottomSheet`:reveal-bottom-bar] property.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter bottomBar: The bottom bar widget.
/// - Returns: A copy of this view with the modifier applied.
public func bottomBar(_ bottomBar: Adw.Widget?) -> Self {
appending { w, _ in
w.setBottomBar(bottomBar: bottomBar)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.BottomSheet.setBottomBar(bottomBar:)
/// Sets the bottom bar widget for `self`.
///
/// Shown when [property`BottomSheet`:open] is `FALSE`. When open, morphs into
/// the [property`BottomSheet`:sheet].
///
/// Bottom bar can be temporarily hidden using the
/// [property`BottomSheet`:reveal-bottom-bar] property.
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter bottomBar: The bottom bar widget.
/// - Returns: A copy of this view with the modifier applied.
public func bottomBar(@ViewBuilder _ bottomBar: () -> [AnyView]) -> Self {
let bottomBarViews = bottomBar()
return appending { w, ctx in
guard let v = bottomBarViews.first else { return }
w.setBottomBar(bottomBar: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setBottomBar(bottomBar:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getBottomBar()
/// Sets the bottom bar widget for `self`.
///
/// Shown when [property`BottomSheet`:open] is `FALSE`. When open, morphs into
/// the [property`BottomSheet`:sheet].
///
/// Bottom bar can be temporarily hidden using the
/// [property`BottomSheet`:reveal-bottom-bar] property.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Widget?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func bottomBar<W: Gtk.Widget>(_ bottomBar: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, bottomBar, registry: ctx.registry, notifyDetail: "bottom-bar",
read: { [w] in w.getBottomBar() as? W },
write: { [w] v in w.setBottomBar(bottomBar: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.BottomSheet.setBottomBar(bottomBar:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getBottomBar()
/// Sets the bottom bar widget for `self`.
///
/// Shown when [property`BottomSheet`:open] is `FALSE`. When open, morphs into
/// the [property`BottomSheet`:sheet].
///
/// Bottom bar can be temporarily hidden using the
/// [property`BottomSheet`:reveal-bottom-bar] property.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
/// When `Adw.Widget` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func bottomBar<W: Gtk.Widget>(_ bottomBar: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, bottomBar, registry: ctx.registry, notifyDetail: "bottom-bar",
read: { [w] in w.getBottomBar() as? W },
write: { [w] v in w.setBottomBar(bottomBar: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setBottomBar(bottomBar:)
/// Sets the bottom bar widget for `self`.
///
/// Shown when [property`BottomSheet`:open] is `FALSE`. When open, morphs into
/// the [property`BottomSheet`:sheet].
///
/// Bottom bar can be temporarily hidden using the
/// [property`BottomSheet`:reveal-bottom-bar] property.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setBottomBar(bottomBar:)`.
///
/// - Parameter bottomBar: The bottom bar widget.
/// - Returns: A copy of this view with the modifier applied.
public func bottomBar(_ bottomBar: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setBottomBar(bottomBar: bottomBar()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setCanClose(canClose:)
/// Sets whether the bottom sheet can be closed by user.
///
/// It can be closed via the close button, swiping down, pressing
/// <kbd>Escape</kbd> or clicking the content dimming (when modal).
///
/// Bottom sheet can still be closed using [property`BottomSheet`:open].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter canClose: Whether the bottom sheet can be closed by user.
/// - Returns: A copy of this view with the modifier applied.
public func canClose(_ canClose: Bool) -> Self {
appending { w, _ in
w.setCanClose(canClose: canClose)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setCanClose(canClose:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getCanClose()
/// Sets whether the bottom sheet can be closed by user.
///
/// It can be closed via the close button, swiping down, pressing
/// <kbd>Escape</kbd> or clicking the content dimming (when modal).
///
/// Bottom sheet can still be closed using [property`BottomSheet`:open].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func canClose(_ canClose: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, canClose, registry: ctx.registry, notifyDetail: "can-close",
read: { [w] in w.getCanClose() },
write: { [w] v in w.setCanClose(canClose: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setCanClose(canClose:)
/// Sets whether the bottom sheet can be closed by user.
///
/// It can be closed via the close button, swiping down, pressing
/// <kbd>Escape</kbd> or clicking the content dimming (when modal).
///
/// Bottom sheet can still be closed using [property`BottomSheet`:open].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setCanClose(canClose:)`.
///
/// - Parameter canClose: Whether the bottom sheet can be closed by user.
/// - Returns: A copy of this view with the modifier applied.
public func canClose(_ canClose: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCanClose(canClose: canClose()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setCanOpen(canOpen:)
/// Sets whether the bottom sheet can be opened by user.
///
/// It can be opened via clicking or swiping up from the bottom bar.
///
/// Does nothing if [property`BottomSheet`:bottom-bar] is not set.
///
/// Bottom sheet can still be opened using [property`BottomSheet`:open].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter canOpen: Whether the bottom sheet can be opened by user.
/// - Returns: A copy of this view with the modifier applied.
public func canOpen(_ canOpen: Bool) -> Self {
appending { w, _ in
w.setCanOpen(canOpen: canOpen)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setCanOpen(canOpen:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getCanOpen()
/// Sets whether the bottom sheet can be opened by user.
///
/// It can be opened via clicking or swiping up from the bottom bar.
///
/// Does nothing if [property`BottomSheet`:bottom-bar] is not set.
///
/// Bottom sheet can still be opened using [property`BottomSheet`:open].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func canOpen(_ canOpen: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, canOpen, registry: ctx.registry, notifyDetail: "can-open",
read: { [w] in w.getCanOpen() },
write: { [w] v in w.setCanOpen(canOpen: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setCanOpen(canOpen:)
/// Sets whether the bottom sheet can be opened by user.
///
/// It can be opened via clicking or swiping up from the bottom bar.
///
/// Does nothing if [property`BottomSheet`:bottom-bar] is not set.
///
/// Bottom sheet can still be opened using [property`BottomSheet`:open].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setCanOpen(canOpen:)`.
///
/// - Parameter canOpen: Whether the bottom sheet can be opened by user.
/// - Returns: A copy of this view with the modifier applied.
public func canOpen(_ canOpen: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCanOpen(canOpen: canOpen()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setContent(content:)
/// Sets the content widget for `self`.
///
/// It's always shown, and the bottom sheet is overlaid over it.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter content: The content widget.
/// - Returns: A copy of this view with the modifier applied.
public func content(_ content: Adw.Widget?) -> Self {
appending { w, _ in
w.setContent(content: content)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.BottomSheet.setContent(content:)
/// Sets the content widget for `self`.
///
/// It's always shown, and the bottom sheet is overlaid over it.
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter content: The content widget.
/// - Returns: A copy of this view with the modifier applied.
public func content(@ViewBuilder _ content: () -> [AnyView]) -> Self {
let contentViews = content()
return appending { w, ctx in
guard let v = contentViews.first else { return }
w.setContent(content: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setContent(content:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getContent()
/// Sets the content widget for `self`.
///
/// It's always shown, and the bottom sheet is overlaid over it.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Widget?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func content<W: Gtk.Widget>(_ content: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, content, registry: ctx.registry, notifyDetail: "content",
read: { [w] in w.getContent() as? W },
write: { [w] v in w.setContent(content: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.BottomSheet.setContent(content:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getContent()
/// Sets the content widget for `self`.
///
/// It's always shown, and the bottom sheet is overlaid over it.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
/// When `Adw.Widget` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func content<W: Gtk.Widget>(_ content: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, content, registry: ctx.registry, notifyDetail: "content",
read: { [w] in w.getContent() as? W },
write: { [w] v in w.setContent(content: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setContent(content:)
/// Sets the content widget for `self`.
///
/// It's always shown, and the bottom sheet is overlaid over it.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setContent(content:)`.
///
/// - Parameter content: The content widget.
/// - Returns: A copy of this view with the modifier applied.
public func content(_ content: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setContent(content: content()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setFullWidth(fullWidth:)
/// Sets whether the bottom sheet takes the full width.
///
/// When full width, [property`BottomSheet`:align] is ignored.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter fullWidth: Whether the bottom sheet takes the full width.
/// - Returns: A copy of this view with the modifier applied.
public func fullWidth(_ fullWidth: Bool) -> Self {
appending { w, _ in
w.setFullWidth(fullWidth: fullWidth)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setFullWidth(fullWidth:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getFullWidth()
/// Sets whether the bottom sheet takes the full width.
///
/// When full width, [property`BottomSheet`:align] is ignored.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func fullWidth(_ fullWidth: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, fullWidth, registry: ctx.registry, notifyDetail: "full-width",
read: { [w] in w.getFullWidth() },
write: { [w] v in w.setFullWidth(fullWidth: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setFullWidth(fullWidth:)
/// Sets whether the bottom sheet takes the full width.
///
/// When full width, [property`BottomSheet`:align] is ignored.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setFullWidth(fullWidth:)`.
///
/// - Parameter fullWidth: Whether the bottom sheet takes the full width.
/// - Returns: A copy of this view with the modifier applied.
public func fullWidth(_ fullWidth: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFullWidth(fullWidth: fullWidth()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setModal(modal:)
/// Sets whether the bottom sheet is modal.
///
/// When modal, [property`BottomSheet`:content] will be dimmed when the bottom
/// sheet is open, and clicking it will close the bottom sheet. It also cannot be
/// focused with keyboard.
///
/// Otherwise, the content is accessible even when the bottom sheet is open.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter modal: Whether the bottom sheet is modal.
/// - Returns: A copy of this view with the modifier applied.
public func modal(_ modal: Bool) -> Self {
appending { w, _ in
w.setModal(modal: modal)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setModal(modal:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getModal()
/// Sets whether the bottom sheet is modal.
///
/// When modal, [property`BottomSheet`:content] will be dimmed when the bottom
/// sheet is open, and clicking it will close the bottom sheet. It also cannot be
/// focused with keyboard.
///
/// Otherwise, the content is accessible even when the bottom sheet is open.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func modal(_ modal: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, modal, registry: ctx.registry, notifyDetail: "modal",
read: { [w] in w.getModal() },
write: { [w] v in w.setModal(modal: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setModal(modal:)
/// Sets whether the bottom sheet is modal.
///
/// When modal, [property`BottomSheet`:content] will be dimmed when the bottom
/// sheet is open, and clicking it will close the bottom sheet. It also cannot be
/// focused with keyboard.
///
/// Otherwise, the content is accessible even when the bottom sheet is open.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setModal(modal:)`.
///
/// - Parameter modal: Whether the bottom sheet is modal.
/// - Returns: A copy of this view with the modifier applied.
public func modal(_ modal: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setModal(modal: modal()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setOpen(`open`:)
/// Sets whether the bottom sheet is open.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter `open`: Whether the bottom sheet is open.
/// - Returns: A copy of this view with the modifier applied.
public func `open`(_ `open`: Bool) -> Self {
appending { w, _ in
w.setOpen(`open`: `open`)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setOpen(`open`:), GObject.Object.connectNotify(detail:_:)
/// Sets whether the bottom sheet is open.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func `open`(_ `open`: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, `open`, registry: ctx.registry, notifyDetail: "open",
read: { [w] in w.`open` },
write: { [w] v in w.setOpen(`open`: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setOpen(`open`:)
/// Sets whether the bottom sheet is open.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setOpen(`open`:)`.
///
/// - Parameter `open`: Whether the bottom sheet is open.
/// - Returns: A copy of this view with the modifier applied.
public func `open`(_ `open`: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setOpen(`open`: `open`()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setRevealBottomBar(reveal:)
/// Sets whether to reveal the bottom bar.
///
/// The transition will be animated.
///
/// See [property`BottomSheet`:bottom-bar] and
/// [property`BottomSheet`:bottom-bar-height].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter revealBottomBar: Whether to reveal the bottom bar.
/// - Returns: A copy of this view with the modifier applied.
public func revealBottomBar(_ revealBottomBar: Bool) -> Self {
appending { w, _ in
w.setRevealBottomBar(reveal: revealBottomBar)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setRevealBottomBar(reveal:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getRevealBottomBar()
/// Sets whether to reveal the bottom bar.
///
/// The transition will be animated.
///
/// See [property`BottomSheet`:bottom-bar] and
/// [property`BottomSheet`:bottom-bar-height].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func revealBottomBar(_ revealBottomBar: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, revealBottomBar, registry: ctx.registry, notifyDetail: "reveal-bottom-bar",
read: { [w] in w.getRevealBottomBar() },
write: { [w] v in w.setRevealBottomBar(reveal: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setRevealBottomBar(reveal:)
/// Sets whether to reveal the bottom bar.
///
/// The transition will be animated.
///
/// See [property`BottomSheet`:bottom-bar] and
/// [property`BottomSheet`:bottom-bar-height].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setRevealBottomBar(reveal:)`.
///
/// - Parameter revealBottomBar: Whether to reveal the bottom bar.
/// - Returns: A copy of this view with the modifier applied.
public func revealBottomBar(_ revealBottomBar: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setRevealBottomBar(reveal: revealBottomBar()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setSheet(sheet:)
/// Sets the bottom sheet widget for `self`.
///
/// Only shown when [property`BottomSheet`:open] is `TRUE`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter sheet: The bottom sheet widget.
/// - Returns: A copy of this view with the modifier applied.
public func sheet(_ sheet: Adw.Widget?) -> Self {
appending { w, _ in
w.setSheet(sheet: sheet)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.BottomSheet.setSheet(sheet:)
/// Sets the bottom sheet widget for `self`.
///
/// Only shown when [property`BottomSheet`:open] is `TRUE`.
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter sheet: The bottom sheet widget.
/// - Returns: A copy of this view with the modifier applied.
public func sheet(@ViewBuilder _ sheet: () -> [AnyView]) -> Self {
let sheetViews = sheet()
return appending { w, ctx in
guard let v = sheetViews.first else { return }
w.setSheet(sheet: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setSheet(sheet:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getSheet()
/// Sets the bottom sheet widget for `self`.
///
/// Only shown when [property`BottomSheet`:open] is `TRUE`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Widget?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func sheet<W: Gtk.Widget>(_ sheet: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sheet, registry: ctx.registry, notifyDetail: "sheet",
read: { [w] in w.getSheet() as? W },
write: { [w] v in w.setSheet(sheet: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.BottomSheet.setSheet(sheet:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getSheet()
/// Sets the bottom sheet widget for `self`.
///
/// Only shown when [property`BottomSheet`:open] is `TRUE`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
/// When `Adw.Widget` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func sheet<W: Gtk.Widget>(_ sheet: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sheet, registry: ctx.registry, notifyDetail: "sheet",
read: { [w] in w.getSheet() as? W },
write: { [w] v in w.setSheet(sheet: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setSheet(sheet:)
/// Sets the bottom sheet widget for `self`.
///
/// Only shown when [property`BottomSheet`:open] is `TRUE`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setSheet(sheet:)`.
///
/// - Parameter sheet: The bottom sheet widget.
/// - Returns: A copy of this view with the modifier applied.
public func sheet(_ sheet: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSheet(sheet: sheet()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.BottomSheet.setShowDragHandle(showDragHandle:)
/// Sets whether to show a drag handle in the bottom sheet.
///
/// The handle will be overlaid over [property`BottomSheet`:sheet].
///
/// When the handle is shown, [class`HeaderBar`] will hide its default title, and
/// [class`ToolbarView`] will reserve space if there are no top bars.
///
/// Showing drag handle also allows to swipe the bottom sheet down (and to swipe
/// the bottom bar up) with a pointer, instead of just touchscreen.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showDragHandle: Whether to overlay a drag handle in the bottom sheet.
/// - Returns: A copy of this view with the modifier applied.
public func showDragHandle(_ showDragHandle: Bool) -> Self {
appending { w, _ in
w.setShowDragHandle(showDragHandle: showDragHandle)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.BottomSheet.setShowDragHandle(showDragHandle:), GObject.Object.connectNotify(detail:_:), Adw.BottomSheet.getShowDragHandle()
/// Sets whether to show a drag handle in the bottom sheet.
///
/// The handle will be overlaid over [property`BottomSheet`:sheet].
///
/// When the handle is shown, [class`HeaderBar`] will hide its default title, and
/// [class`ToolbarView`] will reserve space if there are no top bars.
///
/// Showing drag handle also allows to swipe the bottom sheet down (and to swipe
/// the bottom bar up) with a pointer, instead of just touchscreen.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func showDragHandle(_ showDragHandle: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showDragHandle, registry: ctx.registry, notifyDetail: "show-drag-handle",
read: { [w] in w.getShowDragHandle() },
write: { [w] v in w.setShowDragHandle(showDragHandle: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.BottomSheet.setShowDragHandle(showDragHandle:)
/// Sets whether to show a drag handle in the bottom sheet.
///
/// The handle will be overlaid over [property`BottomSheet`:sheet].
///
/// When the handle is shown, [class`HeaderBar`] will hide its default title, and
/// [class`ToolbarView`] will reserve space if there are no top bars.
///
/// Showing drag handle also allows to swipe the bottom sheet down (and to swipe
/// the bottom bar up) with a pointer, instead of just touchscreen.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.BottomSheet.setShowDragHandle(showDragHandle:)`.
///
/// - Parameter showDragHandle: Whether to overlay a drag handle in the bottom sheet.
/// - Returns: A copy of this view with the modifier applied.
public func showDragHandle(_ showDragHandle: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowDragHandle(showDragHandle: showDragHandle()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.BottomSheet.connectCloseAttempt(_:)
/// Emitted when the close button or shortcut is used while
/// [property`Dialog`:can-close] is set to `FALSE`.
///
/// - Parameter handler: Invoked when the widget emits the `close-attempt` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onCloseAttempt(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectCloseAttempt { _ in handler() })
}
}
}