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
127 changes: 127 additions & 0 deletions examples/mirai_gallery/assets/json/hero_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Hero Example"
}
},
"body": {
"type": "center",
"child": {
"type": "column",
"mainAxisAlignment": "center",
"children": [
{
"type": "hero",
"tag": "hero-icon",
"createRectTween": {
"type": "materialRectArcTween",
"begin": {
"rectType": "fromCenter",
"center": {
"dx": 120.0,
"dy": 140.0
},
"width": 100.0,
"height": 100.0
},
"end": {
"rectType": "fromCenter",
"center": {
"dx": 200.0,
"dy": 200.0
},
"width": 50.0,
"height": 50.0
}
},
"child": {
"type": "icon",
"iconType": "material",
"icon": "flight_takeoff",
"size": 150.0
}
},
{
"type": "sizedBox",
"height": 24.0
},
{
"type": "textButton",
"child": {
"type": "text",
"data": "Tap to see Hero Animation"
},
"onPressed": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Flight Details"
}
},
"body": {
"type": "center",
"child": {
"type": "column",
"mainAxisAlignment": "center",
"children": [
{
"type": "hero",
"tag": "hero-icon",
"createRectTween": {
"type": "materialRectArcTween",
"begin": {
"rectType": "fromCenter",
"center": {
"dx": 120.0,
"dy": 140.0
},
"width": 100.0,
"height": 100.0
},
"end": {
"rectType": "fromCenter",
"center": {
"dx": 200.0,
"dy": 200.0
},
"width": 50.0,
"height": 50.0
}
},
"child": {
"type": "icon",
"iconType": "material",
"icon": "flight_takeoff",
"size": 50.0
}
},
{
"type": "sizedBox",
"height": 16.0
},
{
"type": "text",
"data": "Flight AB123",
"style": {
"fontSize": 24.0,
"fontWeight": "w500"
}
}
]
}
}
}
}
}
]
}
}
}
34 changes: 34 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,40 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "flight_takeoff"
},
"title": {
"type": "text",
"data": "Mirai Hero",
"align": "center",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Hero Widget",
"align": "center",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"style": "list",
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/hero_example.json"
}
}
},
{
"type": "sizedBox",
"height": 24.0
Expand Down
1 change: 1 addition & 0 deletions packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Mirai {
const MiraiDividerParser(),
const MiraiCircularProgressIndicatorParser(),
const MiraiLinearProgressIndicatorParser(),
const MiraiHeroParser(),
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
21 changes: 21 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween.dart';
export 'package:mirai/src/parsers/mirai_hero/mirai_hero_parser.dart';

part 'mirai_hero.freezed.dart';
part 'mirai_hero.g.dart';

@freezed
class MiraiHero with _$MiraiHero {
const factory MiraiHero({
required Object tag,
required Map<String, dynamic> child,
MiraiRectTween? createRectTween,
Map<String, dynamic>? flightShuttleBuilder,
Map<String, dynamic>? placeholderBuilder,
@Default(false) bool transitionOnUserGestures,
}) = _MiraiHero;

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