Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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"
}
}
}
]
}
}
}
101 changes: 101 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,107 @@
"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": "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"
}
}

}
}


]
}
}
3 changes: 3 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,9 @@ class Mirai {
const MiraiSliderParser(),
const MiraiOpacityParser(),
const MiraiPlaceholderParser(),
const MiraiAspectRatioParser(),
const MiraiFittedBoxParser(),
const MiraiLimitedBoxParser(),
];

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