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: Mirai Grid View #262

Merged
merged 4 commits into from
Feb 24, 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
227 changes: 227 additions & 0 deletions examples/mirai_gallery/assets/json/grid_view_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Grid View Example"
}
},
"body": {
"type": "padding",
"padding": {
"left": 10,
"top": 10,
"right": 10,
"bottom": 10
},
"child": {
"type": "gridView",
"crossAxisCount": 2,
"crossAxisSpacing": 10.0,
"mainAxisSpacing": 10.0,
"children": [
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#FFCDD2",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 1",
"style": {
"color": "#B71C1C"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#C8E6C9",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 2",
"style": {
"color": "#1B5E20"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#BBDEFB",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 3",
"style": {
"color": "#0D47A1"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#FFF9C4",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 4",
"style": {
"color": "#F57F17"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#FFCCBC",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 5",
"style": {
"color": "#BF360C"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#B2EBF2",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 6",
"style": {
"color": "#006064"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#F8BBD0",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 7",
"style": {
"color": "#880E4F"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#D1C4E9",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 8",
"style": {
"color": "#311B92"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#C5CAE9",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 9",
"style": {
"color": "#1A237E"
}
}
}
},
{
"type": "container",
"decoration": {
"type": "boxDecoration",
"color": "#FFE0B2",
"borderRadius": {
"all": 8.0
}
},
"child": {
"type": "center",
"child": {
"type": "text",
"data": "Item 10",
"style": {
"color": "#E65100"
}
}
}
}
]
}
}
}
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 @@ -889,6 +889,37 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "grid_view"
},
"title": {
"type": "text",
"data": "Mirai GridView",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A scrollable, 2D array of widgets that are created on demand.",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/grid_view_example.json"
}
}
},
{
"type": "listTile",
"leading": {
Expand Down
2 changes: 1 addition & 1 deletion examples/mirai_gallery/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 @@ -64,6 +64,7 @@ class Mirai {
const MiraiRefreshIndicatorParser(),
const MiraiNetworkWidgetParser(),
const MiraiCircleAvatarParser(),
const MiraiGridViewParser(),
];

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

export 'mirai_grid_view_parser.dart';

part 'mirai_grid_view.freezed.dart';
part 'mirai_grid_view.g.dart';

@freezed
class MiraiGridView with _$MiraiGridView {
const factory MiraiGridView({
@Default(Axis.vertical) Axis scrollDirection,
@Default(false) bool reverse,
@Default(false) bool primary,
MiraiScrollPhysics? physics,
@Default(false) bool shrinkWrap,
MiraiEdgeInsets? padding,
int? crossAxisCount,
@Default(0.0) double mainAxisSpacing,
@Default(0.0) double crossAxisSpacing,
@Default(1.0) double childAspectRatio,
double? mainAxisExtent,
@Default(true) bool addAutomaticKeepAlives,
@Default(true) bool addRepaintBoundaries,
@Default(true) bool addSemanticIndexes,
double? cacheExtent,
@Default([]) List<Map<String, dynamic>> children,
int? semanticChildCount,
@Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior,
@Default(ScrollViewKeyboardDismissBehavior.manual)
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior,
String? restorationId,
@Default(Clip.hardEdge) Clip clipBehavior,
}) = _MiraiGridView;

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