Skip to content

Commit 45964fd

Browse files
committed
docs(components/dialog): add Dialog docs and preview video
1 parent d81572f commit 45964fd

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

docs/en/components/dialog.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Dialog
3+
order: 21
4+
---
5+
6+
# Dialog
7+
8+
```rust
9+
pub fn dialog_provider(
10+
args: DialogProviderArgs,
11+
state: Arc<RwLock<DialogProviderState>>,
12+
main_content: impl FnOnce(),
13+
dialog_content: impl FnOnce(f32) + Send + Sync + 'static,
14+
)
15+
```
16+
17+
The `dialog_provider` component is used to display dialogs in an application.
18+
19+
## Arguments
20+
21+
- `args: DialogProviderArgs`
22+
23+
This argument configures the style of the dialog. Notably, `dialog_provider` supports both glass and non-glass dialog variants. It can be configured via the `style: DialogStyle` field of `DialogProviderArgs`. The default is `DialogStyle::Material`, i.e. the non-glass variant.
24+
25+
- `state: Arc<RwLock<DialogProviderState>>`
26+
27+
This argument manages the dialog state, including whether the dialog is open and the animation progress.
28+
29+
Use its `open()` and `close()` methods to programmatically open and close the dialog.
30+
31+
- `main_content: impl FnOnce()`
32+
33+
A closure that renders the main contentthe content underneath the dialog.
34+
35+
- `dialog_content: impl FnOnce(f32) + Send + Sync + 'static`
36+
37+
A closure that renders the dialog content. It receives an `f32` parameter representing the dialog's fade level. It is recommended to use this value as an alpha multiplier for content colors to achieve better visual effects.
38+
39+
## Preview
40+
41+
<video autoplay loop muted>
42+
43+
<source src="/dialog_example.mp4" type="video/mp4">
44+
Your browser does not support the video tag
45+
</video>

docs/public/dialog_example.mp4

506 KB
Binary file not shown.

docs/zhHans/components/dialog.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Dialog 组件
3+
order: 21
4+
---
5+
6+
# Dialog
7+
8+
```rust
9+
pub fn dialog_provider(
10+
args: DialogProviderArgs,
11+
state: Arc<RwLock<DialogProviderState>>,
12+
main_content: impl FnOnce(),
13+
dialog_content: impl FnOnce(f32) + Send + Sync + 'static,
14+
)
15+
```
16+
17+
`dialog_provider` 组件用于在应用程序中显示对话框。
18+
19+
## 参数
20+
21+
- `args: DialogProviderArgs`
22+
23+
该参数配置对话框的样式。值得一提的是,`dialog_provider` 同时支持玻璃态版本和非玻璃态版本的对话框。它可以通过 `DialogProviderArgs` 的 `style: DialogStyle` 字段来配置。默认为 `DialogStyle::Material`,即非玻璃态版本。
24+
25+
- `state: Arc<RwLock<DialogProviderState>>`
26+
27+
该参数管理对话框的状态,包括对话框是否打开以及动画进度。
28+
29+
使用其 `open()` 和 `close()` 方法可以程序化的打开和关闭对话框。
30+
31+
- `main_content: impl FnOnce()`
32+
33+
该参数是一个闭包,用于渲染主内容。即对话框下方的内容。
34+
35+
- `dialog_content: impl FnOnce(f32) + Send + Sync + 'static`
36+
37+
该参数是一个闭包,用于渲染对话框内容。它接受一个 `f32` 类型的参数,表示对话框的淡出程度。建议对对话框的内容的颜色也使用它作为透明度系数进行调节,以实现更好的视觉效果。
38+
39+
## 预览
40+
41+
<video autoplay loop muted>
42+
43+
<source src="/dialog_example.mp4" type="video/mp4">
44+
Your browser does not support the video tag
45+
</video>

0 commit comments

Comments
 (0)