Skip to content

Commit

Permalink
Merge pull request #239 from Securrency-OSS/asim/page-view
Browse files Browse the repository at this point in the history
feat: Added `PageView` widget parser in `mirai` widget parsers
  • Loading branch information
divyanshub024 authored Jan 18, 2024
2 parents 71c7f8e + 13055e4 commit b352381
Show file tree
Hide file tree
Showing 9 changed files with 738 additions and 1 deletion.
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

0 comments on commit b352381

Please sign in to comment.