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: Add support to Chip Widget #263

Merged
merged 6 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
190 changes: 190 additions & 0 deletions examples/mirai_gallery/assets/json/chip_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Chip"
}
},
"body": {
"type": "column",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "chip",
"avatar": {
"type": "icon",
"iconType": "material",
"icon": "tune"
},
"label": {
"type": "text",
"data": "Chip",
"align": "center",
"style": {
"fontSize": 21
}
}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "chip",
"autofocus": true,
"deleteIcon": {
"type": "icon",
"iconType": "material",
"icon": "close",
"size": 20
},
"label": {
"type": "text",
"data": "Chip",
"align": "center",
"style": {
"fontSize": 21
}
}
}
]
},
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "chip",
"avatar": {
"type": "icon",
"iconType": "material",
"icon": "tune"
},
"label": {
"type": "text",
"data": "Round Chip",
"align": "center",
"style": {
"fontSize": 21
}
},
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "chip",
"autofocus": true,
"deleteIcon": {
"type": "icon",
"iconType": "material",
"icon": "close",
"size": 20
},
"label": {
"type": "text",
"data": "Round Chip",
"align": "center",
"style": {
"fontSize": 21
}
},
"elevation": 8,
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
}
]
},
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "chip",
"color": "#6d81b3",
"avatar": {
"type": "icon",
"color": "#ffffff",
"iconType": "material",
"icon": "tune"
},
"label": {
"type": "text",
"data": "Color Chip",
"align": "center",
"style": {
"fontSize": 21,
"color": "#ffffff"
}
},
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "chip",
"color": "#6d81b3",
"deleteIcon": {
"type": "icon",
"color": "#ffffff",
"iconType": "material",
"icon": "close",
"size": 20
},
"label": {
"type": "text",
"data": "Color Chip",
"align": "center",
"style": {
"color": "#ffffff",
"fontSize": 21
}
},
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
}
]
}
]
}
}
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 @@ -1111,6 +1111,40 @@
"assetPath": "assets/json/web_view_example.json"
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "check_box_outline_blank"
},
"title": {
"type": "text",
"data": "Chip",
"align": "center",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "Chips are compact elements that represent an attribute, text, entity, or action",
"align": "center",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"style": "list",
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/chip_example.json"
}
}
}
]
}
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 MiraiChipParser(),
const MiraiGridViewParser(),
];

Expand Down
37 changes: 37 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart';
import 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart';
import 'package:mirai/src/parsers/mirai_border_side/mirai_border_side.dart';
import 'package:mirai/src/parsers/mirai_rounded_rectangle_border/mirai_rounded_rectangle_border.dart';
import 'package:mirai/src/parsers/mirai_icon_theme_data/mirai_icon_theme_data.dart';

export 'mirai_chip_parser.dart';

part 'mirai_chip.freezed.dart';
part 'mirai_chip.g.dart';

@freezed
class MiraiChip with _$MiraiChip {
const factory MiraiChip({
required Map<String, dynamic> label,
Map<String, dynamic>? avatar,
MiraiTextStyle? labelStyle,
MiraiEdgeInsets? labelPadding,
Map<String, dynamic>? deleteIcon,
String? deleteIconColor,
String? deleteButtonTooltipMessage,
MiraiBorderSide? side,
MiraiRoundedRectangleBorder? shape,
@Default(false) bool autofocus,
String? color,
String? backgroundColor,
MiraiEdgeInsets? padding,
double? elevation,
String? shadowColor,
String? surfaceTintColor,
MiraiIconThemeData? iconTheme,
}) = _MiraiChip;

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