Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions website/docs/actions/dialog..md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Dialog Action

The `MiraiDialogAction` class is used to display a dialog in Mirai applications.

## Properties

| Property | Type | Description |
|------------------------|-------------------------------|-----------------------------------------------------------------------------|
| widget | `Map<String, dynamic>?` | The widget to display inside the dialog. |
| request | `MiraiNetworkRequest?` | The network request to perform before displaying the dialog. |
| assetPath | `String?` | The asset path of the widget to display inside the dialog. |
| barrierDismissible | `bool` | Whether the dialog is dismissible by tapping outside. Defaults to `true`. |
| barrierColor | `String?` | The color of the modal barrier. |
| barrierLabel | `String?` | The semantic label for the modal barrier. |
| useSafeArea | `bool` | Whether to use the safe area. Defaults to `true`. |
| traversalEdgeBehavior | `TraversalEdgeBehavior?` | The traversal edge behavior of the dialog. |

## Example JSON

### Dialog with a Widget JSON

```json
{
"actionType": "showDialog",
"widget": {
"type": "text",
"data": "Hello, World!"
}
}
```

### Dialog with a Request JSON

```json
{
"actionType": "showDialog",
"request": {
"url": "https://example.com/api",
"method": "get"
}
}
```

### Dialog with an Asset JSON

```json
{
"actionType": "showDialog",
"assetPath": "assets/dialog.json"
}
```
34 changes: 34 additions & 0 deletions website/docs/actions/form_validate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Form Validate Action

The `MiraiFormValidateAction` class is used to validate a form in Mirai applications.

## Properties

| Property | Type | Description |
|-------------|-------------------------|-----------------------------------------------------------------------------|
| isValid | `Map<String, dynamic>` | The action to perform if the form is valid. |
| isNotValid | `Map<String, dynamic>` | The action to perform if the form is not valid. |

## Example JSON

### Form Validate Action JSON

```json
{
"actionType": "validateForm",
"isValid": {
"actionType": "showDialog",
"widget": {
"type": "text",
"data": "Form is valid!"
}
},
"isNotValid": {
"actionType": "showDialog",
"widget": {
"type": "text",
"data": "Form is not valid!"
}
}
}
```
20 changes: 20 additions & 0 deletions website/docs/actions/get_form_value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Get Form Value Action

The `MiraiGetFormValueAction` class is used to retrieve a form value in Mirai applications.

## Properties

| Property | Type | Description |
|-----------|----------|------------------------------------|
| id | `String` | The ID of the form field to get. |

## Example JSON

### Get Form Value Action JSON

```json
{
"actionType": "getFormValue",
"id": "username"
}
```
83 changes: 83 additions & 0 deletions website/docs/actions/modal_bottom_sheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Modal Bottom Sheet Action

The `MiraiModalBottomSheetAction` class is used to display a modal bottom sheet in Mirai applications.

## Properties

| Property | Type | Description |
|---------------------|-------------------------------|-----------------------------------------------------------------------------|
| widget | `Map<String, dynamic>?` | The widget to display inside the modal bottom sheet. |
| request | `MiraiNetworkRequest?` | The network request to perform before displaying the modal bottom sheet. |
| assetPath | `String?` | The asset path of the widget to display inside the modal bottom sheet. |
| backgroundColor | `String?` | The background color of the modal bottom sheet. |
| barrierLabel | `String?` | The semantic label for the modal barrier. |
| elevation | `double?` | The elevation of the modal bottom sheet. |
| shape | `MiraiBorder?` | The shape of the modal bottom sheet. |
| constraints | `MiraiBoxConstraints?` | The constraints for the modal bottom sheet. |
| barrierColor | `String?` | The color of the modal barrier. |
| isScrollControlled | `bool` | Whether the modal bottom sheet is scroll controlled. Defaults to `false`. |
| useRootNavigator | `bool` | Whether to use the root navigator. Defaults to `false`. |
| isDismissible | `bool` | Whether the modal bottom sheet is dismissible. Defaults to `true`. |
| enableDrag | `bool` | Whether the modal bottom sheet can be dragged. Defaults to `true`. |
| showDragHandle | `bool?` | Whether to show a drag handle on the modal bottom sheet. |
| useSafeArea | `bool` | Whether to use the safe area. Defaults to `false`. |

## Example JSON

### Modal Bottom Sheet with a Widget JSON

```json
{
"actionType": "showModalBottomSheet",
"widget": {
"type": "container",
"height": 200,
"color": "amber",
"child": {
"type": "center",
"child": {
"type": "column",
"mainAxisAlignment": "center",
"mainAxisSize": "min",
"children": [
{
"type": "text",
"data": "Modal BottomSheet"
},
{
"type": "elevatedButton",
"child": {
"type": "text",
"data": "Close BottomSheet"
},
"onPressed": {
"actionType": "pop"
}
}
]
}
}
}
}
```

### Modal Bottom Sheet with an Asset Path

```json
{
"actionType": "showModalBottomSheet",
"assetPath": "assets/widgets/modal_bottom_sheet.json"
}
```

### Modal Bottom Sheet with a Network Request

```json
{
"actionType": "showModalBottomSheet",
"request": {
"url": "https://example.com/api",
"method": "get"
}
}
```
93 changes: 93 additions & 0 deletions website/docs/actions/navigate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Navigate Action

The Mirai Navigate Action allows you to perform navigation actions in a Flutter application using JSON.
To know more about navigation in Flutter, refer to the [official documentation](https://api.flutter.dev/flutter/widgets/Navigator-class.html).

## Properties

| Property | Type | Description |
|------------------|-------------------------|-----------------------------------------------------------------------------|
| request | `MiraiNetworkRequest?` | The network request to perform before navigation. |
| widgetJson | `Map<String, dynamic>?` | The JSON representation of the widget to navigate to. |
| assetPath | `String?` | The asset path of the widget to navigate to. |
| routeName | `String?` | The name of the route to navigate to. |
| navigationStyle | `NavigationStyle?` | The style of navigation (e.g., push, pop, pushReplacement, etc.). |
| result | `Map<String, dynamic>?` | The result to return when popping the route. |
| arguments | `Map<String, dynamic>?` | The arguments to pass to the route. |


### NavigationStyle

The `NavigationStyle` enum defines the different styles of navigation that can be used in the Mirai Navigate Action.

| Value | Description |
|-------------------------|-----------------------------------------------------------|
| `push` | Pushes a new route onto the navigator stack. |
| `pop` | Pops the current route off the navigator stack. |
| `pushReplacement` | Replaces the current route with a new route. |
| `pushAndRemoveAll` | Pushes a new route and removes all the previous routes. |
| `popAll` | Pops all the routes off the navigator stack. |
| `pushNamed` | Pushes a named route onto the navigator stack. |
| `pushNamedAndRemoveAll` | Pushes a named route and removes all the previous routes. |
| `pushReplacementNamed` | Replaces the current route with a named route. |

## Example JSON

### Navigate with a Network Request

```json
{
"actionType": "navigate",
"request": {
"url": "https://example.com/api",
"method": "get"
},
"navigationStyle": "push"
}
```

### Navigate with a Widget JSON

```json
{
"actionType": "navigate",
"widgetJson": {
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "My App"
}
},
"body": {
"type": "center",
"child": {
"type": "text",
"data": "Hello, World!"
}
}
},
"navigationStyle": "push"
}
```

### Navigate with an Asset Path

```json
{
"actionType": "navigate",
"assetPath": "assets/widgets/my_widget.json",
"navigationStyle": "push"
}
```

### Navigate with a Route Name

```json
{
"actionType": "navigate",
"routeName": "/home",
"navigationStyle": "pushNamed"
}
```
69 changes: 69 additions & 0 deletions website/docs/actions/network_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Network Request Action

The `NetworkRequestAction` class is used to make network requests in Mirai applications.

## Properties

| Property | Type | Description |
|-----------------|----------------------------|----------------------------------------------------------------------------------|
| url | `String` | The URL to which the request is sent. |
| method | `Method` | The HTTP method to use for the request. Defaults to `Method.get`. |
| queryParameters | `Map<String, dynamic>?` | The query parameters to include in the request URL. |
| headers | `Map<String, dynamic>?` | The headers to include in the request. |
| contentType | `String?` | The content type of the request. |
| body | `dynamic` | The body of the request. |
| results | `List<MiraiNetworkResult>` | The list of results to handle different status codes. Defaults to an empty list. |

### Method

The `Method` enum defines the different HTTP methods that can be used in the Mirai Network Request Action.

| Value | Description |
|----------|-------------------------|
| `get` | Sends a GET request. |
| `post` | Sends a POST request. |
| `put` | Sends a PUT request. |
| `delete` | Sends a DELETE request. |

### MiraiNetworkResult

The `MiraiNetworkResult` class is used to handle different status codes in the Mirai Network Request Action.

| Property | Type | Description |
|------------|----------|---------------------------------------------------------|
| statusCode | `int` | The status code to handle. |
| action | `Action` | The action to perform when the status code is received. |

## Example JSON

```json
{
"actionType": "networkRequest",
"url": "https://example.com/api",
"method": "get",
"queryParameters": {
"page": 1
},
"headers": {
"Authorization": "Bearer token"
},
"contentType": "application/json",
"body": {
"data": "example"
},
"results": [
{
"statusCode": 200,
"action": {
"actionType": "none"
}
},
{
"statusCode": 404,
"action": {
"actionType": "none"
}
}
]
}
```
11 changes: 11 additions & 0 deletions website/docs/actions/none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# None Action

A default action that does nothing.

## Example JSON

```json
{
"actionType": "none"
}
```