forked from aparoksha/adwaita-swift
Add modifiers for modifying child views of a view
This commit is contained in:
parent
88eaad2c12
commit
a478acbdcd
@ -16,6 +16,7 @@
|
|||||||
- [Binding](structs/Binding.md)
|
- [Binding](structs/Binding.md)
|
||||||
- [Button](structs/Button.md)
|
- [Button](structs/Button.md)
|
||||||
- [Clamp](structs/Clamp.md)
|
- [Clamp](structs/Clamp.md)
|
||||||
|
- [ContentModifier](structs/ContentModifier.md)
|
||||||
- [EitherView](structs/EitherView.md)
|
- [EitherView](structs/EitherView.md)
|
||||||
- [HStack](structs/HStack.md)
|
- [HStack](structs/HStack.md)
|
||||||
- [HeaderBar](structs/HeaderBar.md)
|
- [HeaderBar](structs/HeaderBar.md)
|
||||||
@ -24,6 +25,7 @@
|
|||||||
- [Menu](structs/Menu.md)
|
- [Menu](structs/Menu.md)
|
||||||
- [MenuButton](structs/MenuButton.md)
|
- [MenuButton](structs/MenuButton.md)
|
||||||
- [MenuSection](structs/MenuSection.md)
|
- [MenuSection](structs/MenuSection.md)
|
||||||
|
- [ModifierStopper](structs/ModifierStopper.md)
|
||||||
- [NavigationSplitView](structs/NavigationSplitView.md)
|
- [NavigationSplitView](structs/NavigationSplitView.md)
|
||||||
- [ScrollView](structs/ScrollView.md)
|
- [ScrollView](structs/ScrollView.md)
|
||||||
- [State](structs/State.md)
|
- [State](structs/State.md)
|
||||||
|
|||||||
@ -40,3 +40,7 @@ Focus the window with a certain id. Create the window if it doesn't already exis
|
|||||||
Add a new window with the content of the window with a certain id.
|
Add a new window with the content of the window with a certain id.
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- id: The window's id.
|
- id: The window's id.
|
||||||
|
|
||||||
|
### `setParentWindows()`
|
||||||
|
|
||||||
|
Set the parents of every window having a parent window.
|
||||||
|
|||||||
@ -9,6 +9,10 @@ A storage for an app's window.
|
|||||||
|
|
||||||
The window's identifier.
|
The window's identifier.
|
||||||
|
|
||||||
|
### `parentID`
|
||||||
|
|
||||||
|
The identifier of the window's parent window.
|
||||||
|
|
||||||
### `destroy`
|
### `destroy`
|
||||||
|
|
||||||
Whether the reference to the window should disappear in the next update.
|
Whether the reference to the window should disappear in the next update.
|
||||||
|
|||||||
@ -8,16 +8,18 @@
|
|||||||
The array's view body is the array itself.
|
The array's view body is the array itself.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `widget()`
|
### `widget(modifiers:)`
|
||||||
|
|
||||||
Get a widget from a collection of views.
|
Get a widget from a collection of views.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: A widget.
|
- Returns: A widget.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a collection of views with a collection of view storages.
|
Update a collection of views with a collection of view storages.
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- storage: The collection of view storages.
|
- storage: The collection of view storages.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `windows()`
|
### `windows()`
|
||||||
|
|
||||||
|
|||||||
@ -3,14 +3,17 @@
|
|||||||
# `NativeWidgetPeer`
|
# `NativeWidgetPeer`
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
A `GTUI.NativeWidgetPeer` is static.
|
A `GTUI.NativeWidgetPeer` is static.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
A `GTUI.NativeWidgetPeer`'s container is itself.
|
A `GTUI.NativeWidgetPeer`'s container is itself.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
### `modifier(code:)`
|
### `modifier(code:)`
|
||||||
|
|||||||
@ -3,27 +3,41 @@
|
|||||||
# `View`
|
# `View`
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `widget()`
|
### `widget(modifiers:)`
|
||||||
|
|
||||||
Wrap the view into a widget.
|
Wrap the view into a widget.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The widget.
|
- Returns: The widget.
|
||||||
|
|
||||||
### `updateStorage(_:)`
|
### `updateStorage(_:modifiers:)`
|
||||||
|
|
||||||
Update a storage to a view.
|
Update a storage to a view.
|
||||||
- Parameter storage: The storage.
|
- Parameters:
|
||||||
|
- storage: The storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `storage()`
|
### `storage(modifiers:)`
|
||||||
|
|
||||||
Get a storage.
|
Get a storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The storage.
|
- Returns: The storage.
|
||||||
|
|
||||||
|
### `getModified(modifiers:)`
|
||||||
|
|
||||||
### `frame(maxSize:)`
|
### `frame(maxSize:)`
|
||||||
|
|
||||||
Set the view's maximal size.
|
Set the view's maximal size.
|
||||||
- Parameter maxSize: The maximal size.
|
- Parameter maxSize: The maximal size.
|
||||||
- Returns: A view.
|
- Returns: A view.
|
||||||
|
|
||||||
|
### `modifyContent(_:modify:)`
|
||||||
|
|
||||||
|
Replace every occurrence of a certain view type in the content.
|
||||||
|
- Parameters:
|
||||||
|
- type: The view type.
|
||||||
|
- modify: Modify the view.
|
||||||
|
- Returns: A view.
|
||||||
|
|
||||||
### `inspect(_:)`
|
### `inspect(_:)`
|
||||||
|
|
||||||
Modify a GTUI widget before being displayed and when being updated.
|
Modify a GTUI widget before being displayed and when being updated.
|
||||||
@ -94,6 +108,11 @@ Run a function when the view appears for the first time.
|
|||||||
- Parameter closure: The function.
|
- Parameter closure: The function.
|
||||||
- Returns: A view.
|
- Returns: A view.
|
||||||
|
|
||||||
|
### `stopModifiers()`
|
||||||
|
|
||||||
|
Remove all of the content modifiers for the wrapped views.
|
||||||
|
- Returns: A view.
|
||||||
|
|
||||||
### `topToolbar(visible:_:)`
|
### `topToolbar(visible:_:)`
|
||||||
|
|
||||||
Add a top toolbar to the view.
|
Add a top toolbar to the view.
|
||||||
|
|||||||
@ -5,11 +5,14 @@
|
|||||||
A widget is a view that know about its GTUI widget.
|
A widget is a view that know about its GTUI widget.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
The view storage.
|
The view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the stored content.
|
Update the stored content.
|
||||||
- Parameter storage: The storage to update.
|
- Parameters:
|
||||||
|
- storage: The storage to update.
|
||||||
|
- modifiers: Modify views before being updated
|
||||||
|
|||||||
@ -9,6 +9,10 @@ A structure representing the content for a certain window type.
|
|||||||
|
|
||||||
The window type's identifier.
|
The window type's identifier.
|
||||||
|
|
||||||
|
### `parentID`
|
||||||
|
|
||||||
|
The identifier of the window's parent window.
|
||||||
|
|
||||||
### `open`
|
### `open`
|
||||||
|
|
||||||
The number of instances of the window at the startup.
|
The number of instances of the window at the startup.
|
||||||
|
|||||||
@ -33,14 +33,17 @@ Initialize a button.
|
|||||||
- label: The buttons label.
|
- label: The buttons label.
|
||||||
- handler: The button's action handler.
|
- handler: The button's action handler.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a button's view storage.
|
Update a button's view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a button's view storage.
|
Get a button's view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The button's view storage.
|
- Returns: The button's view storage.
|
||||||
|
|
||||||
### `keyboardShortcut(_:window:)`
|
### `keyboardShortcut(_:window:)`
|
||||||
|
|||||||
@ -14,12 +14,15 @@ The content.
|
|||||||
The maximum size.
|
The maximum size.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
33
Documentation/Reference/structs/ContentModifier.md
Normal file
33
Documentation/Reference/structs/ContentModifier.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
**STRUCT**
|
||||||
|
|
||||||
|
# `ContentModifier`
|
||||||
|
|
||||||
|
A widget which replaces views of a specific type in its content.
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
### `content`
|
||||||
|
|
||||||
|
The wrapped view.
|
||||||
|
|
||||||
|
### `modify`
|
||||||
|
|
||||||
|
The closure for the modification.
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
### `container(modifiers:)`
|
||||||
|
|
||||||
|
Get the content's container.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
|
- Returns: The content's container.
|
||||||
|
|
||||||
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
|
Update the content.
|
||||||
|
- Parameters:
|
||||||
|
- storage: The content's storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
|
### `modifyView(_:)`
|
||||||
|
|
||||||
|
Apply the modifier to a view.
|
||||||
|
- Parameter view: The view.
|
||||||
@ -34,18 +34,21 @@ Initialize an `EitherView`.
|
|||||||
- trueView: The view that is presented if `isTrue` is true.
|
- trueView: The view that is presented if `isTrue` is true.
|
||||||
- falseView: The view that is presented if `isTrue` is false.
|
- falseView: The view that is presented if `isTrue` is false.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update an `EitherView`'s storage.
|
Update an `EitherView`'s storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `updateContent(_:state:stack:)`
|
### `updateContent(_:state:stack:modifiers:)`
|
||||||
|
|
||||||
Update the content of a view in the view storage.
|
Update the content of a view in the view storage.
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- storage: The view storage.
|
- storage: The view storage.
|
||||||
- state: Whether it is the true or false view.
|
- state: Whether it is the true or false view.
|
||||||
- stack: The stack.
|
- stack: The stack.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `setVisible(_:view:)`
|
### `setVisible(_:view:)`
|
||||||
|
|
||||||
@ -54,7 +57,8 @@ Set the visible content page.
|
|||||||
- stack: The stack.
|
- stack: The stack.
|
||||||
- view: The visible view.
|
- view: The visible view.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a GtkStack view storage.
|
Get a GtkStack view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -15,12 +15,15 @@ The content.
|
|||||||
Initialize a `HStack`.
|
Initialize a `HStack`.
|
||||||
- Parameter content: The view content.
|
- Parameter content: The view content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -59,14 +59,17 @@ Initialize a header bar with only views at the end.
|
|||||||
- Parameter start: The views.
|
- Parameter start: The views.
|
||||||
- Returns: The header bar.
|
- Returns: The header bar.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a header bar's view storage.
|
Update a header bar's view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the container for a header bar.
|
Get the container for a header bar.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
### `headerBarTitle(view:)`
|
### `headerBarTitle(view:)`
|
||||||
|
|||||||
@ -14,12 +14,15 @@ The custom code to edit the widget.
|
|||||||
The wrapped view.
|
The wrapped view.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the content's container.
|
Get the content's container.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The content's container.
|
- Returns: The content's container.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the content.
|
Update the content.
|
||||||
- Parameter storage: The content's storage.
|
- Parameters:
|
||||||
|
- storage: The content's storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|||||||
@ -26,14 +26,17 @@ Initialize `List`.
|
|||||||
- selection: The identifier of the selected element.
|
- selection: The identifier of the selected element.
|
||||||
- content: The view for an element.
|
- content: The view for an element.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
### `updateSelection(box:)`
|
### `updateSelection(box:)`
|
||||||
|
|||||||
@ -45,12 +45,15 @@ Initialize a menu button.
|
|||||||
- window: The application window.
|
- window: The application window.
|
||||||
- content: The menu's content.
|
- content: The menu's content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a button's view storage.
|
Update a button's view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a button's view storage.
|
Get a button's view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The button's view storage.
|
- Returns: The button's view storage.
|
||||||
|
|||||||
24
Documentation/Reference/structs/ModifierStopper.md
Normal file
24
Documentation/Reference/structs/ModifierStopper.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
**STRUCT**
|
||||||
|
|
||||||
|
# `ModifierStopper`
|
||||||
|
|
||||||
|
Remove all of the content modifiers for the wrapped views.
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
### `content`
|
||||||
|
|
||||||
|
The wrapped view.
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
### `container(modifiers:)`
|
||||||
|
|
||||||
|
Get the content's container.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
|
- Returns: The content's container.
|
||||||
|
|
||||||
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
|
Update the content.
|
||||||
|
- Parameters:
|
||||||
|
- storage: The content's storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
@ -29,12 +29,15 @@ Initialize a navigation split view.
|
|||||||
- sidebar: The sidebar content.
|
- sidebar: The sidebar content.
|
||||||
- content: The main content.
|
- content: The main content.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the container of the navigation split view widget.
|
Get the container of the navigation split view widget.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the view storage of the navigation split view widget.
|
Update the view storage of the navigation split view widget.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|||||||
@ -15,12 +15,15 @@ The content.
|
|||||||
Initialize a `ScrollView`.
|
Initialize a `ScrollView`.
|
||||||
- Parameter content: The view content.
|
- Parameter content: The view content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -26,12 +26,15 @@ Initialize a `StateWrapper`.
|
|||||||
- content: The view content.
|
- content: The view content.
|
||||||
- state: The state information.
|
- state: The state information.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -31,12 +31,15 @@ Initialize a status page widget.
|
|||||||
- description: Additional details.
|
- description: Additional details.
|
||||||
- content: Additional content.
|
- content: Additional content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the view storage of the text widget.
|
Update the view storage of the text widget.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the container of the text widget.
|
Get the container of the text widget.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -15,12 +15,14 @@ The content.
|
|||||||
Initialize a text widget.
|
Initialize a text widget.
|
||||||
- Parameter text: The content.
|
- Parameter text: The content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the view storage of the text widget.
|
Update the view storage of the text widget.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the container of the text widget.
|
Get the container of the text widget.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -26,12 +26,15 @@ Whether the toolbar is visible.
|
|||||||
The identifier of the toolbar content.
|
The identifier of the toolbar content.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the container of the toolbar view widget.
|
Get the container of the toolbar view widget.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the view storage of the toolbar view widget.
|
Update the view storage of the toolbar view widget.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|||||||
@ -14,12 +14,15 @@ The function.
|
|||||||
The content.
|
The content.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get the content's container.
|
Get the content's container.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The content's container.
|
- Returns: The content's container.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update the content.
|
Update the content.
|
||||||
- Parameter storage: The content's storage.
|
- Parameters:
|
||||||
|
- storage: The content's storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|||||||
@ -15,12 +15,15 @@ The content.
|
|||||||
Initialize a `VStack`.
|
Initialize a `VStack`.
|
||||||
- Parameter content: The view content.
|
- Parameter content: The view content.
|
||||||
|
|
||||||
### `update(_:)`
|
### `update(_:modifiers:)`
|
||||||
|
|
||||||
Update a view storage.
|
Update a view storage.
|
||||||
- Parameter storage: The view storage.
|
- Parameters:
|
||||||
|
- storage: The view storage.
|
||||||
|
- modifiers: Modify views before being updated.
|
||||||
|
|
||||||
### `container()`
|
### `container(modifiers:)`
|
||||||
|
|
||||||
Get a view storage.
|
Get a view storage.
|
||||||
|
- Parameter modifiers: Modify views before being updated.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|||||||
@ -19,6 +19,10 @@ The window's content.
|
|||||||
|
|
||||||
Whether an instance of the window type should be opened when the app is starting up.
|
Whether an instance of the window type should be opened when the app is starting up.
|
||||||
|
|
||||||
|
### `parentID`
|
||||||
|
|
||||||
|
The identifier of the window's parent.
|
||||||
|
|
||||||
### `shortcuts`
|
### `shortcuts`
|
||||||
|
|
||||||
The keyboard shortcuts.
|
The keyboard shortcuts.
|
||||||
@ -59,6 +63,12 @@ Get the storage of the content view.
|
|||||||
Update a window storage's content.
|
Update a window storage's content.
|
||||||
- Parameter storage: The storage to update.
|
- Parameter storage: The storage to update.
|
||||||
|
|
||||||
|
### `overlay(windows:)`
|
||||||
|
|
||||||
|
Add windows that overlay the last instance of this window if presented.
|
||||||
|
- Parameter windows: The windows.
|
||||||
|
- Returns: The new windows and this window.
|
||||||
|
|
||||||
### `keyboardShortcut(_:action:)`
|
### `keyboardShortcut(_:action:)`
|
||||||
|
|
||||||
Add a keyboard shortcut.
|
Add a keyboard shortcut.
|
||||||
|
|||||||
@ -103,6 +103,8 @@ If you want to use _Adwaita_ in a project, but there are widgets missing, open a
|
|||||||
| `onAppear(_:)` | Run when the view is rendered for the first time. |
|
| `onAppear(_:)` | Run when the view is rendered for the first time. |
|
||||||
| `topToolbar(visible:_:)` | Add a native toolbar to the view. Normally, it contains a HeaderBar. |
|
| `topToolbar(visible:_:)` | Add a native toolbar to the view. Normally, it contains a HeaderBar. |
|
||||||
| `bottomToolbar(visible:_:)` | Add a native bottom toolbar to the view. |
|
| `bottomToolbar(visible:_:)` | Add a native bottom toolbar to the view. |
|
||||||
|
| `modifyContent(_:modify:)` | Replace all occurrences of a certain view type with another view. |
|
||||||
|
| `stopModifiers()` | Ignore all the `modifyContent(_:modify:)` modifiers from higher above in the view tree. |
|
||||||
|
|
||||||
### `Button` Modifiers
|
### `Button` Modifiers
|
||||||
| Syntax | Description |
|
| Syntax | Description |
|
||||||
|
|||||||
@ -13,22 +13,30 @@ extension Array: View where Element == View {
|
|||||||
public var view: Body { self }
|
public var view: Body { self }
|
||||||
|
|
||||||
/// Get a widget from a collection of views.
|
/// Get a widget from a collection of views.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: A widget.
|
/// - Returns: A widget.
|
||||||
public func widget() -> Widget {
|
public func widget(modifiers: [(View) -> View]) -> Widget {
|
||||||
if count == 1, let widget = self[safe: 0]?.widget() {
|
if count == 1, let widget = self[safe: 0]?.widget(modifiers: modifiers) {
|
||||||
return widget
|
return widget
|
||||||
} else {
|
} else {
|
||||||
return VStack { self }
|
var modified = self
|
||||||
|
for (index, view) in modified.enumerated() {
|
||||||
|
for modifier in modifiers {
|
||||||
|
modified[index] = modifier(view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return VStack { modified }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update a collection of views with a collection of view storages.
|
/// Update a collection of views with a collection of view storages.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - storage: The collection of view storages.
|
/// - storage: The collection of view storages.
|
||||||
public func update(_ storage: [ViewStorage]) {
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: [ViewStorage], modifiers: [(View) -> View]) {
|
||||||
for (index, element) in enumerated() {
|
for (index, element) in enumerated() {
|
||||||
if let storage = storage[safe: index] {
|
if let storage = storage[safe: index] {
|
||||||
element.widget().updateStorage(storage)
|
element.widget(modifiers: modifiers).updateStorage(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,12 +10,15 @@ import GTUI
|
|||||||
extension NativeWidgetPeer: Widget {
|
extension NativeWidgetPeer: Widget {
|
||||||
|
|
||||||
/// A `GTUI.NativeWidgetPeer` is static.
|
/// A `GTUI.NativeWidgetPeer` is static.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) { }
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { }
|
||||||
|
|
||||||
/// A `GTUI.NativeWidgetPeer`'s container is itself.
|
/// A `GTUI.NativeWidgetPeer`'s container is itself.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let bold = "\(modifier(code: 1))"
|
let bold = "\(modifier(code: 1))"
|
||||||
let yellow = 33
|
let yellow = 33
|
||||||
let warning = "\(modifier(code: yellow))\(bold)"
|
let warning = "\(modifier(code: yellow))\(bold)"
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class GTUIApp: Application {
|
|||||||
/// Set the parents of every window having a parent window.
|
/// Set the parents of every window having a parent window.
|
||||||
func setParentWindows() {
|
func setParentWindows() {
|
||||||
for window in sceneStorage {
|
for window in sceneStorage {
|
||||||
if let parent = sceneStorage.first { $0.id == window.parentID } {
|
if let parent = sceneStorage.first(where: { $0.id == window.parentID }) {
|
||||||
window.window.setParent(parent.window)
|
window.window.setParent(parent.window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,11 @@ public protocol View {
|
|||||||
extension View {
|
extension View {
|
||||||
|
|
||||||
/// Wrap the view into a widget.
|
/// Wrap the view into a widget.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The widget.
|
/// - Returns: The widget.
|
||||||
public func widget() -> Widget {
|
public func widget(modifiers: [(View) -> View]) -> Widget {
|
||||||
if let peer = self as? Widget {
|
let modified = getModified(modifiers: modifiers)
|
||||||
|
if let peer = modified as? Widget {
|
||||||
return peer
|
return peer
|
||||||
} else {
|
} else {
|
||||||
var state: [String: StateProtocol] = [:]
|
var state: [String: StateProtocol] = [:]
|
||||||
@ -46,19 +48,31 @@ extension View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a storage to a view.
|
/// Update a storage to a view.
|
||||||
/// - Parameter storage: The storage.
|
/// - Parameters:
|
||||||
func updateStorage(_ storage: ViewStorage) {
|
/// - storage: The storage.
|
||||||
if let widget = self as? Widget {
|
/// - modifiers: Modify views before being updated.
|
||||||
widget.update(storage)
|
func updateStorage(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
let modified = getModified(modifiers: modifiers)
|
||||||
|
if let widget = modified as? Widget {
|
||||||
|
widget.update(storage, modifiers: modifiers)
|
||||||
} else {
|
} else {
|
||||||
StateWrapper { self }.update(storage)
|
StateWrapper { self }.update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a storage.
|
/// Get a storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The storage.
|
/// - Returns: The storage.
|
||||||
func storage() -> ViewStorage {
|
func storage(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
widget().container()
|
widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getModified(modifiers: [(View) -> View]) -> View {
|
||||||
|
var modified: View = self
|
||||||
|
for modifier in modifiers {
|
||||||
|
modified = modifier(modified)
|
||||||
|
}
|
||||||
|
return modified
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,10 +11,13 @@ import GTUI
|
|||||||
public protocol Widget: View {
|
public protocol Widget: View {
|
||||||
|
|
||||||
/// The view storage.
|
/// The view storage.
|
||||||
func container() -> ViewStorage
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
|
func container(modifiers: [(View) -> View]) -> ViewStorage
|
||||||
/// Update the stored content.
|
/// Update the stored content.
|
||||||
/// - Parameter storage: The storage to update.
|
/// - Parameters:
|
||||||
func update(_ storage: ViewStorage)
|
/// - storage: The storage to update.
|
||||||
|
/// - modifiers: Modify views before being updated
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,8 +40,10 @@ public struct Button: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a button's view storage.
|
/// Update a button's view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let button = storage.view as? GTUI.Button {
|
if let button = storage.view as? GTUI.Button {
|
||||||
let content = button.getContent()
|
let content = button.getContent()
|
||||||
if let label {
|
if let label {
|
||||||
@ -58,8 +60,9 @@ public struct Button: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a button's view storage.
|
/// Get a button's view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The button's view storage.
|
/// - Returns: The button's view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
if let icon {
|
if let icon {
|
||||||
return .init(GTUI.Button(label, icon: icon).handler(handler))
|
return .init(GTUI.Button(label, icon: icon).handler(handler))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -42,11 +42,13 @@ public struct EitherView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update an `EitherView`'s storage.
|
/// Update an `EitherView`'s storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
let stack = storage.view as? Stack
|
let stack = storage.view as? Stack
|
||||||
updateContent(storage, state: true, stack: stack)
|
updateContent(storage, state: true, stack: stack, modifiers: modifiers)
|
||||||
updateContent(storage, state: false, stack: stack)
|
updateContent(storage, state: false, stack: stack, modifiers: modifiers)
|
||||||
if isTrue, let trueView = storage.content["\(true)"]?.last?.view {
|
if isTrue, let trueView = storage.content["\(true)"]?.last?.view {
|
||||||
setVisible(stack, view: trueView)
|
setVisible(stack, view: trueView)
|
||||||
} else if !isTrue, let falseView = storage.content["\(false)"]?.last?.view {
|
} else if !isTrue, let falseView = storage.content["\(false)"]?.last?.view {
|
||||||
@ -59,11 +61,12 @@ public struct EitherView: Widget {
|
|||||||
/// - storage: The view storage.
|
/// - storage: The view storage.
|
||||||
/// - state: Whether it is the true or false view.
|
/// - state: Whether it is the true or false view.
|
||||||
/// - stack: The stack.
|
/// - stack: The stack.
|
||||||
private func updateContent(_ storage: ViewStorage, state: Bool, stack: Stack?) {
|
/// - modifiers: Modify views before being updated.
|
||||||
let activeView = (state ? trueView : falseView)?.widget()
|
private func updateContent(_ storage: ViewStorage, state: Bool, stack: Stack?, modifiers: [(View) -> View]) {
|
||||||
|
let activeView = (state ? trueView : falseView)?.widget(modifiers: modifiers)
|
||||||
if let view = storage.content["\(state)"]?[safe: 0] {
|
if let view = storage.content["\(state)"]?[safe: 0] {
|
||||||
activeView?.updateStorage(view)
|
activeView?.updateStorage(view, modifiers: modifiers)
|
||||||
} else if let view = activeView?.storage() {
|
} else if let view = activeView?.storage(modifiers: modifiers) {
|
||||||
_ = stack?.append(view.view)
|
_ = stack?.append(view.view)
|
||||||
storage.content["\(state)"] = [view]
|
storage.content["\(state)"] = [view]
|
||||||
}
|
}
|
||||||
@ -78,17 +81,18 @@ public struct EitherView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a GtkStack view storage.
|
/// Get a GtkStack view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let stack = Stack()
|
let stack = Stack()
|
||||||
var content: [String: [ViewStorage]] = [:]
|
var content: [String: [ViewStorage]] = [:]
|
||||||
if let trueView {
|
if let trueView {
|
||||||
let view = trueView.widget().storage()
|
let view = trueView.widget(modifiers: modifiers).storage(modifiers: modifiers)
|
||||||
_ = stack.append(view.view)
|
_ = stack.append(view.view)
|
||||||
content["\(true)"] = [view]
|
content["\(true)"] = [view]
|
||||||
}
|
}
|
||||||
if let falseView {
|
if let falseView {
|
||||||
let view = falseView.widget().storage()
|
let view = falseView.widget(modifiers: modifiers).storage(modifiers: modifiers)
|
||||||
_ = stack.append(view.view)
|
_ = stack.append(view.view)
|
||||||
content["\(false)"] = [view]
|
content["\(false)"] = [view]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,18 +20,21 @@ public struct HStack: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
content().update(storage.content[.mainContent] ?? [])
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
content().update(storage.content[.mainContent] ?? [], modifiers: modifiers)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let box: Box = .init(horizontal: true)
|
let box: Box = .init(horizontal: true)
|
||||||
var content: [ViewStorage] = []
|
var content: [ViewStorage] = []
|
||||||
for element in self.content() {
|
for element in self.content() {
|
||||||
let widget = element.storage()
|
let widget = element.storage(modifiers: modifiers)
|
||||||
_ = box.append(widget.view)
|
_ = box.append(widget.view)
|
||||||
content.append(widget)
|
content.append(widget)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,35 +58,38 @@ public struct HeaderBar: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a header bar's view storage.
|
/// Update a header bar's view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let bar = storage.view as? GTUI.HeaderBar {
|
if let bar = storage.view as? GTUI.HeaderBar {
|
||||||
_ = bar.showTitleButtons(titleButtons)
|
_ = bar.showTitleButtons(titleButtons)
|
||||||
}
|
}
|
||||||
start.update(storage.content[startID] ?? [])
|
start.update(storage.content[startID] ?? [], modifiers: modifiers)
|
||||||
end.update(storage.content[endID] ?? [])
|
end.update(storage.content[endID] ?? [], modifiers: modifiers)
|
||||||
if let first = storage.content[titleID]?.first {
|
if let first = storage.content[titleID]?.first {
|
||||||
headerBarTitle?.widget().update(first)
|
headerBarTitle?.widget(modifiers: modifiers).update(first, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the container for a header bar.
|
/// Get the container for a header bar.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let bar: GTUI.HeaderBar = .init()
|
let bar: GTUI.HeaderBar = .init()
|
||||||
var startContent: [ViewStorage] = []
|
var startContent: [ViewStorage] = []
|
||||||
var endContent: [ViewStorage] = []
|
var endContent: [ViewStorage] = []
|
||||||
for element in start {
|
for element in start {
|
||||||
let element = element.storage()
|
let element = element.storage(modifiers: modifiers)
|
||||||
_ = bar.packStart(element.view)
|
_ = bar.packStart(element.view)
|
||||||
startContent.append(element)
|
startContent.append(element)
|
||||||
}
|
}
|
||||||
for element in end {
|
for element in end {
|
||||||
let element = element.storage()
|
let element = element.storage(modifiers: modifiers)
|
||||||
_ = bar.packEnd(element.view)
|
_ = bar.packEnd(element.view)
|
||||||
endContent.append(element)
|
endContent.append(element)
|
||||||
}
|
}
|
||||||
let title = headerBarTitle?.widget().container()
|
let title = headerBarTitle?.widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
let titleStorage: [ViewStorage]
|
let titleStorage: [ViewStorage]
|
||||||
if let title {
|
if let title {
|
||||||
_ = bar.titleWidget(title.view)
|
_ = bar.titleWidget(title.view)
|
||||||
|
|||||||
@ -33,20 +33,23 @@ public struct List<Element>: Widget where Element: Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let box = storage.view as? ListBox {
|
if let box = storage.view as? ListBox {
|
||||||
updateSelection(box: box)
|
updateSelection(box: box)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let box: ListBox = .init()
|
let box: ListBox = .init()
|
||||||
var content: [ViewStorage] = []
|
var content: [ViewStorage] = []
|
||||||
for element in elements {
|
for element in elements {
|
||||||
let widget = self.content(element).widget().container()
|
let widget = self.content(element).widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
_ = box.append(widget.view)
|
_ = box.append(widget.view)
|
||||||
content.append(widget)
|
content.append(widget)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,8 +63,10 @@ public struct Menu: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a button's view storage.
|
/// Update a button's view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let button = storage.view as? GTUI.MenuButton {
|
if let button = storage.view as? GTUI.MenuButton {
|
||||||
let content = button.getContent()
|
let content = button.getContent()
|
||||||
if let label {
|
if let label {
|
||||||
@ -81,8 +83,9 @@ public struct Menu: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a button's view storage.
|
/// Get a button's view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The button's view storage.
|
/// - Returns: The button's view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let button: GTUI.MenuButton
|
let button: GTUI.MenuButton
|
||||||
if let icon {
|
if let icon {
|
||||||
button = .init(label, icon: icon)
|
button = .init(label, icon: icon)
|
||||||
|
|||||||
@ -16,20 +16,23 @@ struct Clamp: Widget {
|
|||||||
var maxSize: Int
|
var maxSize: Int
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let clamp = storage.view as? GTUI.Clamp {
|
if let clamp = storage.view as? GTUI.Clamp {
|
||||||
_ = clamp.maximumSize(maxSize)
|
_ = clamp.maximumSize(maxSize)
|
||||||
}
|
}
|
||||||
if let storage = storage.content[.mainContent]?[safe: 0] {
|
if let storage = storage.content[.mainContent]?[safe: 0] {
|
||||||
content.widget().update(storage)
|
content.widget(modifiers: modifiers).update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
func container() -> ViewStorage {
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let container = content.storage()
|
let container = content.storage(modifiers: modifiers)
|
||||||
let clamp: GTUI.Clamp = .init(container.view)
|
let clamp: GTUI.Clamp = .init(container.view)
|
||||||
_ = clamp.maximumSize(maxSize)
|
_ = clamp.maximumSize(maxSize)
|
||||||
return .init(clamp, content: [.mainContent: [container]])
|
return .init(clamp, content: [.mainContent: [container]])
|
||||||
|
|||||||
60
Sources/Adwaita/View/Modifiers/ContentModifier.swift
Normal file
60
Sources/Adwaita/View/Modifiers/ContentModifier.swift
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// ContentModifier.swift
|
||||||
|
// Adwaita
|
||||||
|
//
|
||||||
|
// Created by david-swift on 11.11.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import GTUI
|
||||||
|
|
||||||
|
/// A widget which replaces views of a specific type in its content.
|
||||||
|
struct ContentModifier<Content>: Widget where Content: View {
|
||||||
|
|
||||||
|
/// The wrapped view.
|
||||||
|
var content: View
|
||||||
|
/// The closure for the modification.
|
||||||
|
var modify: (Content) -> View
|
||||||
|
|
||||||
|
/// Get the content's container.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
|
/// - Returns: The content's container.
|
||||||
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
|
let storage = content.storage(modifiers: modifiers + [modifyView])
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update the content.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - storage: The content's storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
content.updateStorage(storage, modifiers: modifiers + [modifyView])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply the modifier to a view.
|
||||||
|
/// - Parameter view: The view.
|
||||||
|
func modifyView(_ view: View) -> View {
|
||||||
|
if let view = view as? Content {
|
||||||
|
return modify(view).stopModifiers()
|
||||||
|
} else {
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension View {
|
||||||
|
|
||||||
|
/// Replace every occurrence of a certain view type in the content.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - type: The view type.
|
||||||
|
/// - modify: Modify the view.
|
||||||
|
/// - Returns: A view.
|
||||||
|
public func modifyContent<Content>(
|
||||||
|
_ type: Content.Type,
|
||||||
|
modify: @escaping (Content) -> View
|
||||||
|
) -> View where Content: View {
|
||||||
|
ContentModifier(content: self, modify: modify)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -16,17 +16,20 @@ struct InspectorWrapper: Widget {
|
|||||||
var content: View
|
var content: View
|
||||||
|
|
||||||
/// Get the content's container.
|
/// Get the content's container.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The content's container.
|
/// - Returns: The content's container.
|
||||||
func container() -> ViewStorage {
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let storage = content.storage()
|
let storage = content.storage(modifiers: modifiers)
|
||||||
modify(storage.view)
|
modify(storage.view)
|
||||||
return storage
|
return storage
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the content.
|
/// Update the content.
|
||||||
/// - Parameter storage: The content's storage.
|
/// - Parameters:
|
||||||
func update(_ storage: ViewStorage) {
|
/// - storage: The content's storage.
|
||||||
content.updateStorage(storage)
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
content.updateStorage(storage, modifiers: modifiers)
|
||||||
modify(storage.view)
|
modify(storage.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
42
Sources/Adwaita/View/Modifiers/ModifierStopper.swift
Normal file
42
Sources/Adwaita/View/Modifiers/ModifierStopper.swift
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// ModifierStopper.swift
|
||||||
|
// Adwaita
|
||||||
|
//
|
||||||
|
// Created by david-swift on 11.11.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import GTUI
|
||||||
|
|
||||||
|
/// Remove all of the content modifiers for the wrapped views.
|
||||||
|
struct ModifierStopper: Widget {
|
||||||
|
|
||||||
|
/// The wrapped view.
|
||||||
|
var content: View
|
||||||
|
|
||||||
|
/// Get the content's container.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
|
/// - Returns: The content's container.
|
||||||
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
|
let storage = content.storage(modifiers: [])
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update the content.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - storage: The content's storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
content.updateStorage(storage, modifiers: [])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension View {
|
||||||
|
|
||||||
|
/// Remove all of the content modifiers for the wrapped views.
|
||||||
|
/// - Returns: A view.
|
||||||
|
public func stopModifiers() -> View {
|
||||||
|
ModifierStopper(content: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -23,13 +23,14 @@ struct ToolbarView: Widget {
|
|||||||
let toolbarID = "toolbar"
|
let toolbarID = "toolbar"
|
||||||
|
|
||||||
/// Get the container of the toolbar view widget.
|
/// Get the container of the toolbar view widget.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
func container() -> ViewStorage {
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let content = content.storage()
|
let content = content.storage(modifiers: modifiers)
|
||||||
let view = GTUI.ToolbarView(content.view)
|
let view = GTUI.ToolbarView(content.view)
|
||||||
var toolbarContent: [ViewStorage] = []
|
var toolbarContent: [ViewStorage] = []
|
||||||
for item in toolbar() {
|
for item in toolbar() {
|
||||||
let storage = item.storage()
|
let storage = item.storage(modifiers: modifiers)
|
||||||
toolbarContent.append(storage)
|
toolbarContent.append(storage)
|
||||||
if bottom {
|
if bottom {
|
||||||
_ = view.addBottomBar(storage.view)
|
_ = view.addBottomBar(storage.view)
|
||||||
@ -46,14 +47,16 @@ struct ToolbarView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the view storage of the toolbar view widget.
|
/// Update the view storage of the toolbar view widget.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let mainContent = storage.content[.mainContent]?.first {
|
if let mainContent = storage.content[.mainContent]?.first {
|
||||||
content.widget().update(mainContent)
|
content.widget(modifiers: modifiers).update(mainContent, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
if let toolbar = storage.content[toolbarID] {
|
if let toolbar = storage.content[toolbarID] {
|
||||||
for (index, content) in toolbar.enumerated() {
|
for (index, content) in toolbar.enumerated() {
|
||||||
self.toolbar()[safe: index]?.updateStorage(content)
|
self.toolbar()[safe: index]?.updateStorage(content, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let view = storage.view as? GTUI.ToolbarView {
|
if let view = storage.view as? GTUI.ToolbarView {
|
||||||
|
|||||||
@ -16,17 +16,20 @@ struct UpdateObserver: Widget {
|
|||||||
var content: View
|
var content: View
|
||||||
|
|
||||||
/// Get the content's container.
|
/// Get the content's container.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The content's container.
|
/// - Returns: The content's container.
|
||||||
func container() -> ViewStorage {
|
func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
onUpdate()
|
onUpdate()
|
||||||
return content.storage()
|
return content.storage(modifiers: modifiers)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the content.
|
/// Update the content.
|
||||||
/// - Parameter storage: The content's storage.
|
/// - Parameters:
|
||||||
func update(_ storage: ViewStorage) {
|
/// - storage: The content's storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
onUpdate()
|
onUpdate()
|
||||||
content.updateStorage(storage)
|
content.updateStorage(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,17 +30,18 @@ public struct NavigationSplitView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the container of the navigation split view widget.
|
/// Get the container of the navigation split view widget.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let splitView: GTUI.NavigationSplitView = .init()
|
let splitView: GTUI.NavigationSplitView = .init()
|
||||||
var content: [String: [ViewStorage]] = [:]
|
var content: [String: [ViewStorage]] = [:]
|
||||||
|
|
||||||
let sidebar = sidebar().widget().container()
|
let sidebar = sidebar().widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
let label = sidebar.view.fields[.navigationLabel] as? String ?? ""
|
let label = sidebar.view.fields[.navigationLabel] as? String ?? ""
|
||||||
_ = splitView.sidebar(sidebar.view, title: label)
|
_ = splitView.sidebar(sidebar.view, title: label)
|
||||||
content[sidebarID] = [sidebar]
|
content[sidebarID] = [sidebar]
|
||||||
|
|
||||||
let mainContent = self.content().widget().container()
|
let mainContent = self.content().widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
let mainLabel = mainContent.view.fields[.navigationLabel] as? String ?? ""
|
let mainLabel = mainContent.view.fields[.navigationLabel] as? String ?? ""
|
||||||
_ = splitView.content(mainContent.view, title: mainLabel)
|
_ = splitView.content(mainContent.view, title: mainLabel)
|
||||||
content[contentID] = [mainContent]
|
content[contentID] = [mainContent]
|
||||||
@ -49,13 +50,15 @@ public struct NavigationSplitView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the view storage of the navigation split view widget.
|
/// Update the view storage of the navigation split view widget.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let storage = storage.content[contentID]?[safe: 0] {
|
if let storage = storage.content[contentID]?[safe: 0] {
|
||||||
content().widget().update(storage)
|
content().widget(modifiers: modifiers).update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
if let storage = storage.content[sidebarID]?[safe: 0] {
|
if let storage = storage.content[sidebarID]?[safe: 0] {
|
||||||
sidebar().widget().update(storage)
|
sidebar().widget(modifiers: modifiers).update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,17 +20,20 @@ public struct ScrollView: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let first = storage.content[.mainContent]?.first {
|
if let first = storage.content[.mainContent]?.first {
|
||||||
content().widget().update(first)
|
content().widget(modifiers: modifiers).update(first, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let container = content().widget().container()
|
let container = content().widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
return .init(Scrolled().setChild(container.view), content: [.mainContent: [container]])
|
return .init(Scrolled().setChild(container.view), content: [.mainContent: [container]])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,22 +31,25 @@ public struct StateWrapper: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
for property in state {
|
for property in state {
|
||||||
if let value = storage.state[property.key]?.value {
|
if let value = storage.state[property.key]?.value {
|
||||||
property.value.value = value
|
property.value.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let storage = storage.content[.mainContent]?.first {
|
if let storage = storage.content[.mainContent]?.first {
|
||||||
content().widget().update(storage)
|
content().widget(modifiers: modifiers).update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let content = content().widget().container()
|
let content = content().widget(modifiers: modifiers).container(modifiers: modifiers)
|
||||||
return .init(content.view, content: [.mainContent: [content]], state: state)
|
return .init(content.view, content: [.mainContent: [content]], state: state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,20 +38,23 @@ public struct StatusPage: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the view storage of the text widget.
|
/// Update the view storage of the text widget.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let statusPage = storage.view as? GTUI.StatusPage {
|
if let statusPage = storage.view as? GTUI.StatusPage {
|
||||||
_ = statusPage.title(title).description(description).icon(icon)
|
_ = statusPage.title(title).description(description).icon(icon)
|
||||||
}
|
}
|
||||||
if let storage = storage.content[.mainContent]?.first {
|
if let storage = storage.content[.mainContent]?.first {
|
||||||
content.widget().update(storage)
|
content.widget(modifiers: modifiers).update(storage, modifiers: modifiers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the container of the text widget.
|
/// Get the container of the text widget.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let child = content.widget().container()
|
let child = content.widget(modifiers: []).container(modifiers: modifiers)
|
||||||
return .init(
|
return .init(
|
||||||
GTUI.StatusPage().title(title).description(description).icon(icon).child(child.view),
|
GTUI.StatusPage().title(title).description(description).icon(icon).child(child.view),
|
||||||
content: [.mainContent: [child]]
|
content: [.mainContent: [child]]
|
||||||
|
|||||||
@ -20,8 +20,10 @@ public struct Text: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the view storage of the text widget.
|
/// Update the view storage of the text widget.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
if let label = storage.view as? MarkupLabel {
|
if let label = storage.view as? MarkupLabel {
|
||||||
label.setText(text)
|
label.setText(text)
|
||||||
}
|
}
|
||||||
@ -29,7 +31,7 @@ public struct Text: Widget {
|
|||||||
|
|
||||||
/// Get the container of the text widget.
|
/// Get the container of the text widget.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
.init(MarkupLabel(self.text))
|
.init(MarkupLabel(self.text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,18 +20,21 @@ public struct VStack: Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update a view storage.
|
/// Update a view storage.
|
||||||
/// - Parameter storage: The view storage.
|
/// - Parameters:
|
||||||
public func update(_ storage: ViewStorage) {
|
/// - storage: The view storage.
|
||||||
content().update(storage.content[.mainContent] ?? [])
|
/// - modifiers: Modify views before being updated.
|
||||||
|
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
|
||||||
|
content().update(storage.content[.mainContent] ?? [], modifiers: modifiers)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a view storage.
|
/// Get a view storage.
|
||||||
|
/// - Parameter modifiers: Modify views before being updated.
|
||||||
/// - Returns: The view storage.
|
/// - Returns: The view storage.
|
||||||
public func container() -> ViewStorage {
|
public func container(modifiers: [(View) -> View]) -> ViewStorage {
|
||||||
let box: Box = .init(horizontal: false)
|
let box: Box = .init(horizontal: false)
|
||||||
var content: [ViewStorage] = []
|
var content: [ViewStorage] = []
|
||||||
for element in self.content() {
|
for element in self.content() {
|
||||||
let widget = element.storage()
|
let widget = element.storage(modifiers: modifiers)
|
||||||
_ = box.append(widget.view)
|
_ = box.append(widget.view)
|
||||||
content.append(widget)
|
content.append(widget)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public struct Window: WindowScene {
|
|||||||
/// - Returns: The storage of the content of the window.
|
/// - Returns: The storage of the content of the window.
|
||||||
func getViewStorage(window: GTUIApplicationWindow) -> ViewStorage {
|
func getViewStorage(window: GTUIApplicationWindow) -> ViewStorage {
|
||||||
let content = content(window)
|
let content = content(window)
|
||||||
let storage = content.widget().container()
|
let storage = content.widget(modifiers: []).container(modifiers: [])
|
||||||
window.setChild(storage.view)
|
window.setChild(storage.view)
|
||||||
updateShortcuts(window: window)
|
updateShortcuts(window: window)
|
||||||
return storage
|
return storage
|
||||||
@ -77,7 +77,7 @@ public struct Window: WindowScene {
|
|||||||
public func update(_ storage: WindowStorage, app: GTUIApp) {
|
public func update(_ storage: WindowStorage, app: GTUIApp) {
|
||||||
if let window = storage.window as? GTUIApplicationWindow {
|
if let window = storage.window as? GTUIApplicationWindow {
|
||||||
let content = content(window)
|
let content = content(window)
|
||||||
content.widget().updateStorage(storage.view)
|
content.widget(modifiers: []).updateStorage(storage.view, modifiers: [])
|
||||||
updateShortcuts(window: window)
|
updateShortcuts(window: window)
|
||||||
updateAppShortcuts(app: app)
|
updateAppShortcuts(app: app)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ struct Demo: App {
|
|||||||
|
|
||||||
struct DemoContent: View {
|
struct DemoContent: View {
|
||||||
|
|
||||||
@State private var selection: Page = .welcome
|
@State private var selection: Page = .transition
|
||||||
var window: GTUIApplicationWindow
|
var window: GTUIApplicationWindow
|
||||||
var app: GTUIApp!
|
var app: GTUIApp!
|
||||||
|
|
||||||
|
|||||||
@ -16,15 +16,16 @@ struct TransitionDemo: View {
|
|||||||
var view: Body {
|
var view: Body {
|
||||||
VStack {
|
VStack {
|
||||||
if firstView {
|
if firstView {
|
||||||
content("First View")
|
Text("First View")
|
||||||
.transition(.slideDown)
|
.transition(.slideDown)
|
||||||
.style("accent")
|
.style("accent")
|
||||||
} else {
|
} else {
|
||||||
content("Second View")
|
Text("Second View")
|
||||||
.transition(.slideUp)
|
.transition(.slideUp)
|
||||||
.style("success")
|
.style("success")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.modifyContent(Text.self) { $0.style("title-2").padding() }
|
||||||
.style("card")
|
.style("card")
|
||||||
.frame(maxSize: 200)
|
.frame(maxSize: 200)
|
||||||
.padding()
|
.padding()
|
||||||
@ -36,12 +37,6 @@ struct TransitionDemo: View {
|
|||||||
.frame(maxSize: 100)
|
.frame(maxSize: 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func content(_ text: String) -> View {
|
|
||||||
Text(text)
|
|
||||||
.style("title-2")
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// swiftlint:enable missing_docs no_magic_numbers
|
// swiftlint:enable missing_docs no_magic_numbers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user