Skip to content

Commit

Permalink
Merge pull request #1 from Securrency-OSS/main
Browse files Browse the repository at this point in the history
Mirai State Management
  • Loading branch information
iampranabray authored May 6, 2024
2 parents b1a0a14 + 2e75287 commit ce3e49d
Show file tree
Hide file tree
Showing 34 changed files with 1,371 additions and 970 deletions.
6 changes: 1 addition & 5 deletions examples/mirai_gallery/assets/json/container_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
{
"type": "container",
"color": "#672BFF",
"clipBehavior": "hardEdge",
"height": 250,
"width": 200,
"decoration": {
}
"width": 200
},
{
"type": "sizedBox",
Expand All @@ -32,7 +29,6 @@
{
"type": "container",
"color": "#FC5632",
"clipBehavior": "hardEdge",
"height": 250,
"width": 200,
"child": {
Expand Down
17 changes: 6 additions & 11 deletions examples/mirai_gallery/assets/json/switch_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,27 @@
"crossAxisAlignment": "center",
"children": [
{
"type": "switchButton",
"type": "switch",
"switchType": "cupertino",
"initialValue": true,
"onChanged": {}
"value": true
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "switchButton",
"type": "switch",
"switchType": "adaptive",
"initialValue": false,
"onChanged": {},
"inActiveColor": "#FF0000",
"activeColor": "#0000FF"
"value": true
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "switchButton",
"type": "switch",
"switchType": "material",
"initialValue": false,
"onChanged": {}
"value": false
}
]
},
Expand Down
7 changes: 1 addition & 6 deletions examples/mirai_gallery/assets/json/text_field_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,7 @@
"labelText": "Gradient TextField",
"border": {
"type": "outlineInputBorder",
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
},
"borderRadius": 80,
"gradient": {
"colors": [
"#FF0000",
Expand Down
11 changes: 11 additions & 0 deletions packages/mirai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.7.0

* Added support for new widgets: CircleAvatar, GridView, Chip, Wrap & FilledButton
* Rename scrollView to SingleChildScrollView
* Added defaultBottomNavigationController & bottomNavigationView
* A new and better way to define Mirai Network Request & Network Result
* Revamp Mirai Form to add form validation, getting form values and submitting Form
* Use app text theme in text styles
* A new way to declare EdgeInsets & BorderRadius
* A lot of enhancement, refactoring and bug fixes

## 0.6.0

* chore: update readme by @divyanshub024 in https://github.com/Securrency-OSS/mirai/pull/210
Expand Down
2 changes: 1 addition & 1 deletion packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Mirai {
const MiraiCircleAvatarParser(),
const MiraiChipParser(),
const MiraiGridViewParser(),
const MiraiFilledButtonParser()
const MiraiFilledButtonParser(),
const MiraiBottomNavigationViewParser(),
const MiraiDefaultBottomNavigationControllerParser(),
const MiraiWrapParser(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,37 @@ class MiraiBorderRadius with _$MiraiBorderRadius {
@Default(0.0) double bottomRight,
}) = _MiraiBorder;

factory MiraiBorderRadius.fromJson(Map<String, dynamic> json) =>
_$MiraiBorderRadiusFromJson(json);
factory MiraiBorderRadius.fromJson(dynamic json) => _fromJson(json);

static MiraiBorderRadius _fromJson(dynamic json) {
Map<String, dynamic> resultantJson;

if (json is num) {
resultantJson = {
"topLeft": json,
"topRight": json,
"bottomLeft": json,
"bottomRight": json
};
} else if (json is List<dynamic> && json.length == 4) {
bool allElementsNum = json.every((element) => element is num);
if (!allElementsNum) {
throw ArgumentError('Invalid input format for MiraiEdgeInsets');
}
resultantJson = {
"topLeft": json[0],
"topRight": json[1],
"bottomLeft": json[2],
"bottomRight": json[3]
};
} else if (json is Map<String, dynamic>) {
resultantJson = json;
} else {
throw ArgumentError('Invalid input format for MiraiEdgeInsets');
}

return _$MiraiBorderRadiusFromJson(resultantJson);
}
}

extension MiraiBorderRadiusParser on MiraiBorderRadius? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/mirai_border/mirai_border.dart';
import 'package:mirai/src/parsers/mirai_border_radius/mirai_border_radius.dart';
import 'package:mirai/src/parsers/mirai_box_shadow/mirai_box_shadow.dart';
import 'package:mirai/src/parsers/mirai_container_image/mirai_container_image.dart';
import 'package:mirai/src/parsers/mirai_decoration_image/mirai_decoration_image.dart';
import 'package:mirai/src/parsers/mirai_gradient/mirai_gradient.dart';
import 'package:mirai/src/utils/color_utils.dart';

Expand All @@ -14,13 +14,12 @@ part 'mirai_box_decoration.g.dart';
class MiraiBoxDecoration with _$MiraiBoxDecoration {
const factory MiraiBoxDecoration({
String? color,
@Default(BorderStyle.none) BorderStyle borderStyle,
BlendMode? blendMode,
BlendMode? backgroundBlendMode,
List<MiraiBoxShadow?>? boxShadow,
@Default(BoxShape.rectangle) BoxShape shape,
MiraiBorder? border,
MiraiBorderRadius? borderRadius,
MiraiContainerImage? image,
MiraiDecorationImage? image,
MiraiGradient? gradient,
}) = _MiraiBoxDecoration;

Expand All @@ -32,7 +31,7 @@ extension MiraiBoxDecorationParser on MiraiBoxDecoration? {
BoxDecoration? parse(BuildContext context) {
return BoxDecoration(
color: this?.color.toColor(context),
backgroundBlendMode: this?.blendMode,
backgroundBlendMode: this?.backgroundBlendMode,
boxShadow: this?.boxShadow?.map((elem) => elem.parse(context)).toList(),
shape: this?.shape ?? BoxShape.rectangle,
border: this?.border?.parse(context),
Expand Down
Loading

0 comments on commit ce3e49d

Please sign in to comment.