Skip to content

Commit

Permalink
docs(framework): Enhance modal initializer docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStegii committed Jul 2, 2024
1 parent 0b9a964 commit 5cbd7c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 8 additions & 4 deletions docs/features/4-modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ can be used to display popup windows, dialogs, etc.
The framework provides a `Modals` class that can be used to display a modal.
Using a builder, a stage can be configured and then be displayed.

A BiConsumer provides access to the component instance and the stage for configuring things the builder doesn't provide.
An Initializer in the form of a BiConsumer provides access to the component instance and the stage for configuring
things the builder doesn't provide.
It can be set using `init()`.
Initializers are called after the component has been created, initialized and rendered, but before the stage is shown.

Enabling `dialog()` adds some default styling to the stage.
This has been added as an option to enable the legacy default styling present in the old modal class.

Parameters can be passed by using the `param()` method in form of a map (see `show()` in the `FulibFxApp` class).

Enabling `destroyOnClose()` configures the component to be destroyed upon closing the modal.
Enabling `destroyOnClose()` configures the component to be destroyed upon closing the modal.
This is enabled by default and shouldn't be changed if not necessary.

The stage can either be built using `build()` and then displayed by yourself, or built and displayed at once using `show()`.
The stage can either be built using `build()` and then displayed by yourself, or built and displayed at once
using `show()`.

When displaying the component, the parameters `modalStage` and `ownerStage` will be passed so that the modal can for
example be closed from inside the component class.

The same component instance cannot be used twice for displaying a modal. When using Dagger it is recommended to inject a provider and use it to create an instance for every modal.
The same component instance cannot be used twice for displaying a modal. When using Dagger it is recommended to inject a
provider and use it to create an instance for every modal.

```java

Expand Down
7 changes: 6 additions & 1 deletion framework/src/main/java/org/fulib/fx/constructs/Modals.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ public ModalBuilder(FulibFxApp app, T component) {
}

/**
* Adds an initializer.
* Adds an initializer for the modal stage.
* Initializers are called after the component has been initialized and rendered and the stage has been created,
* but before the stage is shown.
* They can be used to set additional properties on the stage or the component.
* <p>
* If another initializer has been added already, the new initializer will be called after the previous one.
*
Expand Down Expand Up @@ -114,6 +117,8 @@ public ModalBuilder<T> owner(Stage owner) {
* <p>
* This will set the stage style to {@link StageStyle#TRANSPARENT}, the modality to {@link Modality#WINDOW_MODAL}
* and the scene fill to transparent (see {@link ModalBuilder#FULIBFX_DIALOG}).
* <p>
* This initializer will be called before any other initializer.
*
* @param dialog Whether the default dialog options should be used
* @return The current modal instance
Expand Down

0 comments on commit 5cbd7c3

Please sign in to comment.