Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : Adding AspectRatio, FittedBox, LimitedBox Widgets #120

Merged
merged 21 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from 19 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
39 changes: 39 additions & 0 deletions examples/mirai_gallery/assets/json/aspect_ratio_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "AspectRatio"
}
},
"body": {
"type": "padding",
"padding": {
"top": 12,
"left": 12,
"right": 12
},
"child": {
"type": "column",
"mainAxisAlignment": "start",
"crossAxisAlignment": "start",
"children": [
{
"type": "sizedBox",
"height": 12
},
{
"type": "aspectRatio",
"aspectRatio": 1.33,
"child": {
"type": "container",
"color": "#FF5733",
"width": 100,
"height": 100
}
}
]
}
}
}
42 changes: 42 additions & 0 deletions examples/mirai_gallery/assets/json/fitted_box_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "FittedBox"
}
},
"body": {
"type": "padding",
"padding": {
"top": 12,
"left": 12,
"right": 12
},
"child": {
"type": "column",
"mainAxisAlignment": "start",
"crossAxisAlignment": "start",
"children": [
{
"type": "sizedBox",
"height": 12
},
{
"type": "fittedBox",
"fit": "contain",
"alignment": "center",
"child": {
"type": "text",
"data": "Hello, World!",
"style": {
"fontSize": 20,
"color": "#000000"
}
}
}
]
}
}
}
134 changes: 134 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,140 @@
"behavior": "floating"
}
},

{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "apartment"
},

"title": {
"type": "text",
"data": "Mirai AspectRatio",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design Mirai AspectRatio widget",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/aspect_ratio_example.json"
}
}
},

{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "apartment"
},

"title": {
"type": "text",
"data": "Mirai FittedBox",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design Mirai FittedBox widget",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/fitted_box_example.json"
}
}
},

{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "apartment"
},

"title": {
"type": "text",
"data": "Mirai LimitedBox",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design Mirai LimitedBox widget",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/limited_box_example.json"
}
}
},

{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "visibility"
},

"title": {
"type": "text",
"data": "Mirai Visibility",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design Mirai Visibility widget",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/visibility_example.json"
}
}
},


{
"type": "sizedBox",
"height": 24.0
Expand Down
40 changes: 40 additions & 0 deletions examples/mirai_gallery/assets/json/limited_box_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "LimitedBox"
}
},
"body": {
"type": "listView",
"shrinkWrap": true,
"children": [
{
"type": "sizedBox",
"height": 25
},

{
"type": "limitedBox",
"child": {
"type": "container",
"height": 100,
"color": "#FF0000",
"child": {
"type": "text",
"data": "Hello, World! from Limited Box",
"style": {
"fontSize": 16,
"color": "#000000"
}
}

}
}


]
}
}
46 changes: 46 additions & 0 deletions examples/mirai_gallery/assets/json/visibility_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Visibility"
}
},
"body": {
"type": "listView",
"shrinkWrap": true,
"children": [
{
"type": "sizedBox",
"height": 25
},
{
"type": "visibility",
"child": {
"type": "text",
"data": "I am visible!"
},
"visible": true
},
{
"type": "sizedBox",
"height": 25
},
{
"type": "visibility",
"child": {
"type": "text",
"data": "I am hidden!"
},
"replacement": {
"type": "container",
"color": "#FF5733",
"width": 50,
"height": 50
},
"visible": false
}
]
}
}
4 changes: 4 additions & 0 deletions packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class Mirai {
const MiraiSliderParser(),
const MiraiOpacityParser(),
const MiraiPlaceholderParser(),
const MiraiAspectRatioParser(),
const MiraiFittedBoxParser(),
const MiraiLimitedBoxParser(),
const MiraiVisibilityParser()
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';
export 'package:mirai/src/parsers/mirai_aspect_ratio/mirai_aspect_ratio_parser.dart';

part 'mirai_aspect_ratio.freezed.dart';
part 'mirai_aspect_ratio.g.dart';

@freezed
class MiraiAspectRatio with _$MiraiAspectRatio {
const factory MiraiAspectRatio({
@Default(1) double aspectRatio,
Map<String, dynamic>? child,
}) = _MiraiAspectRatio;

factory MiraiAspectRatio.fromJson(Map<String, dynamic> json) =>
_$MiraiAspectRatioFromJson(json);
}
Loading
Loading