diff --git a/Documentation/Reference/README.md b/Documentation/Reference/README.md index bf39c27..da594e4 100644 --- a/Documentation/Reference/README.md +++ b/Documentation/Reference/README.md @@ -50,6 +50,8 @@ - [MenuSection](structs/MenuSection.md) - [ModifierStopper](structs/ModifierStopper.md) - [NavigationSplitView](structs/NavigationSplitView.md) +- [NavigationView](structs/NavigationView.md) +- [NavigationView.NavigationStack](structs/NavigationView.NavigationStack.md) - [Overlay](structs/Overlay.md) - [OverlaySplitView](structs/OverlaySplitView.md) - [PasswordEntryRow](structs/PasswordEntryRow.md) @@ -99,7 +101,9 @@ - [Edge](enums/Edge.md) - [Icon](enums/Icon.md) - [Icon.DefaultIcon](enums/Icon.DefaultIcon.md) +- [NavigationView.Action](enums/NavigationView.Action.md) - [Transition](enums/Transition.md) +- [UpdateManager](enums/UpdateManager.md) - [ViewBuilder](enums/ViewBuilder.md) - [ViewBuilder.Component](enums/ViewBuilder.Component.md) @@ -123,6 +127,7 @@ - [Menu](extensions/Menu.md) - [MenuItem](extensions/MenuItem.md) - [MenuItemGroup](extensions/MenuItemGroup.md) +- [NavigationView](extensions/NavigationView.md) - [OpaquePointer](extensions/OpaquePointer.md) - [OverlaySplitView](extensions/OverlaySplitView.md) - [PasswordEntryRow](extensions/PasswordEntryRow.md) @@ -154,6 +159,7 @@ - [List](typealiases/List.md) - [MenuBuilder](typealiases/MenuBuilder.md) - [MenuContent](typealiases/MenuContent.md) +- [NavigationStack](typealiases/NavigationStack.md) - [Scene](typealiases/Scene.md) - [SceneBuilder](typealiases/SceneBuilder.md) - [ScrollView](typealiases/ScrollView.md) diff --git a/Documentation/Reference/enums/NavigationView.Action.md b/Documentation/Reference/enums/NavigationView.Action.md new file mode 100644 index 0000000..6c6e5c8 --- /dev/null +++ b/Documentation/Reference/enums/NavigationView.Action.md @@ -0,0 +1,14 @@ +**ENUM** + +# `NavigationView.Action` + +An action to run on a view update. + +## Cases +### `pop` + +Remove the last item. + +### `push(component:)` + +Add a new item. diff --git a/Documentation/Reference/enums/UpdateManager.md b/Documentation/Reference/enums/UpdateManager.md new file mode 100644 index 0000000..4669866 --- /dev/null +++ b/Documentation/Reference/enums/UpdateManager.md @@ -0,0 +1,16 @@ +**ENUM** + +# `UpdateManager` + +This type manages view updates. + +## Properties +### `blockUpdates` + +The class storing the value. + +## Methods +### `updateViews(force:)` + +Update all of the views. +- Parameter force: Whether to force all views to update. diff --git a/Documentation/Reference/extensions/NavigationView.md b/Documentation/Reference/extensions/NavigationView.md new file mode 100644 index 0000000..b266b0a --- /dev/null +++ b/Documentation/Reference/extensions/NavigationView.md @@ -0,0 +1,18 @@ +**EXTENSION** + +# `NavigationView` + +## Properties +### `componentID` + +The ID for the component field in a content storage. + +## Methods +### `init(_:_:content:initialView:)` + +Initialize a navigation view. +- Parameters: + - stack: The navigation stack for pushing and popping. + - initialTitle: The title of the initial view. + - content: The view for a path component. + - initialView: The view that is displayed when the path is empty. diff --git a/Documentation/Reference/structs/Label.md b/Documentation/Reference/structs/Label.md index 2e84bf9..20f628a 100644 --- a/Documentation/Reference/structs/Label.md +++ b/Documentation/Reference/structs/Label.md @@ -34,7 +34,7 @@ visited. In this case, label node also gets a .link style class. The GtkLabel implementation of the GtkBuildable interface supports a custom `` element, which supports any number of `` -elements. The element has attributes named “name“, “value“, +elements. The `` element has attributes named “name“, “value“, “start“ and “end“ and allows you to specify [struct@Pango.Attribute] values for this label. @@ -64,8 +64,9 @@ to the functions [ctor@Gtk.Label.new_with_mnemonic] or Mnemonics automatically activate any activatable widget the label is inside, such as a [class@Gtk.Button]; if the label is not inside the mnemonic’s target widget, you have to tell the label about the target -using [class@Gtk.Label.set_mnemonic_widget]. Here’s a simple example where -the label is inside a button: +using [method@Gtk.Label.set_mnemonic_widget]. + +Here’s a simple example where the label is inside a button: ```c // Pressing Alt+H will activate this button diff --git a/Documentation/Reference/structs/NavigationView.NavigationStack.md b/Documentation/Reference/structs/NavigationView.NavigationStack.md new file mode 100644 index 0000000..440411f --- /dev/null +++ b/Documentation/Reference/structs/NavigationView.NavigationStack.md @@ -0,0 +1,24 @@ +**STRUCT** + +# `NavigationView.NavigationStack` + +A stack controls a navigation view. + +## Properties +### `action` + +The action to run at the next view update, if any. + +## Methods +### `init()` + +Initialize a navigation stack. + +### `pop()` + +Remove the last item from the navigation view. + +### `push(_:)` + +Add a new item to the navigation view. +- Parameter component: The component's value. diff --git a/Documentation/Reference/structs/NavigationView.md b/Documentation/Reference/structs/NavigationView.md new file mode 100644 index 0000000..9e3d3b7 --- /dev/null +++ b/Documentation/Reference/structs/NavigationView.md @@ -0,0 +1,248 @@ +**STRUCT** + +# `NavigationView` + +A page-based navigation container. + +navigation-view + +`AdwNavigationView` presents one child at a time, similar to +[class@Gtk.Stack]. + +`AdwNavigationView` can only contain [class@NavigationPage] children. + +It maintains a navigation stack that can be controlled with +[method@NavigationView.push] and [method@NavigationView.pop]. The whole +navigation stack can also be replaced using [method@NavigationView.replace]. + +`AdwNavigationView` allows to manage pages statically or dynamically. + +Static pages can be added using the [method@NavigationView.add] method. The +`AdwNavigationView` will keep a reference to these pages, but they aren't +accessible to the user until [method@NavigationView.push] is called (except +for the first page, which is pushed automatically). Use the +[method@NavigationView.remove] method to remove them. This is useful for +applications that have a small number of unique pages and just need +navigation between them. + +Dynamic pages are automatically destroyed once they are popped off the +navigation stack. To add a page like this, push it using the +[method@NavigationView.push] method without calling +[method@NavigationView.add] first. + +## Tags + +Static pages, as well as any pages in the navigation stack, can be accessed +by their [property@NavigationPage:tag]. For example, +[method@NavigationView.push_by_tag] can be used to push a static page that's +not in the navigation stack without having to keep a reference to it manually. + +## Header Bar Integration + +When used inside `AdwNavigationView`, [class@HeaderBar] will automatically +display a back button that can be used to go back to the previous page when +possible. The button also has a context menu, allowing to pop multiple pages +at once, potentially across multiple navigation views. + +Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior +if it's unwanted. + +`AdwHeaderBar` will also display the title of the `AdwNavigationPage` it's +placed into, so most applications shouldn't need to customize it at all. + +## Shortcuts and Gestures + +`AdwNavigationView` supports the following shortcuts for going to the +previous page: + +- Escape (unless [property@NavigationView:pop-on-escape] is set to +`FALSE`) +- Alt+ +- Back mouse button + +Additionally, it supports interactive gestures: + +- One-finger swipe towards the right on touchscreens +- Scrolling towards the right on touchpads (usually two-finger swipe) + +These gestures have transitions enabled regardless of the +[property@NavigationView:animate-transitions] value. + +Applications can also enable shortcuts for pushing another page onto the +navigation stack via connecting to the [signal@NavigationView::get-next-page] +signal, in that case the following shortcuts are supported: + +- Alt+ +- Forward mouse button +- Swipe/scrolling towards the left + +For right-to-left locales, the gestures and shortcuts are reversed. + +[property@NavigationPage:can-pop] can be used to disable them, along with the +header bar back buttons. + +## Actions + +`AdwNavigationView` defines actions for controlling the navigation stack. +actions for controlling the navigation stack: + +- `navigation.push` takes a string parameter specifying the tag of the page to +push, and is equivalent to calling [method@NavigationView.push_by_tag]. + +- `navigation.pop` doesn't take any parameters and pops the current page from +the navigation stack, equivalent to calling [method@NavigationView.pop]. + +## `AdwNavigationView` as `GtkBuildable` + +`AdwNavigationView` allows to add pages as children, equivalent to using the +[method@NavigationView.add] method. + +Example of an `AdwNavigationView` UI definition: + +```xml +Page 1Open Page 2centercenternavigation.push'page-2'Page 2page-2 +``` + +navigation-view-example + +## CSS nodes + +`AdwNavigationView` has a single CSS node with the name `navigation-view`. + +## Accessibility + +`AdwNavigationView` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role. + +## Properties +### `updateFunctions` + +Additional update functions for type extensions. + +### `appearFunctions` + +Additional appear functions for type extensions. + +### `animateTransitions` + +Whether to animate page transitions. + +Gesture-based transitions are always animated. + +### `popOnEscape` + +Whether pressing Escape pops the current page. + +Applications using `AdwNavigationView` to implement a browser may want to +disable it. + +### `getNextPage` + +Emitted when a push shortcut or a gesture is triggered. + +To support the push shortcuts and gestures, the application is expected to +return the page to push in the handler. + +This signal can be emitted multiple times for the gestures, for example +when the gesture is cancelled by the user. As such, the application must +not make any irreversible changes in the handler, such as removing the page +from a forward stack. + +Instead, it should be done in the [signal@NavigationView::pushed] handler. + +### `popped` + +Emitted after @page has been popped from the navigation stack. + +See [method@NavigationView.pop]. + +When using [method@NavigationView.pop_to_page] or +[method@NavigationView.pop_to_tag], this signal is emitted for each of the +popped pages. + +### `pushed` + +Emitted after a page has been pushed to the navigation stack. + +See [method@NavigationView.push]. + +### `replaced` + +Emitted after the navigation stack has been replaced. + +See [method@NavigationView.replace]. + +### `app` + +The application. + +### `window` + +The window. + +## Methods +### `init()` + +Initialize `NavigationView`. + +### `container(modifiers:)` + +Get the widget's view storage. +- Parameter modifiers: The view modifiers. +- Returns: The view storage. + +### `update(_:modifiers:updateProperties:)` + +Update the widget's view storage. +- Parameters: + - storage: The view storage. + - modifiers: The view modifiers. + - updateProperties: Whether to update the view's properties. + +### `animateTransitions(_:)` + +Whether to animate page transitions. + +Gesture-based transitions are always animated. + +### `popOnEscape(_:)` + +Whether pressing Escape pops the current page. + +Applications using `AdwNavigationView` to implement a browser may want to +disable it. + +### `getNextPage(_:)` + +Emitted when a push shortcut or a gesture is triggered. + +To support the push shortcuts and gestures, the application is expected to +return the page to push in the handler. + +This signal can be emitted multiple times for the gestures, for example +when the gesture is cancelled by the user. As such, the application must +not make any irreversible changes in the handler, such as removing the page +from a forward stack. + +Instead, it should be done in the [signal@NavigationView::pushed] handler. + +### `popped(_:)` + +Emitted after @page has been popped from the navigation stack. + +See [method@NavigationView.pop]. + +When using [method@NavigationView.pop_to_page] or +[method@NavigationView.pop_to_tag], this signal is emitted for each of the +popped pages. + +### `pushed(_:)` + +Emitted after a page has been pushed to the navigation stack. + +See [method@NavigationView.push]. + +### `replaced(_:)` + +Emitted after the navigation stack has been replaced. + +See [method@NavigationView.replace]. diff --git a/Documentation/Reference/structs/ScrolledWindow.md b/Documentation/Reference/structs/ScrolledWindow.md index 491a11d..a8c5ea5 100644 --- a/Documentation/Reference/structs/ScrolledWindow.md +++ b/Documentation/Reference/structs/ScrolledWindow.md @@ -90,6 +90,10 @@ The accessible role cannot be changed once set. The child widget. +When setting this property, if the child widget does not implement +[iface@Gtk.Scrollable], the scrolled window will add the child to +a [class@Gtk.Viewport] and then set the viewport as the child. + ### `hasFrame` Whether to draw a frame around the contents. @@ -224,6 +228,10 @@ The accessible role cannot be changed once set. The child widget. +When setting this property, if the child widget does not implement +[iface@Gtk.Scrollable], the scrolled window will add the child to +a [class@Gtk.Viewport] and then set the viewport as the child. + ### `hasFrame(_:)` Whether to draw a frame around the contents. diff --git a/Documentation/Reference/typealiases/NavigationStack.md b/Documentation/Reference/typealiases/NavigationStack.md new file mode 100644 index 0000000..4e295f8 --- /dev/null +++ b/Documentation/Reference/typealiases/NavigationStack.md @@ -0,0 +1,5 @@ +**TYPEALIAS** + +# `NavigationStack` + +A stack controls a navigation view. \ No newline at end of file diff --git a/Sources/Adwaita/Model/Data Flow/State.swift b/Sources/Adwaita/Model/Data Flow/State.swift index a3b7f57..83d5ddb 100644 --- a/Sources/Adwaita/Model/Data Flow/State.swift +++ b/Sources/Adwaita/Model/Data Flow/State.swift @@ -114,9 +114,7 @@ public struct State: StateProtocol { /// Update all of the views. /// - Parameter force: Whether to force all views to update. public static func updateViews(force: Bool = false) { - for handler in GTUIApp.updateHandlers { - handler(force) - } + UpdateManager.updateViews(force: force) } /// The directory used for storing user data. diff --git a/Sources/Adwaita/Model/Data Flow/UpdateManager.swift b/Sources/Adwaita/Model/Data Flow/UpdateManager.swift new file mode 100644 index 0000000..5d4e576 --- /dev/null +++ b/Sources/Adwaita/Model/Data Flow/UpdateManager.swift @@ -0,0 +1,24 @@ +// +// UpdateManager.swift +// Adwaita +// +// Created by david-swift on 17.02.23. +// + +/// This type manages view updates. +enum UpdateManager { + + /// The class storing the value. + static var blockUpdates = false + + /// Update all of the views. + /// - Parameter force: Whether to force all views to update. + static func updateViews(force: Bool = false) { + if !blockUpdates { + for handler in GTUIApp.updateHandlers { + handler(force) + } + } + } + +} diff --git a/Sources/Adwaita/View/FlowBox+.swift b/Sources/Adwaita/View/FlowBox+.swift index ea129b4..abd3010 100644 --- a/Sources/Adwaita/View/FlowBox+.swift +++ b/Sources/Adwaita/View/FlowBox+.swift @@ -33,7 +33,7 @@ extension FlowBox { return nil } if let selection { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields[Self.selectionField] = selection storage.connectSignal(name: "selected_children_changed", id: Self.selectionField) { if let binding = storage.fields[Self.selectionField] as? Binding, @@ -43,14 +43,14 @@ extension FlowBox { } } } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if selection.wrappedValue != id(storage, elements), let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt { gtk_flow_box_select_child(storage.pointer, gtk_flow_box_get_child_at_index(storage.pointer, index)) } } } else { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in gtk_flow_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE) } } diff --git a/Sources/Adwaita/View/Forms/ComboRow+.swift b/Sources/Adwaita/View/Forms/ComboRow+.swift index 3e4201d..e5e814f 100644 --- a/Sources/Adwaita/View/Forms/ComboRow+.swift +++ b/Sources/Adwaita/View/Forms/ComboRow+.swift @@ -32,12 +32,12 @@ extension ComboRow { selection.wrappedValue = id } }) - appearFunctions.append { storage in + appearFunctions.append { storage, _ in let list = gtk_string_list_new(nil) storage.fields[Self.stringList] = list adw_combo_row_set_model(storage.pointer?.cast(), list) } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if let list = storage.fields[Self.stringList] as? OpaquePointer { let old = storage.fields[Self.values] as? [Element] ?? [] old.identifiableTransform( diff --git a/Sources/Adwaita/View/Forms/EntryRow+.swift b/Sources/Adwaita/View/Forms/EntryRow+.swift index 1bf0d90..b11cfa8 100644 --- a/Sources/Adwaita/View/Forms/EntryRow+.swift +++ b/Sources/Adwaita/View/Forms/EntryRow+.swift @@ -18,7 +18,7 @@ extension EntryRow { public init(_ title: String, text: Binding) { self.init() self = self.title(title) - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields[Self.textField] = text storage.notify(name: "text") { if let binding = storage.fields[Self.textField] as? Binding { @@ -26,7 +26,7 @@ extension EntryRow { } } } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) { gtk_editable_set_text(storage.pointer, text.wrappedValue) } diff --git a/Sources/Adwaita/View/Forms/PasswordEntryRow+.swift b/Sources/Adwaita/View/Forms/PasswordEntryRow+.swift index 5fdf8fc..a1402e4 100644 --- a/Sources/Adwaita/View/Forms/PasswordEntryRow+.swift +++ b/Sources/Adwaita/View/Forms/PasswordEntryRow+.swift @@ -18,7 +18,7 @@ extension PasswordEntryRow { public init(_ title: String, text: Binding) { self.init() self = self.title(title) - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields[Self.textField] = text storage.notify(name: "text") { if let binding = storage.fields[Self.textField] as? Binding { @@ -26,7 +26,7 @@ extension PasswordEntryRow { } } } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) { gtk_editable_set_text(storage.pointer, text.wrappedValue) } diff --git a/Sources/Adwaita/View/Forms/SpinRow+.swift b/Sources/Adwaita/View/Forms/SpinRow+.swift index 2d145ed..8695afb 100644 --- a/Sources/Adwaita/View/Forms/SpinRow+.swift +++ b/Sources/Adwaita/View/Forms/SpinRow+.swift @@ -35,7 +35,7 @@ extension SpinRow { self = self.title(title) self = self.value(value) self = self.step(1) - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in adw_spin_row_set_range(storage.pointer, min, max) } } @@ -52,7 +52,7 @@ extension SpinRow { /// - Returns: The spin row. public func step(_ step: Double) -> Self { var newSelf = self - newSelf.updateFunctions.append { storage in + newSelf.updateFunctions.append { storage, _, _ in let adjustment = adw_spin_row_get_adjustment(storage.pointer) gtk_adjustment_set_step_increment(adjustment, step) } diff --git a/Sources/Adwaita/View/Generated/ActionRow.swift b/Sources/Adwaita/View/Generated/ActionRow.swift index 8137e7c..c30569b 100644 --- a/Sources/Adwaita/View/Generated/ActionRow.swift +++ b/Sources/Adwaita/View/Generated/ActionRow.swift @@ -2,7 +2,7 @@ // ActionRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -42,9 +42,9 @@ import LevenshteinTransformations public struct ActionRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The widget to activate when the row is activated. /// @@ -132,7 +132,7 @@ public struct ActionRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -206,7 +206,7 @@ public struct ActionRow: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Avatar.swift b/Sources/Adwaita/View/Generated/Avatar.swift index 2a9490a..5ce8cd1 100644 --- a/Sources/Adwaita/View/Generated/Avatar.swift +++ b/Sources/Adwaita/View/Generated/Avatar.swift @@ -2,7 +2,7 @@ // Avatar.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -31,9 +31,9 @@ import LevenshteinTransformations public struct Avatar: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The name of an icon to use as a fallback. /// @@ -69,7 +69,7 @@ public struct Avatar: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -98,7 +98,7 @@ public struct Avatar: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Banner.swift b/Sources/Adwaita/View/Generated/Banner.swift index 896bfa8..5bf5aa7 100644 --- a/Sources/Adwaita/View/Generated/Banner.swift +++ b/Sources/Adwaita/View/Generated/Banner.swift @@ -2,7 +2,7 @@ // Banner.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -30,9 +30,9 @@ import LevenshteinTransformations public struct Banner: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The label to show on the button. /// @@ -73,7 +73,7 @@ public struct Banner: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -107,7 +107,7 @@ public struct Banner: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Bin.swift b/Sources/Adwaita/View/Generated/Bin.swift index f45f07a..6b9939d 100644 --- a/Sources/Adwaita/View/Generated/Bin.swift +++ b/Sources/Adwaita/View/Generated/Bin.swift @@ -2,7 +2,7 @@ // Bin.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -20,9 +20,9 @@ import LevenshteinTransformations public struct Bin: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The child widget of the `AdwBin`. var child: (() -> Body)? @@ -47,7 +47,7 @@ public struct Bin: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -67,7 +67,7 @@ public struct Bin: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Box.swift b/Sources/Adwaita/View/Generated/Box.swift index df7e7b0..9f4b226 100644 --- a/Sources/Adwaita/View/Generated/Box.swift +++ b/Sources/Adwaita/View/Generated/Box.swift @@ -2,7 +2,7 @@ // Box.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -45,9 +45,9 @@ import LevenshteinTransformations public struct Box: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -93,7 +93,7 @@ public struct Box: Widget { } storage.content["prepend"] = prependStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -141,7 +141,7 @@ public struct Box: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Button.swift b/Sources/Adwaita/View/Generated/Button.swift index 17bc719..0105efa 100644 --- a/Sources/Adwaita/View/Generated/Button.swift +++ b/Sources/Adwaita/View/Generated/Button.swift @@ -2,7 +2,7 @@ // Button.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -41,9 +41,9 @@ import LevenshteinTransformations public struct Button: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -101,7 +101,7 @@ public struct Button: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -149,7 +149,7 @@ public struct Button: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ButtonContent.swift b/Sources/Adwaita/View/Generated/ButtonContent.swift index 0172f68..c9ad0b5 100644 --- a/Sources/Adwaita/View/Generated/ButtonContent.swift +++ b/Sources/Adwaita/View/Generated/ButtonContent.swift @@ -2,7 +2,7 @@ // ButtonContent.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -46,9 +46,9 @@ import LevenshteinTransformations public struct ButtonContent: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether the button can be smaller than the natural size of its contents. /// @@ -85,7 +85,7 @@ public struct ButtonContent: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -114,7 +114,7 @@ public struct ButtonContent: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Carousel.swift b/Sources/Adwaita/View/Generated/Carousel.swift index 158806f..b0009bf 100644 --- a/Sources/Adwaita/View/Generated/Carousel.swift +++ b/Sources/Adwaita/View/Generated/Carousel.swift @@ -2,7 +2,7 @@ // Carousel.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -24,9 +24,9 @@ import LevenshteinTransformations public struct Carousel: Widget where Element: Identifiable { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether to allow swiping for more than one page at a time. /// @@ -82,7 +82,7 @@ public struct Carousel: Widget where Element: Identifiable { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -145,7 +145,7 @@ public struct Carousel: Widget where Element: Identifiable { } } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/CenterBox.swift b/Sources/Adwaita/View/Generated/CenterBox.swift index f69dd1a..cccc008 100644 --- a/Sources/Adwaita/View/Generated/CenterBox.swift +++ b/Sources/Adwaita/View/Generated/CenterBox.swift @@ -2,7 +2,7 @@ // CenterBox.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -45,9 +45,9 @@ import LevenshteinTransformations public struct CenterBox: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -105,7 +105,7 @@ public struct CenterBox: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -134,7 +134,7 @@ public struct CenterBox: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/CheckButton.swift b/Sources/Adwaita/View/Generated/CheckButton.swift index 904488f..ec5484b 100644 --- a/Sources/Adwaita/View/Generated/CheckButton.swift +++ b/Sources/Adwaita/View/Generated/CheckButton.swift @@ -2,7 +2,7 @@ // CheckButton.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -68,9 +68,9 @@ import LevenshteinTransformations public struct CheckButton: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -130,7 +130,7 @@ public struct CheckButton: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -181,7 +181,7 @@ if let active, newValue != active.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Clamp.swift b/Sources/Adwaita/View/Generated/Clamp.swift index 04aa76a..7d724c6 100644 --- a/Sources/Adwaita/View/Generated/Clamp.swift +++ b/Sources/Adwaita/View/Generated/Clamp.swift @@ -2,7 +2,7 @@ // Clamp.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -29,9 +29,9 @@ import LevenshteinTransformations public struct Clamp: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The child widget of the `AdwClamp`. var child: (() -> Body)? @@ -75,7 +75,7 @@ public struct Clamp: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -101,7 +101,7 @@ public struct Clamp: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ComboRow.swift b/Sources/Adwaita/View/Generated/ComboRow.swift index cbe678d..4b4aa8c 100644 --- a/Sources/Adwaita/View/Generated/ComboRow.swift +++ b/Sources/Adwaita/View/Generated/ComboRow.swift @@ -2,7 +2,7 @@ // ComboRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -44,9 +44,9 @@ import LevenshteinTransformations public struct ComboRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The widget to activate when the row is activated. /// @@ -156,7 +156,7 @@ public struct ComboRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -223,7 +223,7 @@ if let selected, newValue != selected.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/EntryRow.swift b/Sources/Adwaita/View/Generated/EntryRow.swift index 7dbb700..47e57eb 100644 --- a/Sources/Adwaita/View/Generated/EntryRow.swift +++ b/Sources/Adwaita/View/Generated/EntryRow.swift @@ -2,7 +2,7 @@ // EntryRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -42,9 +42,9 @@ import LevenshteinTransformations public struct EntryRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether activating the embedded entry can activate the default widget. var activatesDefault: Bool? @@ -118,7 +118,7 @@ public struct EntryRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -188,7 +188,7 @@ public struct EntryRow: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ExpanderRow.swift b/Sources/Adwaita/View/Generated/ExpanderRow.swift index 7f84509..baa78c1 100644 --- a/Sources/Adwaita/View/Generated/ExpanderRow.swift +++ b/Sources/Adwaita/View/Generated/ExpanderRow.swift @@ -2,7 +2,7 @@ // ExpanderRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -36,9 +36,9 @@ import LevenshteinTransformations public struct ExpanderRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether expansion is enabled. var enableExpansion: Binding? @@ -120,7 +120,7 @@ public struct ExpanderRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -215,7 +215,7 @@ if let expanded, newValue != expanded.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/FlowBox.swift b/Sources/Adwaita/View/Generated/FlowBox.swift index 9eb175c..643b226 100644 --- a/Sources/Adwaita/View/Generated/FlowBox.swift +++ b/Sources/Adwaita/View/Generated/FlowBox.swift @@ -2,7 +2,7 @@ // FlowBox.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -55,9 +55,9 @@ import LevenshteinTransformations public struct FlowBox: Widget where Element: Identifiable { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// accept-unpaired-release var acceptUnpairedRelease: Bool? @@ -157,7 +157,7 @@ public struct FlowBox: Widget where Element: Identifiable { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -250,7 +250,7 @@ public struct FlowBox: Widget where Element: Identifiable { } } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/HeaderBar.swift b/Sources/Adwaita/View/Generated/HeaderBar.swift index 57f2e08..ccde274 100644 --- a/Sources/Adwaita/View/Generated/HeaderBar.swift +++ b/Sources/Adwaita/View/Generated/HeaderBar.swift @@ -2,7 +2,7 @@ // HeaderBar.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -85,9 +85,9 @@ import LevenshteinTransformations public struct HeaderBar: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The decoration layout for buttons. /// @@ -175,7 +175,7 @@ public struct HeaderBar: Widget { } storage.content["end"] = endStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -232,7 +232,7 @@ public struct HeaderBar: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Label.swift b/Sources/Adwaita/View/Generated/Label.swift index 05a4af1..8c1bed2 100644 --- a/Sources/Adwaita/View/Generated/Label.swift +++ b/Sources/Adwaita/View/Generated/Label.swift @@ -2,7 +2,7 @@ // Label.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -40,7 +40,7 @@ import LevenshteinTransformations /// /// The GtkLabel implementation of the GtkBuildable interface supports a /// custom `` element, which supports any number of `` -/// elements. The element has attributes named “name“, “value“, +/// elements. The `` element has attributes named “name“, “value“, /// “start“ and “end“ and allows you to specify [struct@Pango.Attribute] /// values for this label. /// @@ -70,8 +70,9 @@ import LevenshteinTransformations /// Mnemonics automatically activate any activatable widget the label is /// inside, such as a [class@Gtk.Button]; if the label is not inside the /// mnemonic’s target widget, you have to tell the label about the target -/// using [class@Gtk.Label.set_mnemonic_widget]. Here’s a simple example where -/// the label is inside a button: +/// using [method@Gtk.Label.set_mnemonic_widget]. +/// +/// Here’s a simple example where the label is inside a button: /// /// ```c /// // Pressing Alt+H will activate this button @@ -185,9 +186,9 @@ import LevenshteinTransformations public struct Label: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -288,7 +289,7 @@ public struct Label: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -346,7 +347,7 @@ public struct Label: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/LevelBar.swift b/Sources/Adwaita/View/Generated/LevelBar.swift index 6c2348b..589a197 100644 --- a/Sources/Adwaita/View/Generated/LevelBar.swift +++ b/Sources/Adwaita/View/Generated/LevelBar.swift @@ -2,7 +2,7 @@ // LevelBar.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -108,9 +108,9 @@ import LevenshteinTransformations public struct LevelBar: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -153,7 +153,7 @@ public struct LevelBar: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -187,7 +187,7 @@ public struct LevelBar: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/LinkButton.swift b/Sources/Adwaita/View/Generated/LinkButton.swift index ae5bff4..9964699 100644 --- a/Sources/Adwaita/View/Generated/LinkButton.swift +++ b/Sources/Adwaita/View/Generated/LinkButton.swift @@ -2,7 +2,7 @@ // LinkButton.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -37,9 +37,9 @@ import LevenshteinTransformations public struct LinkButton: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -104,7 +104,7 @@ public struct LinkButton: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -158,7 +158,7 @@ public struct LinkButton: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ListBox.swift b/Sources/Adwaita/View/Generated/ListBox.swift index 25218f7..386dbbf 100644 --- a/Sources/Adwaita/View/Generated/ListBox.swift +++ b/Sources/Adwaita/View/Generated/ListBox.swift @@ -2,7 +2,7 @@ // ListBox.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -64,9 +64,9 @@ import LevenshteinTransformations public struct ListBox: Widget where Element: Identifiable { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether to accept unpaired release events. var acceptUnpairedRelease: Bool? @@ -134,7 +134,7 @@ public struct ListBox: Widget where Element: Identifiable { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -220,7 +220,7 @@ public struct ListBox: Widget where Element: Identifiable { } } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Menu.swift b/Sources/Adwaita/View/Generated/Menu.swift index 146ac05..3611554 100644 --- a/Sources/Adwaita/View/Generated/Menu.swift +++ b/Sources/Adwaita/View/Generated/Menu.swift @@ -2,7 +2,7 @@ // Menu.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -72,9 +72,9 @@ import LevenshteinTransformations public struct Menu: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -139,7 +139,7 @@ public struct Menu: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -194,7 +194,7 @@ if let active, newValue != active.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/NavigationView.swift b/Sources/Adwaita/View/Generated/NavigationView.swift new file mode 100644 index 0000000..93ed74a --- /dev/null +++ b/Sources/Adwaita/View/Generated/NavigationView.swift @@ -0,0 +1,298 @@ +// +// NavigationView.swift +// Adwaita +// +// Created by auto-generation on 17.02.24. +// + +import CAdw +import LevenshteinTransformations + +/// A page-based navigation container. +/// +/// navigation-view +/// +/// `AdwNavigationView` presents one child at a time, similar to +/// [class@Gtk.Stack]. +/// +/// `AdwNavigationView` can only contain [class@NavigationPage] children. +/// +/// It maintains a navigation stack that can be controlled with +/// [method@NavigationView.push] and [method@NavigationView.pop]. The whole +/// navigation stack can also be replaced using [method@NavigationView.replace]. +/// +/// `AdwNavigationView` allows to manage pages statically or dynamically. +/// +/// Static pages can be added using the [method@NavigationView.add] method. The +/// `AdwNavigationView` will keep a reference to these pages, but they aren't +/// accessible to the user until [method@NavigationView.push] is called (except +/// for the first page, which is pushed automatically). Use the +/// [method@NavigationView.remove] method to remove them. This is useful for +/// applications that have a small number of unique pages and just need +/// navigation between them. +/// +/// Dynamic pages are automatically destroyed once they are popped off the +/// navigation stack. To add a page like this, push it using the +/// [method@NavigationView.push] method without calling +/// [method@NavigationView.add] first. +/// +/// ## Tags +/// +/// Static pages, as well as any pages in the navigation stack, can be accessed +/// by their [property@NavigationPage:tag]. For example, +/// [method@NavigationView.push_by_tag] can be used to push a static page that's +/// not in the navigation stack without having to keep a reference to it manually. +/// +/// ## Header Bar Integration +/// +/// When used inside `AdwNavigationView`, [class@HeaderBar] will automatically +/// display a back button that can be used to go back to the previous page when +/// possible. The button also has a context menu, allowing to pop multiple pages +/// at once, potentially across multiple navigation views. +/// +/// Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior +/// if it's unwanted. +/// +/// `AdwHeaderBar` will also display the title of the `AdwNavigationPage` it's +/// placed into, so most applications shouldn't need to customize it at all. +/// +/// ## Shortcuts and Gestures +/// +/// `AdwNavigationView` supports the following shortcuts for going to the +/// previous page: +/// +/// - Escape (unless [property@NavigationView:pop-on-escape] is set to +/// `FALSE`) +/// - Alt+ +/// - Back mouse button +/// +/// Additionally, it supports interactive gestures: +/// +/// - One-finger swipe towards the right on touchscreens +/// - Scrolling towards the right on touchpads (usually two-finger swipe) +/// +/// These gestures have transitions enabled regardless of the +/// [property@NavigationView:animate-transitions] value. +/// +/// Applications can also enable shortcuts for pushing another page onto the +/// navigation stack via connecting to the [signal@NavigationView::get-next-page] +/// signal, in that case the following shortcuts are supported: +/// +/// - Alt+ +/// - Forward mouse button +/// - Swipe/scrolling towards the left +/// +/// For right-to-left locales, the gestures and shortcuts are reversed. +/// +/// [property@NavigationPage:can-pop] can be used to disable them, along with the +/// header bar back buttons. +/// +/// ## Actions +/// +/// `AdwNavigationView` defines actions for controlling the navigation stack. +/// actions for controlling the navigation stack: +/// +/// - `navigation.push` takes a string parameter specifying the tag of the page to +/// push, and is equivalent to calling [method@NavigationView.push_by_tag]. +/// +/// - `navigation.pop` doesn't take any parameters and pops the current page from +/// the navigation stack, equivalent to calling [method@NavigationView.pop]. +/// +/// ## `AdwNavigationView` as `GtkBuildable` +/// +/// `AdwNavigationView` allows to add pages as children, equivalent to using the +/// [method@NavigationView.add] method. +/// +/// Example of an `AdwNavigationView` UI definition: +/// +/// ```xml +/// Page 1Open Page 2centercenternavigation.push'page-2'Page 2page-2 +/// ``` +/// +/// navigation-view-example +/// +/// ## CSS nodes +/// +/// `AdwNavigationView` has a single CSS node with the name `navigation-view`. +/// +/// ## Accessibility +/// +/// `AdwNavigationView` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role. +public struct NavigationView: Widget { + + /// Additional update functions for type extensions. + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] + /// Additional appear functions for type extensions. + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] + + /// Whether to animate page transitions. + /// + /// Gesture-based transitions are always animated. + var animateTransitions: Bool? + /// Whether pressing Escape pops the current page. + /// + /// Applications using `AdwNavigationView` to implement a browser may want to + /// disable it. + var popOnEscape: Bool? + /// Emitted when a push shortcut or a gesture is triggered. + /// + /// To support the push shortcuts and gestures, the application is expected to + /// return the page to push in the handler. + /// + /// This signal can be emitted multiple times for the gestures, for example + /// when the gesture is cancelled by the user. As such, the application must + /// not make any irreversible changes in the handler, such as removing the page + /// from a forward stack. + /// + /// Instead, it should be done in the [signal@NavigationView::pushed] handler. + var getNextPage: (() -> Void)? + /// Emitted after @page has been popped from the navigation stack. + /// + /// See [method@NavigationView.pop]. + /// + /// When using [method@NavigationView.pop_to_page] or + /// [method@NavigationView.pop_to_tag], this signal is emitted for each of the + /// popped pages. + var popped: (() -> Void)? + /// Emitted after a page has been pushed to the navigation stack. + /// + /// See [method@NavigationView.push]. + var pushed: (() -> Void)? + /// Emitted after the navigation stack has been replaced. + /// + /// See [method@NavigationView.replace]. + var replaced: (() -> Void)? + /// The application. + var app: GTUIApp? + /// The window. + var window: GTUIApplicationWindow? + + /// Initialize `NavigationView`. + public init() { + } + + /// Get the widget's view storage. + /// - Parameter modifiers: The view modifiers. + /// - Returns: The view storage. + public func container(modifiers: [(View) -> View]) -> ViewStorage { + let storage = ViewStorage(adw_navigation_view_new()?.opaque()) + update(storage, modifiers: modifiers, updateProperties: true) + + for function in appearFunctions { + function(storage, modifiers) + } + return storage + } + + /// Update the widget's view storage. + /// - Parameters: + /// - storage: The view storage. + /// - modifiers: The view modifiers. + /// - updateProperties: Whether to update the view's properties. + public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { + if let getNextPage { + storage.connectSignal(name: "get-next-page", argCount: 0) { + getNextPage() + } + } + if let popped { + storage.connectSignal(name: "popped", argCount: 1) { + popped() + } + } + if let pushed { + storage.connectSignal(name: "pushed", argCount: 0) { + pushed() + } + } + if let replaced { + storage.connectSignal(name: "replaced", argCount: 0) { + replaced() + } + } + storage.modify { widget in + + if let animateTransitions, updateProperties { + adw_navigation_view_set_animate_transitions(widget, animateTransitions.cBool) + } + if let popOnEscape, updateProperties { + adw_navigation_view_set_pop_on_escape(widget, popOnEscape.cBool) + } + + + } + for function in updateFunctions { + function(storage, modifiers, updateProperties) + } + } + + /// Whether to animate page transitions. + /// + /// Gesture-based transitions are always animated. + public func animateTransitions(_ animateTransitions: Bool? = true) -> Self { + var newSelf = self + newSelf.animateTransitions = animateTransitions + + return newSelf + } + + /// Whether pressing Escape pops the current page. + /// + /// Applications using `AdwNavigationView` to implement a browser may want to + /// disable it. + public func popOnEscape(_ popOnEscape: Bool? = true) -> Self { + var newSelf = self + newSelf.popOnEscape = popOnEscape + + return newSelf + } + + /// Emitted when a push shortcut or a gesture is triggered. + /// + /// To support the push shortcuts and gestures, the application is expected to + /// return the page to push in the handler. + /// + /// This signal can be emitted multiple times for the gestures, for example + /// when the gesture is cancelled by the user. As such, the application must + /// not make any irreversible changes in the handler, such as removing the page + /// from a forward stack. + /// + /// Instead, it should be done in the [signal@NavigationView::pushed] handler. + public func getNextPage(_ getNextPage: @escaping () -> Void) -> Self { + var newSelf = self + newSelf.getNextPage = getNextPage + return newSelf + } + + /// Emitted after @page has been popped from the navigation stack. + /// + /// See [method@NavigationView.pop]. + /// + /// When using [method@NavigationView.pop_to_page] or + /// [method@NavigationView.pop_to_tag], this signal is emitted for each of the + /// popped pages. + public func popped(_ popped: @escaping () -> Void) -> Self { + var newSelf = self + newSelf.popped = popped + return newSelf + } + + /// Emitted after a page has been pushed to the navigation stack. + /// + /// See [method@NavigationView.push]. + public func pushed(_ pushed: @escaping () -> Void) -> Self { + var newSelf = self + newSelf.pushed = pushed + return newSelf + } + + /// Emitted after the navigation stack has been replaced. + /// + /// See [method@NavigationView.replace]. + public func replaced(_ replaced: @escaping () -> Void) -> Self { + var newSelf = self + newSelf.replaced = replaced + return newSelf + } + +} diff --git a/Sources/Adwaita/View/Generated/Overlay.swift b/Sources/Adwaita/View/Generated/Overlay.swift index 9a6e72a..64054a6 100644 --- a/Sources/Adwaita/View/Generated/Overlay.swift +++ b/Sources/Adwaita/View/Generated/Overlay.swift @@ -2,7 +2,7 @@ // Overlay.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -43,9 +43,9 @@ import LevenshteinTransformations public struct Overlay: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -97,7 +97,7 @@ public struct Overlay: Widget { } storage.content["overlay"] = overlayStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -133,7 +133,7 @@ public struct Overlay: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/OverlaySplitView.swift b/Sources/Adwaita/View/Generated/OverlaySplitView.swift index 764e7c5..fdc4caf 100644 --- a/Sources/Adwaita/View/Generated/OverlaySplitView.swift +++ b/Sources/Adwaita/View/Generated/OverlaySplitView.swift @@ -2,7 +2,7 @@ // OverlaySplitView.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -116,9 +116,9 @@ import LevenshteinTransformations public struct OverlaySplitView: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether the split view is collapsed. /// @@ -195,7 +195,7 @@ public struct OverlaySplitView: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -248,7 +248,7 @@ if let showSidebar, newValue != showSidebar.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/PasswordEntryRow.swift b/Sources/Adwaita/View/Generated/PasswordEntryRow.swift index 6dfc608..9538f8d 100644 --- a/Sources/Adwaita/View/Generated/PasswordEntryRow.swift +++ b/Sources/Adwaita/View/Generated/PasswordEntryRow.swift @@ -2,7 +2,7 @@ // PasswordEntryRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -27,9 +27,9 @@ import LevenshteinTransformations public struct PasswordEntryRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether activating the embedded entry can activate the default widget. var activatesDefault: Bool? @@ -103,7 +103,7 @@ public struct PasswordEntryRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -151,7 +151,7 @@ public struct PasswordEntryRow: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Popover.swift b/Sources/Adwaita/View/Generated/Popover.swift index 432e418..c1edea7 100644 --- a/Sources/Adwaita/View/Generated/Popover.swift +++ b/Sources/Adwaita/View/Generated/Popover.swift @@ -2,7 +2,7 @@ // Popover.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -71,9 +71,9 @@ import LevenshteinTransformations public struct Popover: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -124,7 +124,7 @@ public struct Popover: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -169,7 +169,7 @@ public struct Popover: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/PreferencesGroup.swift b/Sources/Adwaita/View/Generated/PreferencesGroup.swift index c9819fd..5aca657 100644 --- a/Sources/Adwaita/View/Generated/PreferencesGroup.swift +++ b/Sources/Adwaita/View/Generated/PreferencesGroup.swift @@ -2,7 +2,7 @@ // PreferencesGroup.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -39,9 +39,9 @@ import LevenshteinTransformations public struct PreferencesGroup: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The description for this group of preferences. var description: String? @@ -83,7 +83,7 @@ public struct PreferencesGroup: Widget { } storage.content["child"] = childStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -120,7 +120,7 @@ public struct PreferencesGroup: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/PreferencesPage.swift b/Sources/Adwaita/View/Generated/PreferencesPage.swift index 6ae24f3..f589a9a 100644 --- a/Sources/Adwaita/View/Generated/PreferencesPage.swift +++ b/Sources/Adwaita/View/Generated/PreferencesPage.swift @@ -2,7 +2,7 @@ // PreferencesPage.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -25,9 +25,9 @@ import LevenshteinTransformations public struct PreferencesPage: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The description to be displayed at the top of the page. var description: String? @@ -64,7 +64,7 @@ public struct PreferencesPage: Widget { } storage.content["child"] = childStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -107,7 +107,7 @@ public struct PreferencesPage: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/PreferencesRow.swift b/Sources/Adwaita/View/Generated/PreferencesRow.swift index 7094505..4222799 100644 --- a/Sources/Adwaita/View/Generated/PreferencesRow.swift +++ b/Sources/Adwaita/View/Generated/PreferencesRow.swift @@ -2,7 +2,7 @@ // PreferencesRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -20,9 +20,9 @@ import LevenshteinTransformations public struct PreferencesRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The title of the preference represented by this row. /// @@ -58,7 +58,7 @@ public struct PreferencesRow: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -87,7 +87,7 @@ public struct PreferencesRow: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ProgressBar.swift b/Sources/Adwaita/View/Generated/ProgressBar.swift index c245d08..60adb14 100644 --- a/Sources/Adwaita/View/Generated/ProgressBar.swift +++ b/Sources/Adwaita/View/Generated/ProgressBar.swift @@ -2,7 +2,7 @@ // ProgressBar.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -57,9 +57,9 @@ import LevenshteinTransformations public struct ProgressBar: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -101,7 +101,7 @@ public struct ProgressBar: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -133,7 +133,7 @@ public struct ProgressBar: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ScrolledWindow.swift b/Sources/Adwaita/View/Generated/ScrolledWindow.swift index 964ee2f..20dbdda 100644 --- a/Sources/Adwaita/View/Generated/ScrolledWindow.swift +++ b/Sources/Adwaita/View/Generated/ScrolledWindow.swift @@ -2,7 +2,7 @@ // ScrolledWindow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -79,15 +79,19 @@ import LevenshteinTransformations public struct ScrolledWindow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// /// The accessible role cannot be changed once set. var accessibleRole: String? /// The child widget. + /// + /// When setting this property, if the child widget does not implement + /// [iface@Gtk.Scrollable], the scrolled window will add the child to + /// a [class@Gtk.Viewport] and then set the viewport as the child. var child: (() -> Body)? /// Whether to draw a frame around the contents. var hasFrame: Bool? @@ -181,7 +185,7 @@ public struct ScrolledWindow: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -248,7 +252,7 @@ public struct ScrolledWindow: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } @@ -263,6 +267,10 @@ public struct ScrolledWindow: Widget { } /// The child widget. + /// + /// When setting this property, if the child widget does not implement + /// [iface@Gtk.Scrollable], the scrolled window will add the child to + /// a [class@Gtk.Viewport] and then set the viewport as the child. public func child(@ViewBuilder _ child: @escaping (() -> Body)) -> Self { var newSelf = self newSelf.child = child diff --git a/Sources/Adwaita/View/Generated/SearchBar.swift b/Sources/Adwaita/View/Generated/SearchBar.swift index 00f219e..09f97be 100644 --- a/Sources/Adwaita/View/Generated/SearchBar.swift +++ b/Sources/Adwaita/View/Generated/SearchBar.swift @@ -2,7 +2,7 @@ // SearchBar.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -55,9 +55,9 @@ import LevenshteinTransformations public struct SearchBar: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -96,7 +96,7 @@ public struct SearchBar: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -122,7 +122,7 @@ public struct SearchBar: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/SearchEntry.swift b/Sources/Adwaita/View/Generated/SearchEntry.swift index e9b095b..21a725c 100644 --- a/Sources/Adwaita/View/Generated/SearchEntry.swift +++ b/Sources/Adwaita/View/Generated/SearchEntry.swift @@ -2,7 +2,7 @@ // SearchEntry.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -55,9 +55,9 @@ import LevenshteinTransformations public struct SearchEntry: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -171,7 +171,7 @@ public struct SearchEntry: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -260,7 +260,7 @@ if let text, newValue != text.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/SpinRow.swift b/Sources/Adwaita/View/Generated/SpinRow.swift index d777e27..46f6891 100644 --- a/Sources/Adwaita/View/Generated/SpinRow.swift +++ b/Sources/Adwaita/View/Generated/SpinRow.swift @@ -2,7 +2,7 @@ // SpinRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -27,9 +27,9 @@ import LevenshteinTransformations public struct SpinRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The widget to activate when the row is activated. /// @@ -148,7 +148,7 @@ public struct SpinRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -239,7 +239,7 @@ if let value, newValue != value.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/Spinner.swift b/Sources/Adwaita/View/Generated/Spinner.swift index 86b65bf..bba9455 100644 --- a/Sources/Adwaita/View/Generated/Spinner.swift +++ b/Sources/Adwaita/View/Generated/Spinner.swift @@ -2,7 +2,7 @@ // Spinner.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -26,9 +26,9 @@ import LevenshteinTransformations public struct Spinner: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -53,7 +53,7 @@ public struct Spinner: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -73,7 +73,7 @@ public struct Spinner: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/SplitButton.swift b/Sources/Adwaita/View/Generated/SplitButton.swift index 34eef0b..09f5410 100644 --- a/Sources/Adwaita/View/Generated/SplitButton.swift +++ b/Sources/Adwaita/View/Generated/SplitButton.swift @@ -2,7 +2,7 @@ // SplitButton.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -43,9 +43,9 @@ import LevenshteinTransformations public struct SplitButton: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// Whether the button can be smaller than the natural size of its contents. /// @@ -123,7 +123,7 @@ public struct SplitButton: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -168,7 +168,7 @@ public struct SplitButton: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/StatusPage.swift b/Sources/Adwaita/View/Generated/StatusPage.swift index 0a46314..519d22f 100644 --- a/Sources/Adwaita/View/Generated/StatusPage.swift +++ b/Sources/Adwaita/View/Generated/StatusPage.swift @@ -2,7 +2,7 @@ // StatusPage.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -25,9 +25,9 @@ import LevenshteinTransformations public struct StatusPage: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The child widget. var child: (() -> Body)? @@ -62,7 +62,7 @@ public struct StatusPage: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -91,7 +91,7 @@ public struct StatusPage: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/SwitchRow.swift b/Sources/Adwaita/View/Generated/SwitchRow.swift index 8401f04..8a53d0e 100644 --- a/Sources/Adwaita/View/Generated/SwitchRow.swift +++ b/Sources/Adwaita/View/Generated/SwitchRow.swift @@ -2,7 +2,7 @@ // SwitchRow.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -31,9 +31,9 @@ import LevenshteinTransformations public struct SwitchRow: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The widget to activate when the row is activated. /// @@ -123,7 +123,7 @@ public struct SwitchRow: Widget { } storage.content["prefix"] = prefixStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -184,7 +184,7 @@ if let active, newValue != active.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ToastOverlay.swift b/Sources/Adwaita/View/Generated/ToastOverlay.swift index 3169741..b5036f5 100644 --- a/Sources/Adwaita/View/Generated/ToastOverlay.swift +++ b/Sources/Adwaita/View/Generated/ToastOverlay.swift @@ -2,7 +2,7 @@ // ToastOverlay.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -47,9 +47,9 @@ import LevenshteinTransformations public struct ToastOverlay: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The child widget. var child: (() -> Body)? @@ -74,7 +74,7 @@ public struct ToastOverlay: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -94,7 +94,7 @@ public struct ToastOverlay: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ToggleButton.swift b/Sources/Adwaita/View/Generated/ToggleButton.swift index 8a04759..f46e147 100644 --- a/Sources/Adwaita/View/Generated/ToggleButton.swift +++ b/Sources/Adwaita/View/Generated/ToggleButton.swift @@ -2,7 +2,7 @@ // ToggleButton.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -86,9 +86,9 @@ import LevenshteinTransformations public struct ToggleButton: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The accessible role of the given `GtkAccessible` implementation. /// @@ -150,7 +150,7 @@ public struct ToggleButton: Widget { } for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -212,7 +212,7 @@ if let active, newValue != active.wrappedValue { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/ToolbarView.swift b/Sources/Adwaita/View/Generated/ToolbarView.swift index 940ed56..5e86e32 100644 --- a/Sources/Adwaita/View/Generated/ToolbarView.swift +++ b/Sources/Adwaita/View/Generated/ToolbarView.swift @@ -2,7 +2,7 @@ // ToolbarView.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -79,9 +79,9 @@ import LevenshteinTransformations public struct ToolbarView: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The current bottom bar height. /// @@ -171,7 +171,7 @@ public struct ToolbarView: Widget { } storage.content["top"] = topStorage for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -225,7 +225,7 @@ public struct ToolbarView: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/Generated/WindowTitle.swift b/Sources/Adwaita/View/Generated/WindowTitle.swift index 478defe..10a0558 100644 --- a/Sources/Adwaita/View/Generated/WindowTitle.swift +++ b/Sources/Adwaita/View/Generated/WindowTitle.swift @@ -2,7 +2,7 @@ // WindowTitle.swift // Adwaita // -// Created by auto-generation on 14.02.24. +// Created by auto-generation on 17.02.24. // import CAdw @@ -21,9 +21,9 @@ import LevenshteinTransformations public struct WindowTitle: Widget { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] /// The subtitle to display. /// @@ -53,7 +53,7 @@ public struct WindowTitle: Widget { update(storage, modifiers: modifiers, updateProperties: true) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -76,7 +76,7 @@ public struct WindowTitle: Widget { } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } diff --git a/Sources/Adwaita/View/List.swift b/Sources/Adwaita/View/List.swift index 5afec94..b78b4f8 100644 --- a/Sources/Adwaita/View/List.swift +++ b/Sources/Adwaita/View/List.swift @@ -35,7 +35,7 @@ extension List { return nil } if let selection { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields[Self.selectionField] = selection storage.connectSignal(name: "selected_rows_changed", id: Self.selectionField) { if let binding = storage.fields[Self.selectionField] as? Binding, @@ -45,14 +45,14 @@ extension List { } } } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if selection.wrappedValue != id(storage, elements), let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt { gtk_list_box_select_row(storage.pointer, gtk_list_box_get_row_at_index(storage.pointer, index)) } } } else { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in gtk_list_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE) } } diff --git a/Sources/Adwaita/View/Modifiers/Clamp+.swift b/Sources/Adwaita/View/Modifiers/Clamp+.swift index c66ec4f..e2523fb 100644 --- a/Sources/Adwaita/View/Modifiers/Clamp+.swift +++ b/Sources/Adwaita/View/Modifiers/Clamp+.swift @@ -14,7 +14,7 @@ extension Clamp { init(vertical: Bool) { self.init() if vertical { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_VERTICAL) } } diff --git a/Sources/Adwaita/View/Modifiers/Popover+.swift b/Sources/Adwaita/View/Modifiers/Popover+.swift index aca1194..9a42214 100644 --- a/Sources/Adwaita/View/Modifiers/Popover+.swift +++ b/Sources/Adwaita/View/Modifiers/Popover+.swift @@ -13,7 +13,7 @@ extension Popover { /// - Parameter vertical: Whether it is a vertical clamp. init(visible: Binding) { self.init() - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields["visible"] = visible storage.connectSignal(name: "closed", id: "visible") { if let binding = storage.fields["visible"] as? Binding { @@ -23,7 +23,7 @@ extension Popover { } } } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if let binding = storage.fields["visible"] as? Binding { if binding.wrappedValue { gtk_popover_popup(storage.pointer?.cast()) diff --git a/Sources/Adwaita/View/Modifiers/ToastOverlay+.swift b/Sources/Adwaita/View/Modifiers/ToastOverlay+.swift index ced3207..c0aad08 100644 --- a/Sources/Adwaita/View/Modifiers/ToastOverlay+.swift +++ b/Sources/Adwaita/View/Modifiers/ToastOverlay+.swift @@ -16,10 +16,10 @@ extension ToastOverlay { /// - title: The toast's title. /// - signal: The signal for adding a toast. public init(_ title: String, signal: Signal) { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in storage.fields["signal"] = signal } - updateFunctions.append { storage in + updateFunctions.append { storage, _, _ in if let signal = storage.fields["signal"] as? Signal, signal.update { let toast = ViewStorage(adw_toast_new(title)) storage.fields[UUID().uuidString] = toast @@ -40,7 +40,7 @@ extension ToastOverlay { /// - Returns: The toast overlay. public func action(button: String, handler: @escaping () -> Void) -> Self { var newSelf = self - let action: (ViewStorage) -> Void = { storage in + let action: (ViewStorage, [(View) -> View], Bool) -> Void = { storage, _, _ in storage.fields["button"] = button storage.fields["handler"] = handler } diff --git a/Sources/Adwaita/View/NavigationView+.swift b/Sources/Adwaita/View/NavigationView+.swift new file mode 100644 index 0000000..0bb9aef --- /dev/null +++ b/Sources/Adwaita/View/NavigationView+.swift @@ -0,0 +1,114 @@ +// +// NavigationView+.swift +// Adwaita +// +// Created by david-swift on 17.02.24. +// + +import CAdw + +extension NavigationView { + + /// The ID for the component field in a content storage. + static var componentID: String { "component" } + + /// Initialize a navigation view. + /// - Parameters: + /// - stack: The navigation stack for pushing and popping. + /// - initialTitle: The title of the initial view. + /// - content: The view for a path component. + /// - initialView: The view that is displayed when the path is empty. + public init( + _ stack: Binding>, + _ initialTitle: String, + @ViewBuilder content: @escaping (Component) -> Body, + @ViewBuilder initialView: @escaping () -> Body + ) { + self.init() + appearFunctions.append { storage, modifiers in + let initialStorage = initialView().storage(modifiers: modifiers) + storage.fields[.mainContent] = [initialStorage] + adw_navigation_view_push( + storage.pointer, + adw_navigation_page_new(initialStorage.pointer?.cast(), initialTitle) + ) + storage.connectSignal(name: "popped", id: "components", argCount: 1) { args in + guard var storages = storage.fields[.mainContent] as? [ViewStorage], + let arg = args.first as? UnsafeRawPointer else { + return + } + if storages.last?.pointer == adw_navigation_page_get_child(OpaquePointer(arg).cast())?.opaque() { + storages.removeLast() + storage.fields[.mainContent] = storages + } + } + } + updateFunctions.append { storage, modifiers, updateProperties in + guard var storages = storage.fields[.mainContent] as? [ViewStorage] else { + return + } + switch stack.wrappedValue.action { + case .pop: + if storages.count > 1 { + adw_navigation_view_pop(storage.pointer) + storages.removeLast() + } else { print("Warning: removing the initial view is not allowed.") } + case let .push(component): + let contentStorage = content(component).storage(modifiers: modifiers) + contentStorage.fields[Self.componentID] = component + storages.append(contentStorage) + adw_navigation_view_push( + storage.pointer, + adw_navigation_page_new(contentStorage.pointer?.cast(), component.description) + ) + default: + break + } + UpdateManager.blockUpdates = true; stack.wrappedValue.action = nil; UpdateManager.blockUpdates = false + storage.fields[.mainContent] = storages + for storage in storages { + if let component = storage.fields[Self.componentID] as? Component { + content(component).updateStorage(storage, modifiers: modifiers, updateProperties: updateProperties) + } else { + initialView().updateStorage(storage, modifiers: modifiers, updateProperties: updateProperties) + } + } + } + } + + /// A stack controls a navigation view. + public struct NavigationStack where Component: CustomStringConvertible { + + /// The action to run at the next view update, if any. + var action: Action? + + /// Initialize a navigation stack. + public init() { } + + /// Remove the last item from the navigation view. + public mutating func pop() { + action = .pop + } + + /// Add a new item to the navigation view. + /// - Parameter component: The component's value. + public mutating func push(_ component: Component) { + action = .push(component: component) + } + + } + + /// An action to run on a view update. + enum Action { + + /// Remove the last item. + case pop + /// Add a new item. + case push(component: Component) + + } + +} + +/// A stack controls a navigation view. +public typealias NavigationStack = NavigationView.NavigationStack diff --git a/Sources/Adwaita/View/OverlaySplitView+.swift b/Sources/Adwaita/View/OverlaySplitView+.swift index e0d1ac3..4fbbd47 100644 --- a/Sources/Adwaita/View/OverlaySplitView+.swift +++ b/Sources/Adwaita/View/OverlaySplitView+.swift @@ -30,7 +30,7 @@ extension OverlaySplitView { /// - Returns: The navigation split view. public func trailingSidebar(_ trailing: Bool = true) -> Self { var newSelf = self - newSelf.updateFunctions.append { storage in + newSelf.updateFunctions.append { storage, _, _ in adw_overlay_split_view_set_sidebar_position(storage.pointer, trailing ? GTK_PACK_END : GTK_PACK_START) } return newSelf diff --git a/Sources/Adwaita/View/VStack.swift b/Sources/Adwaita/View/VStack.swift index 4018267..3b64b17 100644 --- a/Sources/Adwaita/View/VStack.swift +++ b/Sources/Adwaita/View/VStack.swift @@ -22,7 +22,7 @@ extension VStack { self.init(spacing: 0) self = self.append(content) if horizontal { - appearFunctions.append { storage in + appearFunctions.append { storage, _ in gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_HORIZONTAL) } } diff --git a/Sources/Generation/GIR/Class.swift b/Sources/Generation/GIR/Class.swift index 07d7a97..e6e5fc3 100644 --- a/Sources/Generation/GIR/Class.swift +++ b/Sources/Generation/GIR/Class.swift @@ -84,9 +84,9 @@ struct Class: ClassLike, Decodable { public struct \(definition) { /// Additional update functions for type extensions. - var updateFunctions: [(ViewStorage) -> Void] = [] + var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = [] /// Additional appear functions for type extensions. - var appearFunctions: [(ViewStorage) -> Void] = [] + var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = [] \(generateProperties(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) /// Initialize `\(widgetName)`. @@ -100,7 +100,7 @@ struct Class: ClassLike, Decodable { update(storage, modifiers: modifiers, updateProperties: true) \(generateWidgetAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) for function in appearFunctions { - function(storage) + function(storage, modifiers) } return storage } @@ -117,7 +117,7 @@ struct Class: ClassLike, Decodable { \(generateDynamicWidgetUpdate(config: config, genConfig: genConfig)) } for function in updateFunctions { - function(storage) + function(storage, modifiers, updateProperties) } } \(generateModifiers(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) diff --git a/Sources/Generation/GenerationConfiguration.swift b/Sources/Generation/GenerationConfiguration.swift index cdffea4..eed078a 100644 --- a/Sources/Generation/GenerationConfiguration.swift +++ b/Sources/Generation/GenerationConfiguration.swift @@ -140,6 +140,10 @@ struct GenerationConfiguration { class: "SplitButton", excludeProperties: ["direction", "popover"], setConditions: ["label": "storage.content[\"child\"] == nil"] + ), + .init( + class: "NavigationView", + excludeProperties: ["navigation-stack", "visible-page"] ) ] diff --git a/Tests/Demo.swift b/Tests/Demo.swift index 735a0a6..03ad844 100644 --- a/Tests/Demo.swift +++ b/Tests/Demo.swift @@ -62,6 +62,11 @@ struct Demo: App { .closeShortcut() .defaultSize(width: 400, height: 250) .title("Form Demo") + Window(id: "navigation", open: 0) { _ in + NavigationViewDemo.WindowContent() + } + .closeShortcut() + .title("Navigation View Demo") } } diff --git a/Tests/NavigationViewDemo.swift b/Tests/NavigationViewDemo.swift new file mode 100644 index 0000000..9b0a32e --- /dev/null +++ b/Tests/NavigationViewDemo.swift @@ -0,0 +1,64 @@ +// +// NavigationViewDemo.swift +// Adwaita +// +// Created by david-swift on 17.02.24. +// + +// swiftlint:disable missing_docs + +import Adwaita + +struct NavigationViewDemo: View { + + var app: GTUIApp + + var view: Body { + VStack { + Button("View Demo") { + app.showWindow("navigation") + } + .style("suggested-action") + .frame(maxSize: 100) + .padding() + } + } + + struct WindowContent: View { + + @State private var stack = NavigationStack() + let spacing = 10 + + var view: Body { + NavigationView($stack, "Initial View") { component in + VStack { + Button("Add Next View") { + stack.push(component + 1) + } + Button("Pop View") { + stack.pop() + } + } + .spacing(spacing) + .padding() + .topToolbar { + HeaderBar.empty() + } + } initialView: { + VStack { + Button("Add First View") { + stack.push(1) + } + .padding() + } + .topToolbar { + HeaderBar.empty() + } + } + } + + } + +} + +// swiftlint:enable missing_docs diff --git a/Tests/Page.swift b/Tests/Page.swift index edc9bc6..a99b4f5 100644 --- a/Tests/Page.swift +++ b/Tests/Page.swift @@ -25,6 +25,7 @@ enum Page: String, Identifiable, CaseIterable, Codable { case form case popover case flowBox + case navigationView var id: Self { self @@ -38,6 +39,8 @@ enum Page: String, Identifiable, CaseIterable, Codable { return "View Switcher" case .flowBox: return "Flow Box" + case .navigationView: + return "Navigation View" default: return rawValue.capitalized } @@ -82,6 +85,8 @@ enum Page: String, Identifiable, CaseIterable, Codable { return "Present content in a bubble-like context popup." case .flowBox: return "Display views in a reflowing grid." + case .navigationView: + return "A page-based navigation container." } } @@ -117,6 +122,8 @@ enum Page: String, Identifiable, CaseIterable, Codable { PopoverDemo() case .flowBox: FlowBoxDemo() + case .navigationView: + NavigationViewDemo(app: app) } } // swiftlint:enable cyclomatic_complexity