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
478 stars 58 forks source link

feat: Add Mirai Network Request & Network Result #267

Closed divyanshub024 closed 2 months ago

divyanshub024 commented 2 months ago

Description

This PR adds a better and new way for network calls. It also allows users to perform actions from the network call.

            "onPressed": {
              "actionType": "networkRequest",
              "url": "https://demo-identity.securrency.com/connect/token",
              "method": "post",
              "contentType": "application/x-www-form-urlencoded",
              "body": {
                "username": {
                  "actionType": "getFormDataValue",
                  "id": "email"
                },
                "password": {
                  "actionType": "getFormDataValue",
                  "id": "password"
                },
                "client_id": "mobile",
                "scope": "openid email roles profile identity.public identity.admin entity securrency.finance securrency.exchange securrency.ens",
                "grant_type": "mobile"
              },
              "results": [
                {
                  "statusCode": 200,
                  "action": {
                    "actionType": "navigate",
                    "navigationStyle": "pushReplacement",
                    "assetPath": "assets/json/user_profile_screen.json"
                  }
                },
                {
                  "statusCode": 400,
                  "action": {
                    "actionType": "showDialog",
                    "widget": {
                      "type": "alertDialog",
                      "titlePadding": {
                        "top": 8,
                        "left": 12,
                        "right": 12
                      },
                      "contentPadding": {
                        "top": 8,
                        "left": 12,
                        "right": 12
                      },
                      "title": {
                        "type": "text",
                        "data": "Failed to SignIn",
                        "align": "center",
                        "style": {
                          "fontSize": 21
                        }
                      },
                      "content": {
                        "type": "text",
                        "data": "Invalid username or password.",
                        "align": "center",
                        "style": {
                          "fontSize": 14
                        }
                      },
                      "actions": [
                        {
                          "type": "textButton",
                          "child": {
                            "type": "text",
                            "data": "OK"
                          },
                          "onPressed": {
                            "actionType": "navigate",
                            "navigationStyle": "pop"
                          }
                        },
                        {
                          "type": "sizedBox",
                          "width": 12
                        }
                      ]
                    }
                  }
                }

Type of Change