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: Added PageView widget parser in mirai widget parsers #239

Merged
merged 3 commits into from
Jan 18, 2024
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
31 changes: 31 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,37 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "table_chart"
},
"title": {
"type": "text",
"data": "Mirai PageView",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design widget that displays a horizontal row of pages",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/page_view_example.json"
}
}
},
{
"type": "listTile",
"leading": {
Expand Down
60 changes: 60 additions & 0 deletions examples/mirai_gallery/assets/json/page_view_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "PageView"
}
},
"body": {
"type": "pageView",
"children": [
{
"type": "container",
"color": "#D9D9D9",
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Page 1",
"style": {
"fontSize": 23,
"fontWeight": "w400"
}
}
}
},
{
"type": "container",
"color": "#FC3F1B",
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Page 2",
"style": {
"fontSize": 23,
"fontWeight": "w400"
}
}
}
},
{
"type": "container",
"color": "#D9D9D9",
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Page 3",
"style": {
"fontSize": 23,
"fontWeight": "w400"
}
}
}
}
]
}
}
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 @@ -68,6 +68,7 @@ class Mirai {
const MiraiSafeAreaParser(),
const MiraiSwitchParser(),
const MiraiAlignParser(),
const MiraiPageViewParser(),
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/mirai.dart';

export 'package:mirai/src/parsers/mirai_page_view/mirai_page_view_parser.dart';

part 'mirai_page_view.freezed.dart';
part 'mirai_page_view.g.dart';

@freezed
class MiraiPageView with _$MiraiPageView {
const factory MiraiPageView({
@Default(Axis.horizontal) Axis scrollDirection,
@Default(false) bool reverse,
MiraiScrollPhysics? physics,
@Default(true) bool pageSnapping,
Map<String, dynamic>? onPageChanged,
@Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior,
@Default(false) bool allowImplicitScrolling,
String? restorationId,
@Default(Clip.hardEdge) Clip clipBehavior,
@Default(true) bool padEnds,
@Default(0) int initialPage,
@Default(true) keepPage,
@Default(1.0) double viewportFraction,
@Default([]) List<Map<String, dynamic>> children,
}) = _MiraiPageView;

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