From e54b15600573c9fb80e7c9d6a053a97362971266 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Tue, 19 Sep 2023 13:20:12 +0400 Subject: [PATCH 1/3] Added readme for mirai_framework --- packages/mirai_framework/README.md | 93 +++++++++++++++++++++- packages/mirai_framework/example/README.md | 80 +++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 packages/mirai_framework/example/README.md diff --git a/packages/mirai_framework/README.md b/packages/mirai_framework/README.md index e54c51e1..af10ecc6 100644 --- a/packages/mirai_framework/README.md +++ b/packages/mirai_framework/README.md @@ -1,3 +1,94 @@ # Mirai Framework -A local package containing Mirai framework files \ No newline at end of file +A Framework that contains parsers for widgets and actions in `Mirai`. + +## Installation 🚀 + +First, we need to add Mirai Framework to our pubspec.yaml file. + +Install the plugin by running the following command from the project root: + +```bash +flutter pub add mirai_framework +``` + +## Usage + +1. Import `mirai_framework.dart` at the top of your parser file. + +```dart + import 'package:mirai_framework/mirai_framework.dart'; +``` + +2. Initialize your custom parser for a widget or an action and extend it from `MiraiParser` or `MiraiActionParser` like this. + + a. Let's say we are initializing a widget parser. + + + ```dart + class MiraiWidgetPraser extends MiraiParser { + ... + } + + // define `MyCustomWidget` + + @freezed + class MyCustomWidget with _$MyCustomWidget { ... } + ``` + + b. Let's say we are initializing an action parser. + + ```dart + class MiraiActionPraser extends MiraiActionParser { + ... + } + ``` + +3. Now implement the required methods in your custom parser. + + a. Let's say we are building a widget parser. + + ```dart + class MiraiWidgetPraser extends MiraiParser { + @override + MyCustomWidget getModel(Map json) { + // TODO: implement getModel + throw UnimplementedError(); + } + + @override + Widget parse(BuildContext context, MyCustomWidget model) { + // TODO: implement parse + throw UnimplementedError(); + } + + @override + // TODO: implement type + String get type => throw UnimplementedError(); + + } + + ``` + + a. Let's say we are building an action parser. + + ```dart + class MiraiActionPraser extends MiraiActionParser { + @override + // TODO: implement actionType + String get actionType => throw UnimplementedError(); + + @override + getModel(Map json) { + // TODO: implement getModel + throw UnimplementedError(); + } + + @override + FutureOr onCall(BuildContext context, model) { + // TODO: implement onCall + throw UnimplementedError(); + } + } + + ``` \ No newline at end of file diff --git a/packages/mirai_framework/example/README.md b/packages/mirai_framework/example/README.md new file mode 100644 index 00000000..37cff56a --- /dev/null +++ b/packages/mirai_framework/example/README.md @@ -0,0 +1,80 @@ +## Example + +1. Import `mirai_framework.dart` at the top of your parser file. + +```dart + import 'package:mirai_framework/mirai_framework.dart'; +``` + +2. Initialize your custom parser for a widget or an action and extend it from `MiraiParser` or `MiraiActionParser` like this. + + a. Let's say we are initializing a widget parser. + + + ```dart + class MiraiWidgetPraser extends MiraiParser { + ... + } + + // define `MyCustomWidget` + + @freezed + class MyCustomWidget with _$MyCustomWidget { ... } + ``` + + b. Let's say we are initializing an action parser. + + ```dart + class MiraiActionPraser extends MiraiActionParser { + ... + } + ``` + +3. Now implement the required methods in your custom parser. + + a. Let's say we are building a widget parser. + + ```dart + class MiraiWidgetPraser extends MiraiParser { + @override + MyCustomWidget getModel(Map json) { + // TODO: implement getModel + throw UnimplementedError(); + } + + @override + Widget parse(BuildContext context, MyCustomWidget model) { + // TODO: implement parse + throw UnimplementedError(); + } + + @override + // TODO: implement type + String get type => throw UnimplementedError(); + + } + + ``` + + a. Let's say we are building an action parser. + + ```dart + class MiraiActionPraser extends MiraiActionParser { + @override + // TODO: implement actionType + String get actionType => throw UnimplementedError(); + + @override + getModel(Map json) { + // TODO: implement getModel + throw UnimplementedError(); + } + + @override + FutureOr onCall(BuildContext context, model) { + // TODO: implement onCall + throw UnimplementedError(); + } + } + + ``` \ No newline at end of file From 174da0ec058f38a2065bdcdd595f6427b7684f20 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Tue, 19 Sep 2023 13:35:05 +0400 Subject: [PATCH 2/3] Update README.md --- packages/mirai/README.md | 2 +- packages/mirai_framework/README.md | 29 ++++++++++++++-------- packages/mirai_framework/example/README.md | 24 +++++++++--------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/packages/mirai/README.md b/packages/mirai/README.md index 253236a2..b4be7c75 100644 --- a/packages/mirai/README.md +++ b/packages/mirai/README.md @@ -411,4 +411,4 @@ Check out the [Mirai Gallery](https://github.com/Securrency-OSS/mirai/tree/main/ [securrency_link]: https://securrency.com [form_screen]: https://github.com/Securrency-OSS/mirai/blob/main/assets/form_screen_image.png [divyanshu_github]: https://github.com/divyanshub024 -[aasim_github]: https://github.com/iamasimkhan +[aasim_github]: https://github.com/i-asimkhan diff --git a/packages/mirai_framework/README.md b/packages/mirai_framework/README.md index af10ecc6..39799bfb 100644 --- a/packages/mirai_framework/README.md +++ b/packages/mirai_framework/README.md @@ -1,6 +1,13 @@ # Mirai Framework -A Framework that contains parsers for widgets and actions in `Mirai`. +The Mirai Framework package contains the framework files for (Mirai)[https://github.com/Securrency-OSS/mirai], such as MiraiParser and MiraiActionParser. These classes provide a simple way to create custom parsers for widgets and actions in Mirai. This can be useful for extending the functionality of Mirai or for implementing custom widgets and actions. + +Here are some examples of how the Mirai Framework package can be used: + +- Create a custom parser for a new widget that is not supported by Mirai out of the box. +- Create a custom parser for a widget that has additional functionality, such as the ability to handle user input. +- Create a custom action parser to handle a new type of action, such as sending a message to a remote server. +- Create a custom action parser to handle an existing action in a different way, such as logging the action before it is executed. ## Installation 🚀 @@ -22,18 +29,19 @@ flutter pub add mirai_framework 2. Initialize your custom parser for a widget or an action and extend it from `MiraiParser` or `MiraiActionParser` like this. + ```dart + // define `MyCustomWidget` + + @freezed + class MyCustomWidget with _$MyCustomWidget { ... } + ``` + a. Let's say we are initializing a widget parser. - ```dart class MiraiWidgetPraser extends MiraiParser { ... } - - // define `MyCustomWidget` - - @freezed - class MyCustomWidget with _$MyCustomWidget { ... } ``` b. Let's say we are initializing an action parser. @@ -49,7 +57,7 @@ flutter pub add mirai_framework a. Let's say we are building a widget parser. ```dart - class MiraiWidgetPraser extends MiraiParser { + class MiraiWidgetParser extends MiraiParser { @override MyCustomWidget getModel(Map json) { // TODO: implement getModel @@ -70,7 +78,7 @@ flutter pub add mirai_framework ``` - a. Let's say we are building an action parser. + b. Let's say we are building an action parser. ```dart class MiraiActionPraser extends MiraiActionParser { @@ -90,5 +98,4 @@ flutter pub add mirai_framework throw UnimplementedError(); } } - - ``` \ No newline at end of file + ``` diff --git a/packages/mirai_framework/example/README.md b/packages/mirai_framework/example/README.md index 37cff56a..79220b94 100644 --- a/packages/mirai_framework/example/README.md +++ b/packages/mirai_framework/example/README.md @@ -8,21 +8,22 @@ 2. Initialize your custom parser for a widget or an action and extend it from `MiraiParser` or `MiraiActionParser` like this. - a. Let's say we are initializing a widget parser. + ```dart + // define `MyCustomWidget` + + @freezed + class MyCustomWidget with _$MyCustomWidget { ... } + ``` + a. Let's say we are initializing a widget parser. ```dart class MiraiWidgetPraser extends MiraiParser { ... } - - // define `MyCustomWidget` - - @freezed - class MyCustomWidget with _$MyCustomWidget { ... } ``` - b. Let's say we are initializing an action parser. + b. Let's say we are initializing an action parser. ```dart class MiraiActionPraser extends MiraiActionParser { @@ -32,10 +33,10 @@ 3. Now implement the required methods in your custom parser. - a. Let's say we are building a widget parser. + a. Let's say we are building a widget parser. ```dart - class MiraiWidgetPraser extends MiraiParser { + class MiraiWidgetParser extends MiraiParser { @override MyCustomWidget getModel(Map json) { // TODO: implement getModel @@ -56,7 +57,7 @@ ``` - a. Let's say we are building an action parser. + b. Let's say we are building an action parser. ```dart class MiraiActionPraser extends MiraiActionParser { @@ -76,5 +77,4 @@ throw UnimplementedError(); } } - - ``` \ No newline at end of file + ``` From 4b5d97f767a61cdb11430bd8b8d5aef455c19a3a Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Tue, 19 Sep 2023 13:35:30 +0400 Subject: [PATCH 3/3] Update pubspec for Mirai_framework --- packages/mirai_framework/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mirai_framework/pubspec.yaml b/packages/mirai_framework/pubspec.yaml index 85ad8e6f..48cced70 100644 --- a/packages/mirai_framework/pubspec.yaml +++ b/packages/mirai_framework/pubspec.yaml @@ -2,7 +2,6 @@ name: mirai_framework description: A local package containing Mirai framework files version: 0.0.1 homepage: https://github.com/Securrency-OSS/mirai -publish_to: none environment: sdk: '>=3.1.0 <4.0.0'