522 lines
27 KiB
Swift
522 lines
27 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.ViewStack
|
|
/// A view container for [class`ViewSwitcher`].
|
|
///
|
|
/// `AdwViewStack` is a container which only shows one page at a time.
|
|
/// It is typically used to hold an application's main views.
|
|
///
|
|
/// It doesn't provide a way to transition between pages.
|
|
/// Instead, a separate widget such as [class`ViewSwitcher`],
|
|
/// [class`InlineViewSwitcher`] or [class`ViewSwitcherSidebar`] can be used with
|
|
/// `AdwViewStack` to provide this functionality.
|
|
///
|
|
/// `AdwViewStack` pages can have a title, an icon, an attention request, and a
|
|
/// numbered badge that [class`ViewSwitcher`] will use to let users identify which
|
|
/// page is which. Set them using the [property`ViewStackPage`:title],
|
|
/// [property`ViewStackPage`:icon-name],
|
|
/// [property`ViewStackPage`:needs-attention], and
|
|
/// [property`ViewStackPage`:badge-number] properties.
|
|
///
|
|
/// `AdwViewStack` pages can also be grouped into sections, using the
|
|
/// [property`ViewStackPage`:starts-section] and
|
|
/// [property`ViewStackPage`:section-title] properties. Currently, only
|
|
/// [class`ViewSwitcherSidebar`] displays groups.
|
|
///
|
|
/// Unlike [class`Gtk`.Stack], transitions between views can only be animated via
|
|
/// a crossfade and size changes are always interpolated. Animations are disabled
|
|
/// by default. Use [property`ViewStack`:enable-transitions] to enable them.
|
|
///
|
|
/// `AdwViewStack` maintains a [class`ViewStackPage`] object for each added child,
|
|
/// which holds additional per-child properties. You obtain the
|
|
/// [class`ViewStackPage`] for a child with [method`ViewStack`.get_page] and you
|
|
/// can obtain a [iface`Gtk`.SelectionModel] containing all the pages with
|
|
/// [method`ViewStack`.get_pages].
|
|
///
|
|
/// ## AdwViewStack as GtkBuildable
|
|
///
|
|
/// To set child-specific properties in a .ui file, create
|
|
/// [class`ViewStackPage`] objects explicitly, and set the child widget as a
|
|
/// property on it:
|
|
///
|
|
/// ```xml
|
|
/// <object class="AdwViewStack" id="stack">
|
|
/// <child>
|
|
/// <object class="AdwViewStackPage">
|
|
/// <property name="name">overview</property>
|
|
/// <property name="title">Overview</property>
|
|
/// <property name="child">
|
|
/// <object class="AdwStatusPage">
|
|
/// <property name="title">Welcome!</property>
|
|
/// </object>
|
|
/// </property>
|
|
/// </object>
|
|
/// </child>
|
|
/// </object>
|
|
/// ```
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `AdwViewStack` has a single CSS node named `stack`.
|
|
///
|
|
/// ## Accessibility
|
|
///
|
|
/// `AdwViewStack` uses the [enum`Gtk`.AccessibleRole.tab-panel] for the stack
|
|
/// pages which are the accessible parent objects of the child widgets.
|
|
///
|
|
/// A Portico view that mounts a `Adw.ViewStack`.
|
|
@MainActor public struct ViewStack: View {
|
|
private let make: (MountContext) -> Adw.ViewStack
|
|
private var configure: [(Adw.ViewStack, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.ViewStack.init()
|
|
/// Creates a new `AdwViewStack`.
|
|
///
|
|
/// 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.
|
|
/// A `ForEach` in the `children:` closure spreads its rows directly into this widget, with no wrapper, when the widget supports ordered insertion.
|
|
/// 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 enableTransitions: Whether the stack uses a crossfade transition between pages.
|
|
/// - Parameter hhomogeneous: Whether the stack is horizontally homogeneous.
|
|
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
|
|
/// - Parameter vhomogeneous: Whether the stack is vertically homogeneous.
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
|
|
public init(enableTransitions: Bool? = nil, hhomogeneous: Bool? = nil, transitionDuration: UInt32? = nil, vhomogeneous: Bool? = nil, visibleChildName: String? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Adw.ViewStack() }
|
|
configure.append { w, ctx in
|
|
if let enableTransitions { w.setEnableTransitions(enableTransitions: enableTransitions) }
|
|
if let hhomogeneous { w.setHhomogeneous(hhomogeneous: hhomogeneous) }
|
|
if let transitionDuration { w.setTransitionDuration(duration: transitionDuration) }
|
|
if let vhomogeneous { w.setVhomogeneous(vhomogeneous: vhomogeneous) }
|
|
if let visibleChildName { w.setVisibleChildName(name: visibleChildName) }
|
|
Portico.mountChildren(children, into: w, ctx) { c in _ = w.add(child: c) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension ViewStack: WidgetView {
|
|
public typealias Target = Adw.ViewStack
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.ViewStack, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension ViewStack: 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.ViewStack
|
|
/// Modifiers for `Adw.ViewStack`, available on every Portico view whose
|
|
/// backing widget is `Adw.ViewStack` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.ViewStack {
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.ViewStack.add(child:)
|
|
/// Adds a child to `self`.
|
|
///
|
|
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
|
|
///
|
|
/// - Parameter child: A child widget to add.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func add(_ child: Gtk.Widget) -> Self {
|
|
appending { w, _ in
|
|
_ = w.add(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.ViewStack.add(child:)
|
|
/// Adds a child to `self`.
|
|
///
|
|
/// Every view the closure produces is added at mount, in order.
|
|
///
|
|
/// - Parameter child: A closure producing child views.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func add(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
for v in childViews { _ = w.add(child: v.makeWidget(ctx)) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setEnableTransitions(enableTransitions:)
|
|
/// Sets whether `self` uses a crossfade transition between pages.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter enableTransitions: Whether the stack uses a crossfade transition between pages.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableTransitions(_ enableTransitions: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setEnableTransitions(enableTransitions: enableTransitions)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setEnableTransitions(enableTransitions:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getEnableTransitions()
|
|
/// Sets whether `self` uses a crossfade transition between pages.
|
|
///
|
|
/// 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 enableTransitions(_ enableTransitions: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, enableTransitions, registry: ctx.registry, notifyDetail: "enable-transitions",
|
|
read: { [w] in w.getEnableTransitions() },
|
|
write: { [w] v in w.setEnableTransitions(enableTransitions: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setEnableTransitions(enableTransitions:)
|
|
/// Sets whether `self` uses a crossfade transition between pages.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setEnableTransitions(enableTransitions:)`.
|
|
///
|
|
/// - Parameter enableTransitions: Whether the stack uses a crossfade transition between pages.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableTransitions(_ enableTransitions: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setEnableTransitions(enableTransitions: enableTransitions()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setHhomogeneous(hhomogeneous:)
|
|
/// Sets `self` to be horizontally homogeneous or not.
|
|
///
|
|
/// If the stack is horizontally homogeneous, it allocates the same width for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change width when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter hhomogeneous: Whether the stack is horizontally homogeneous.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hhomogeneous(_ hhomogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHhomogeneous(hhomogeneous: hhomogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setHhomogeneous(hhomogeneous:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getHhomogeneous()
|
|
/// Sets `self` to be horizontally homogeneous or not.
|
|
///
|
|
/// If the stack is horizontally homogeneous, it allocates the same width for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change width when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// 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 hhomogeneous(_ hhomogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, hhomogeneous, registry: ctx.registry, notifyDetail: "hhomogeneous",
|
|
read: { [w] in w.getHhomogeneous() },
|
|
write: { [w] v in w.setHhomogeneous(hhomogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setHhomogeneous(hhomogeneous:)
|
|
/// Sets `self` to be horizontally homogeneous or not.
|
|
///
|
|
/// If the stack is horizontally homogeneous, it allocates the same width for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change width when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setHhomogeneous(hhomogeneous:)`.
|
|
///
|
|
/// - Parameter hhomogeneous: Whether the stack is horizontally homogeneous.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hhomogeneous(_ hhomogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHhomogeneous(hhomogeneous: hhomogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setTransitionDuration(duration:)
|
|
/// Sets the transition animation duration for `self`.
|
|
///
|
|
/// Only used when [property`ViewStack`:enable-transitions] is set to `TRUE`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionDuration(_ transitionDuration: UInt32) -> Self {
|
|
appending { w, _ in
|
|
w.setTransitionDuration(duration: transitionDuration)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setTransitionDuration(duration:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getTransitionDuration()
|
|
/// Sets the transition animation duration for `self`.
|
|
///
|
|
/// Only used when [property`ViewStack`:enable-transitions] is set to `TRUE`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `UInt32` 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 transitionDuration(_ transitionDuration: Portico.Binding<UInt32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, transitionDuration, registry: ctx.registry, notifyDetail: "transition-duration",
|
|
read: { [w] in w.getTransitionDuration() },
|
|
write: { [w] v in w.setTransitionDuration(duration: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setTransitionDuration(duration:)
|
|
/// Sets the transition animation duration for `self`.
|
|
///
|
|
/// Only used when [property`ViewStack`:enable-transitions] is set to `TRUE`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setTransitionDuration(duration:)`.
|
|
///
|
|
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionDuration(_ transitionDuration: @escaping () -> UInt32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTransitionDuration(duration: transitionDuration()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setVhomogeneous(vhomogeneous:)
|
|
/// Sets `self` to be vertically homogeneous or not.
|
|
///
|
|
/// If the stack is vertically homogeneous, it allocates the same height for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change height when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter vhomogeneous: Whether the stack is vertically homogeneous.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func vhomogeneous(_ vhomogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setVhomogeneous(vhomogeneous: vhomogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setVhomogeneous(vhomogeneous:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getVhomogeneous()
|
|
/// Sets `self` to be vertically homogeneous or not.
|
|
///
|
|
/// If the stack is vertically homogeneous, it allocates the same height for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change height when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// 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 vhomogeneous(_ vhomogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, vhomogeneous, registry: ctx.registry, notifyDetail: "vhomogeneous",
|
|
read: { [w] in w.getVhomogeneous() },
|
|
write: { [w] v in w.setVhomogeneous(vhomogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setVhomogeneous(vhomogeneous:)
|
|
/// Sets `self` to be vertically homogeneous or not.
|
|
///
|
|
/// If the stack is vertically homogeneous, it allocates the same height for
|
|
/// all children.
|
|
///
|
|
/// If it's `FALSE`, the stack may change height when a different child becomes
|
|
/// visible.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setVhomogeneous(vhomogeneous:)`.
|
|
///
|
|
/// - Parameter vhomogeneous: Whether the stack is vertically homogeneous.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func vhomogeneous(_ vhomogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVhomogeneous(vhomogeneous: vhomogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `self`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: Adw.Widget) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChild(child: visibleChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.ViewStack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `self`.
|
|
///
|
|
/// 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 visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(@ViewBuilder _ visibleChild: () -> [AnyView]) -> Self {
|
|
let visibleChildViews = visibleChild()
|
|
return appending { w, ctx in
|
|
guard let v = visibleChildViews.first else { return }
|
|
w.setVisibleChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setVisibleChild(child:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getVisibleChild()
|
|
/// Makes `child` the visible child of `self`.
|
|
///
|
|
/// 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 visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChild, registry: ctx.registry, notifyDetail: "visible-child",
|
|
read: { [w] in w.getVisibleChild() as? W },
|
|
write: { [w] v in w.setVisibleChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Adw.ViewStack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `self`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding (what a `WidgetRef` projects) and ignores `nil` values. Binds one way only.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
if let v = visibleChild.untrackedValue { w.setVisibleChild(child: v) }
|
|
ctx.registry.add(visibleChild.subscribe { [w] v in if let v { w.setVisibleChild(child: v) } })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setVisibleChild(child:)`.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: @escaping () -> Adw.Widget) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChild(child: visibleChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ViewStack.setVisibleChildName(name:)
|
|
/// Makes the child with `name` visible.
|
|
///
|
|
/// See [property`ViewStack`:visible-child].
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func visibleChildName<S: StringProtocol>(_ visibleChildName: S) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChildName(name: String(visibleChildName))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ViewStack.setVisibleChildName(name:), GObject.Object.connectNotify(detail:_:), Adw.ViewStack.getVisibleChildName()
|
|
/// Makes the child with `name` visible.
|
|
///
|
|
/// See [property`ViewStack`:visible-child].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String` 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 visibleChildName(_ visibleChildName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChildName, registry: ctx.registry, notifyDetail: "visible-child-name",
|
|
read: { [w] in w.getVisibleChildName() },
|
|
write: { [w] v in w.setVisibleChildName(name: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ViewStack.setVisibleChildName(name:)
|
|
/// Makes the child with `name` visible.
|
|
///
|
|
/// See [property`ViewStack`:visible-child].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ViewStack.setVisibleChildName(name:)`.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChildName(name: visibleChildName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.ViewStack.setVisibleChildName(name:)
|
|
/// Makes the child with `name` visible.
|
|
///
|
|
/// See [property`ViewStack`:visible-child].
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ViewStack.setVisibleChildName(name:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(visibleChildName, registry: ctx.registry) { [w] v in w.setVisibleChildName(name: v) }
|
|
}
|
|
}
|
|
|
|
}
|