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 for Filled Button #274

Merged
merged 8 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
310 changes: 310 additions & 0 deletions examples/mirai_gallery/assets/json/filled_button_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Filled Button"
}
},
"body": {
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "column",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "filledButton",
"child": {
"type": "text",
"data": "BUTTON"
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
}
},
"onPressed": {}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "filledButton",
"child": {
"type": "row",
"children": [
{
"type": "icon",
"iconType": "material",
"icon": "add",
"size": 18
},
{
"type": "sizedBox",
"width": 4
},
{
"type": "text",
"data": "BUTTON"
}
]
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
}
},
"onPressed": {}
}
]
},
{
"type": "sizedBox",
"height": 12
},
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "filledButton",
"child": {
"type": "text",
"data": "BUTTON"
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
},
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
"onPressed": {}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "filledButton",
"child": {
"type": "row",
"children": [
{
"type": "icon",
"iconType": "material",
"icon": "add",
"size": 18
},
{
"type": "sizedBox",
"width": 4
},
{
"type": "text",
"data": "BUTTON"
}
]
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
},
"shape": {
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
"onPressed": {}
}
]
},
{
"type": "sizedBox",
"height": 12
},
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "filledButton",
"child": {
"type": "text",
"data": "BUTTON"
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
}
}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "filledButton",
"child": {
"type": "row",
"children": [
{
"type": "icon",
"iconType": "material",
"icon": "add",
"size": 18
},
{
"type": "sizedBox",
"width": 4
},
{
"type": "text",
"data": "BUTTON"
}
]
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
}
}
}
]
},
{
"type": "sizedBox",
"height": 12
},
{
"type": "row",
"mainAxisAlignment": "center",
"crossAxisAlignment": "center",
"children": [
{
"type": "filledButton",
"child": {
"type": "text",
"data": "BUTTON"
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
},
"shape": {
"side": {
"color": "#ff5454",
"width": 1,
"strokeAlign": 0,
"borderStyle": "solid"
},
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
"onPressed": {}
},
{
"type": "sizedBox",
"width": 20
},
{
"type": "filledButton",
"child": {
"type": "row",
"children": [
{
"type": "icon",
"iconType": "material",
"icon": "add",
"size": 18
},
{
"type": "sizedBox",
"width": 4
},
{
"type": "text",
"data": "BUTTON"
}
]
},
"style": {
"padding": {
"top": 8,
"left": 12,
"right": 12,
"bottom": 8
},
"shape": {
"side": {
"color": "#ff5454",
"width": 1,
"strokeAlign": 0,
"borderStyle": "solid"
},
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomLeft": 8,
"bottomRight": 8
}
}
},
"onPressed": {}
}
]
}
]
}
]
}
}
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 @@ -1145,6 +1145,40 @@
"assetPath": "assets/json/chip_example.json"
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "material",
"icon": "smart_button"
},
"title": {
"type": "text",
"data": "Filled Button",
"align": "center",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design filled button",
"align": "center",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"style": "list",
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/filled_button_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 @@ -65,6 +65,7 @@ class Mirai {
const MiraiCircleAvatarParser(),
const MiraiChipParser(),
const MiraiGridViewParser(),
const MiraiFilledButtonParser()
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import "package:mirai/src/parsers/mirai_button_style/mirai_button_style.dart";
import 'package:flutter/material.dart';
export 'mirai_filled_button_parser.dart';
part 'mirai_filled_button.freezed.dart';
part 'mirai_filled_button.g.dart';

@freezed
class MiraiFilledButton with _$MiraiFilledButton {
const factory MiraiFilledButton({
Map<String, dynamic>? onPressed,
Map<String, dynamic>? onLongPress,
Map<String, dynamic>? onHover,
Map<String, dynamic>? onFocusChange,
MiraiButtonStyle? style,
@Default(false) bool autofocus,
@Default(Clip.none) Clip clipBehavior,
Map<String, dynamic>? child,
}) = _MiraiFilledButton;

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