Securrency-OSS / mirai

Mirai is a Server-Driven UI (SDUI) library for Flutter. Mirai allows you to build beautiful cross-platform applications with JSON in real time.
https://pub.dev/packages/mirai
MIT License
490 stars 60 forks source link

feat: Add support to `each` action #179

Open RodolfoSilva opened 10 months ago

RodolfoSilva commented 10 months ago

Description

The idea of this action is to allow the user to perform sequential actions when necessary. For example, when the user clicks on a button, this action should show a toast and send a request to the server. Or copy something to the clipboard and show a dialog.

So we can declare this like that:

{
  "type": "textButton",
  "child": {
    "type": "text",
    "data": "BUTTON"
  },
  "onPressed": {
    "actionType": "each",
    "actions": [
      {
        "actionType": "copyToClipBoard",
        "value": "Some value"
      },
      {
        "actionType": "showToast",
        "value": "Value copied to clipboard"
      },
      {
        "actionType": "vibrate",
        "pattern": [0, 1, 1, 0, 1, 0, 1, 1, 1]
      }
    ]
  }
}

Related Issues

Type of Change

RodolfoSilva commented 10 months ago

This is just a proposal @i-asimkhan, @divyanshub024?

Do you have any suggestions?

i-asimkhan commented 10 months ago

This is just a proposal @i-asimkhan, @divyanshub024?

Do you have any suggestions?

@RodolfoSilva This is a great idea, we really were looking for this. Let's discuss the naming and other stuff.