diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 98bc48b4..5d7e592d 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -1145,6 +1145,40 @@ "assetPath": "assets/json/chip_example.json" } } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "wrap_text" + }, + "title": { + "type": "text", + "data": "Wrap", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget to creates a wrap layout", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/wrap_example.json" + } + } } ] } diff --git a/examples/mirai_gallery/assets/json/wrap_example.json b/examples/mirai_gallery/assets/json/wrap_example.json new file mode 100644 index 00000000..1fb9c5ea --- /dev/null +++ b/examples/mirai_gallery/assets/json/wrap_example.json @@ -0,0 +1,180 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Wrap Demo" + } + }, + "body": { + "type": "center", + "child": { + "type": "wrap", + "spacing": 8.0, + "runSpacing": 4.0, + "children": [ + { + "type": "container", + "color": "#FFCDD2", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "1", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#F8BBD0", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "2", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#E1BEE7", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "3", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#D1C4E9", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "4", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#C5CAE9", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "5", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#BBDEFB", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "6", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#B3E5FC", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "7", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#B2EBF2", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "8", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#B2DFDB", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "9", + "style": { + "color": "#FFFFFF" + } + } + } + }, + { + "type": "container", + "color": "#C8E6C9", + "width": 100, + "height": 100, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "10", + "style": { + "color": "#FFFFFF" + } + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 783ac520..bfb15294 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:mirai/src/action_parsers/action_parsers.dart'; import 'package:mirai/src/action_parsers/mirai_network_request/mirai_network_request_parser.dart'; import 'package:mirai/src/framework/mirai_registry.dart'; +import 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; import 'package:mirai/src/parsers/parsers.dart'; import 'package:mirai/src/services/mirai_network_service.dart'; import 'package:mirai/src/utils/log.dart'; @@ -67,6 +68,7 @@ class Mirai { const MiraiGridViewParser(), const MiraiBottomNavigationViewParser(), const MiraiDefaultBottomNavigationControllerParser(), + const MiraiWrapParser(), ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.g.dart b/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.g.dart index ef26ef8e..6b8f18e8 100644 --- a/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.g.dart @@ -12,34 +12,28 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( icon: json['icon'] as Map?, iconPadding: json['iconPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['iconPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['iconPadding']), iconColor: json['iconColor'] as String?, title: json['title'] as Map?, titlePadding: json['titlePadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['titlePadding'] as Map), + : MiraiEdgeInsets.fromJson(json['titlePadding']), titleTextStyle: json['titleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['titleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['titleTextStyle']), content: json['content'] as Map?, contentPadding: json['contentPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['contentPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['contentPadding']), contentTextStyle: json['contentTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['contentTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['contentTextStyle']), actions: (json['actions'] as List?) ?.map((e) => e as Map) .toList(), actionsPadding: json['actionsPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['actionsPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['actionsPadding']), actionsAlignment: $enumDecodeNullable( _$MainAxisAlignmentEnumMap, json['actionsAlignment']), actionsOverflowAlignment: $enumDecodeNullable( @@ -50,15 +44,13 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( (json['actionsOverflowButtonSpacing'] as num?)?.toDouble(), buttonPadding: json['buttonPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['buttonPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['buttonPadding']), backgroundColor: json['backgroundColor'] as String?, elevation: (json['elevation'] as num?)?.toDouble(), semanticLabel: json['semanticLabel'] as String?, insetPadding: json['insetPadding'] == null ? const MiraiEdgeInsets(left: 40, right: 40, top: 24, bottom: 24) - : MiraiEdgeInsets.fromJson( - json['insetPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['insetPadding']), clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.none, scrollable: json['scrollable'] as bool? ?? false, diff --git a/packages/mirai/lib/src/parsers/mirai_app_bar/mirai_app_bar.g.dart b/packages/mirai/lib/src/parsers/mirai_app_bar/mirai_app_bar.g.dart index 3c42b58c..b0635d98 100644 --- a/packages/mirai/lib/src/parsers/mirai_app_bar/mirai_app_bar.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_app_bar/mirai_app_bar.g.dart @@ -12,12 +12,10 @@ _$MiraiAppBarImpl _$$MiraiAppBarImplFromJson(Map json) => title: json['title'] as Map?, titleTextStyle: json['titleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['titleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['titleTextStyle']), toolbarTextStyle: json['toolbarTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['toolbarTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['toolbarTextStyle']), shadowColor: json['shadowColor'] as String?, backgroundColor: json['backgroundColor'] as String?, foregroundColor: json['foregroundColor'] as String?, diff --git a/packages/mirai/lib/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.g.dart index 9ec60359..35db8b40 100644 --- a/packages/mirai/lib/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.g.dart @@ -29,12 +29,10 @@ _$MiraiAppBarThemeImpl _$$MiraiAppBarThemeImplFromJson( toolbarHeight: (json['toolbarHeight'] as num?)?.toDouble(), toolbarTextStyle: json['toolbarTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['toolbarTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['toolbarTextStyle']), titleTextStyle: json['titleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['titleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['titleTextStyle']), systemOverlayStyle: json['systemOverlayStyle'] == null ? null : MiraiSystemUIOverlayStyle.fromJson( diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_app_bar_theme/mirai_bottom_app_bar_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_bottom_app_bar_theme/mirai_bottom_app_bar_theme.g.dart index 3adaaa22..104b7846 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_app_bar_theme/mirai_bottom_app_bar_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_app_bar_theme/mirai_bottom_app_bar_theme.g.dart @@ -16,7 +16,7 @@ _$MiraiBottomAppBarThemeImpl _$$MiraiBottomAppBarThemeImplFromJson( shadowColor: json['shadowColor'] as String?, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), ); Map _$$MiraiBottomAppBarThemeImplToJson( diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_nav_bar_theme/mirai_bottom_nav_bar_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_bottom_nav_bar_theme/mirai_bottom_nav_bar_theme.g.dart index c5bfb6eb..40313a96 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_nav_bar_theme/mirai_bottom_nav_bar_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_nav_bar_theme/mirai_bottom_nav_bar_theme.g.dart @@ -23,12 +23,10 @@ _$MiraiBottomNavBarThemeDataImpl _$$MiraiBottomNavBarThemeDataImplFromJson( unselectedItemColor: json['unselectedItemColor'] as String?, selectedLabelStyle: json['selectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['selectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['selectedLabelStyle']), unselectedLabelStyle: json['unselectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['unselectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['unselectedLabelStyle']), showSelectedLabels: json['showSelectedLabels'] as bool?, showUnselectedLabels: json['showUnselectedLabels'] as bool?, type: $enumDecodeNullable(_$BottomNavigationBarTypeEnumMap, json['type']), diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.g.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.g.dart index 3581b116..deece17f 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.g.dart @@ -26,12 +26,10 @@ _$MiraiBottomNavigationBarImpl _$$MiraiBottomNavigationBarImplFromJson( (json['unselectedFontSize'] as num?)?.toDouble() ?? 12.0, selectedLabelStyle: json['selectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['selectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['selectedLabelStyle']), unselectedLabelStyle: json['unselectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['unselectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['unselectedLabelStyle']), showSelectedLabels: json['showSelectedLabels'] as bool?, showUnselectedLabels: json['showUnselectedLabels'] as bool?, enableFeedback: json['enableFeedback'] as bool?, diff --git a/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.g.dart b/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.g.dart index e1f6534d..abb26d58 100644 --- a/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.g.dart @@ -20,10 +20,10 @@ _$MiraiButtonStyleImpl _$$MiraiButtonStyleImplFromJson( elevation: (json['elevation'] as num?)?.toDouble(), textStyle: json['textStyle'] == null ? null - : MiraiTextStyle.fromJson(json['textStyle'] as Map), + : MiraiTextStyle.fromJson(json['textStyle']), padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), minimumSize: json['minimumSize'] == null ? null : MiraiSize.fromJson(json['minimumSize'] as Map), diff --git a/packages/mirai/lib/src/parsers/mirai_card/mirai_card.g.dart b/packages/mirai/lib/src/parsers/mirai_card/mirai_card.g.dart index 8cb1cc2d..fcba443e 100644 --- a/packages/mirai/lib/src/parsers/mirai_card/mirai_card.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_card/mirai_card.g.dart @@ -15,7 +15,7 @@ _$MiraiCardImpl _$$MiraiCardImplFromJson(Map json) => borderOnForeground: json['borderOnForeground'] as bool? ?? true, margin: json['margin'] == null ? null - : MiraiEdgeInsets.fromJson(json['margin'] as Map), + : MiraiEdgeInsets.fromJson(json['margin']), clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']), child: json['child'] as Map?, semanticContainer: json['semanticContainer'] as bool? ?? true, diff --git a/packages/mirai/lib/src/parsers/mirai_card_theme_data/mirai_card_theme_data.g.dart b/packages/mirai/lib/src/parsers/mirai_card_theme_data/mirai_card_theme_data.g.dart index a23a5e9f..a8f077e7 100644 --- a/packages/mirai/lib/src/parsers/mirai_card_theme_data/mirai_card_theme_data.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_card_theme_data/mirai_card_theme_data.g.dart @@ -16,7 +16,7 @@ _$MiraiCardThemeDataImpl _$$MiraiCardThemeDataImplFromJson( elevation: (json['elevation'] as num?)?.toDouble(), margin: json['margin'] == null ? null - : MiraiEdgeInsets.fromJson(json['margin'] as Map), + : MiraiEdgeInsets.fromJson(json['margin']), shape: json['shape'] == null ? null : MiraiBorder.fromJson(json['shape'] as Map), diff --git a/packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.g.dart b/packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.g.dart index 329d1988..8674dd01 100644 --- a/packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.g.dart @@ -12,11 +12,10 @@ _$MiraiChipImpl _$$MiraiChipImplFromJson(Map json) => avatar: json['avatar'] as Map?, labelStyle: json['labelStyle'] == null ? null - : MiraiTextStyle.fromJson(json['labelStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelStyle']), labelPadding: json['labelPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['labelPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['labelPadding']), deleteIcon: json['deleteIcon'] as Map?, deleteIconColor: json['deleteIconColor'] as String?, deleteButtonTooltipMessage: json['deleteButtonTooltipMessage'] as String?, @@ -32,7 +31,7 @@ _$MiraiChipImpl _$$MiraiChipImplFromJson(Map json) => backgroundColor: json['backgroundColor'] as String?, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), elevation: (json['elevation'] as num?)?.toDouble(), shadowColor: json['shadowColor'] as String?, surfaceTintColor: json['surfaceTintColor'] as String?, diff --git a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.g.dart b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.g.dart index e975bebd..8ddede8c 100644 --- a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.g.dart @@ -12,7 +12,7 @@ _$MiraiContainerImpl _$$MiraiContainerImplFromJson(Map json) => $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']), padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), decoration: json['decoration'] == null ? null : MiraiBoxDecoration.fromJson( @@ -22,7 +22,7 @@ _$MiraiContainerImpl _$$MiraiContainerImplFromJson(Map json) => height: (json['height'] as num?)?.toDouble(), margin: json['margin'] == null ? null - : MiraiEdgeInsets.fromJson(json['margin'] as Map), + : MiraiEdgeInsets.fromJson(json['margin']), child: json['child'] as Map?, clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.none, diff --git a/packages/mirai/lib/src/parsers/mirai_dialog_theme/mirai_dialog_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_dialog_theme/mirai_dialog_theme.g.dart index cbf05f63..d4268980 100644 --- a/packages/mirai/lib/src/parsers/mirai_dialog_theme/mirai_dialog_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_dialog_theme/mirai_dialog_theme.g.dart @@ -22,16 +22,13 @@ _$MiraiDialogThemeImpl _$$MiraiDialogThemeImplFromJson( json['alignment'] as Map), titleTextStyle: json['titleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['titleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['titleTextStyle']), contentTextStyle: json['contentTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['contentTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['contentTextStyle']), actionsPadding: json['actionsPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['actionsPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['actionsPadding']), iconColor: json['iconColor'] as String?, ); diff --git a/packages/mirai/lib/src/parsers/mirai_edge_insets/mirai_edge_insets.dart b/packages/mirai/lib/src/parsers/mirai_edge_insets/mirai_edge_insets.dart index 70843e48..87a678b6 100644 --- a/packages/mirai/lib/src/parsers/mirai_edge_insets/mirai_edge_insets.dart +++ b/packages/mirai/lib/src/parsers/mirai_edge_insets/mirai_edge_insets.dart @@ -13,8 +13,37 @@ class MiraiEdgeInsets with _$MiraiEdgeInsets { double? bottom, }) = _MiraiEdgeInsets; - factory MiraiEdgeInsets.fromJson(Map json) => - _$MiraiEdgeInsetsFromJson(json); + factory MiraiEdgeInsets.fromJson(dynamic json) => _fromJson(json); + + static MiraiEdgeInsets _fromJson(dynamic json) { + Map resultantJson; + + if (json is num) { + resultantJson = { + "left": json, + "top": json, + "right": json, + "bottom": json + }; + } else if (json is List && json.length == 4) { + bool allElementsNum = json.every((element) => element is num); + if (!allElementsNum) { + throw ArgumentError('Invalid input format for MiraiEdgeInsets'); + } + resultantJson = { + "left": json[0], + "top": json[1], + "right": json[2], + "bottom": json[3] + }; + } else if (json is Map) { + resultantJson = json; + } else { + throw ArgumentError('Invalid input format for MiraiEdgeInsets'); + } + + return _$MiraiEdgeInsetsFromJson(resultantJson); + } } extension MiraiEdgeInsetsParser on MiraiEdgeInsets? { diff --git a/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.g.dart b/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.g.dart index ec1078c8..595205a4 100644 --- a/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.g.dart @@ -12,7 +12,7 @@ _$MiraiFloatingActionButtonImpl _$$MiraiFloatingActionButtonImplFromJson( onPressed: json['onPressed'] as Map?, textStyle: json['textStyle'] == null ? null - : MiraiTextStyle.fromJson(json['textStyle'] as Map), + : MiraiTextStyle.fromJson(json['textStyle']), buttonType: $enumDecodeNullable( _$FloatingActionButtonTypeEnumMap, json['buttonType']) ?? FloatingActionButtonType.small, @@ -25,8 +25,7 @@ _$MiraiFloatingActionButtonImpl _$$MiraiFloatingActionButtonImplFromJson( splashColor: json['splashColor'] as String?, extendedTextStyle: json['extendedTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['extendedTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['extendedTextStyle']), elevation: (json['elevation'] as num?)?.toDouble(), focusElevation: (json['focusElevation'] as num?)?.toDouble(), hoverElevation: (json['hoverElevation'] as num?)?.toDouble(), diff --git a/packages/mirai/lib/src/parsers/mirai_floating_action_button_theme_data/mirai_floating_action_button_theme_data.g.dart b/packages/mirai/lib/src/parsers/mirai_floating_action_button_theme_data/mirai_floating_action_button_theme_data.g.dart index e3c1629a..c44aaf66 100644 --- a/packages/mirai/lib/src/parsers/mirai_floating_action_button_theme_data/mirai_floating_action_button_theme_data.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_floating_action_button_theme_data/mirai_floating_action_button_theme_data.g.dart @@ -26,12 +26,10 @@ _$MiraiFloatingActionButtonThemeDataImpl (json['extendedIconLabelSpacing'] as num?)?.toDouble(), extendedPadding: json['extendedPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['extendedPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['extendedPadding']), extendedTextStyle: json['extendedTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['extendedTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['extendedTextStyle']), ); Map _$$MiraiFloatingActionButtonThemeDataImplToJson( diff --git a/packages/mirai/lib/src/parsers/mirai_grid_view/mirai_grid_view.g.dart b/packages/mirai/lib/src/parsers/mirai_grid_view/mirai_grid_view.g.dart index ad33bb82..2f40ef13 100644 --- a/packages/mirai/lib/src/parsers/mirai_grid_view/mirai_grid_view.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_grid_view/mirai_grid_view.g.dart @@ -18,7 +18,7 @@ _$MiraiGridViewImpl _$$MiraiGridViewImplFromJson(Map json) => shrinkWrap: json['shrinkWrap'] as bool? ?? false, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), crossAxisCount: json['crossAxisCount'] as int?, mainAxisSpacing: (json['mainAxisSpacing'] as num?)?.toDouble() ?? 0.0, crossAxisSpacing: (json['crossAxisSpacing'] as num?)?.toDouble() ?? 0.0, diff --git a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.g.dart b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.g.dart index 180fe11f..b8cad032 100644 --- a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.g.dart @@ -13,7 +13,7 @@ _$MiraiIconButtonImpl _$$MiraiIconButtonImplFromJson( iconSize: (json['iconSize'] as num?)?.toDouble(), padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), alignment: $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']) ?? MiraiAlignment.center, diff --git a/packages/mirai/lib/src/parsers/mirai_input_decoration/mirai_input_decoration.g.dart b/packages/mirai/lib/src/parsers/mirai_input_decoration/mirai_input_decoration.g.dart index 5da180c7..9d632535 100644 --- a/packages/mirai/lib/src/parsers/mirai_input_decoration/mirai_input_decoration.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_input_decoration/mirai_input_decoration.g.dart @@ -15,20 +15,18 @@ _$MiraiInputDecorationImpl _$$MiraiInputDecorationImplFromJson( labelText: json['labelText'] as String?, labelStyle: json['labelStyle'] == null ? null - : MiraiTextStyle.fromJson(json['labelStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelStyle']), floatingLabelStyle: json['floatingLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['floatingLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['floatingLabelStyle']), helperText: json['helperText'] as String?, helperStyle: json['helperStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['helperStyle'] as Map), + : MiraiTextStyle.fromJson(json['helperStyle']), hintText: json['hintText'] as String?, hintStyle: json['hintStyle'] == null ? null - : MiraiTextStyle.fromJson(json['hintStyle'] as Map), + : MiraiTextStyle.fromJson(json['hintStyle']), helperMaxLines: json['helperMaxLines'] as int?, hintTextDirection: $enumDecodeNullable( _$TextDirectionEnumMap, json['hintTextDirection']), @@ -36,7 +34,7 @@ _$MiraiInputDecorationImpl _$$MiraiInputDecorationImplFromJson( errorText: json['errorText'] as String?, errorStyle: json['errorStyle'] == null ? null - : MiraiTextStyle.fromJson(json['errorStyle'] as Map), + : MiraiTextStyle.fromJson(json['errorStyle']), errorMaxLines: json['errorMaxLines'] as int?, floatingLabelBehavior: $enumDecodeNullable( _$FloatingLabelBehaviorEnumMap, json['floatingLabelBehavior']), @@ -46,8 +44,7 @@ _$MiraiInputDecorationImpl _$$MiraiInputDecorationImplFromJson( isDense: json['isDense'] as bool? ?? false, contentPadding: json['contentPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['contentPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['contentPadding']), prefixIcon: json['prefixIcon'] as Map?, prefixIconConstraints: json['prefixIconConstraints'] == null ? null @@ -57,8 +54,7 @@ _$MiraiInputDecorationImpl _$$MiraiInputDecorationImplFromJson( prefixText: json['prefixText'] as String?, prefixStyle: json['prefixStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['prefixStyle'] as Map), + : MiraiTextStyle.fromJson(json['prefixStyle']), prefixIconColor: json['prefixIconColor'] as String?, suffix: json['suffix'] as Map?, suffixIcon: json['suffixIcon'] as Map?, @@ -69,15 +65,13 @@ _$MiraiInputDecorationImpl _$$MiraiInputDecorationImplFromJson( suffixText: json['suffixText'] as String?, suffixStyle: json['suffixStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['suffixStyle'] as Map), + : MiraiTextStyle.fromJson(json['suffixStyle']), suffixIconColor: json['suffixIconColor'] as String?, counter: json['counter'] as Map?, counterText: json['counterText'] as String?, counterStyle: json['counterStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['counterStyle'] as Map), + : MiraiTextStyle.fromJson(json['counterStyle']), filled: json['filled'] as bool?, fillColor: json['fillColor'] as String?, hoverColor: json['hoverColor'] as String?, diff --git a/packages/mirai/lib/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.g.dart index 3a97f20c..346aaf6e 100644 --- a/packages/mirai/lib/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.g.dart @@ -11,22 +11,20 @@ _$MiraiInputDecorationThemeImpl _$$MiraiInputDecorationThemeImplFromJson( _$MiraiInputDecorationThemeImpl( labelStyle: json['labelStyle'] == null ? null - : MiraiTextStyle.fromJson(json['labelStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelStyle']), floatingLabelStyle: json['floatingLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['floatingLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['floatingLabelStyle']), helperStyle: json['helperStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['helperStyle'] as Map), + : MiraiTextStyle.fromJson(json['helperStyle']), helperMaxLines: json['helperMaxLines'] as int?, hintStyle: json['hintStyle'] == null ? null - : MiraiTextStyle.fromJson(json['hintStyle'] as Map), + : MiraiTextStyle.fromJson(json['hintStyle']), errorStyle: json['errorStyle'] == null ? null - : MiraiTextStyle.fromJson(json['errorStyle'] as Map), + : MiraiTextStyle.fromJson(json['errorStyle']), errorMaxLines: json['errorMaxLines'] as int?, floatingLabelBehavior: $enumDecodeNullable( _$FloatingLabelBehaviorEnumMap, json['floatingLabelBehavior']), @@ -35,24 +33,20 @@ _$MiraiInputDecorationThemeImpl _$$MiraiInputDecorationThemeImplFromJson( isDense: json['isDense'] as bool? ?? false, contentPadding: json['contentPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['contentPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['contentPadding']), isCollapsed: json['isCollapsed'] as bool? ?? false, iconColor: json['iconColor'] as String?, prefixStyle: json['prefixStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['prefixStyle'] as Map), + : MiraiTextStyle.fromJson(json['prefixStyle']), prefixIconColor: json['prefixIconColor'] as String?, suffixStyle: json['suffixStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['suffixStyle'] as Map), + : MiraiTextStyle.fromJson(json['suffixStyle']), suffixIconColor: json['suffixIconColor'] as String?, counterStyle: json['counterStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['counterStyle'] as Map), + : MiraiTextStyle.fromJson(json['counterStyle']), filled: json['filled'] as bool? ?? false, fillColor: json['fillColor'] as String?, activeIndicatorBorder: json['activeIndicatorBorder'] == null diff --git a/packages/mirai/lib/src/parsers/mirai_list_tile/mirai_list_tile.g.dart b/packages/mirai/lib/src/parsers/mirai_list_tile/mirai_list_tile.g.dart index 149a1a41..9986a274 100644 --- a/packages/mirai/lib/src/parsers/mirai_list_tile/mirai_list_tile.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_list_tile/mirai_list_tile.g.dart @@ -22,8 +22,7 @@ _$MiraiListTileImpl _$$MiraiListTileImplFromJson(Map json) => textColor: json['textColor'] as String?, contentPadding: json['contentPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['contentPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['contentPadding']), enabled: json['enabled'] as bool? ?? true, selected: json['selected'] as bool? ?? false, focusColor: json['focusColor'] as String?, diff --git a/packages/mirai/lib/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.g.dart b/packages/mirai/lib/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.g.dart index 8564c0cc..c3026173 100644 --- a/packages/mirai/lib/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.g.dart @@ -19,20 +19,16 @@ _$MiraiListTileThemeDataImpl _$$MiraiListTileThemeDataImplFromJson( textColor: json['textColor'] as String?, titleTextStyle: json['titleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['titleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['titleTextStyle']), subtitleTextStyle: json['subtitleTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['subtitleTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['subtitleTextStyle']), leadingAndTrailingTextStyle: json['leadingAndTrailingTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['leadingAndTrailingTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['leadingAndTrailingTextStyle']), contentPadding: json['contentPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['contentPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['contentPadding']), tileColor: json['tileColor'] as String?, selectedTileColor: json['selectedTileColor'] as String?, horizontalTitleGap: (json['horizontalTitleGap'] as num?)?.toDouble(), diff --git a/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.g.dart b/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.g.dart index 12a4a585..169fa4fb 100644 --- a/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.g.dart @@ -18,7 +18,7 @@ _$MiraiListViewImpl _$$MiraiListViewImplFromJson(Map json) => shrinkWrap: json['shrinkWrap'] as bool? ?? false, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), addAutomaticKeepAlives: json['addAutomaticKeepAlives'] as bool? ?? true, addRepaintBoundaries: json['addRepaintBoundaries'] as bool? ?? true, addSemanticIndexes: json['addSemanticIndexes'] as bool? ?? true, diff --git a/packages/mirai/lib/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.g.dart b/packages/mirai/lib/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.g.dart index 677a064a..e7ea23cc 100644 --- a/packages/mirai/lib/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.g.dart @@ -21,8 +21,7 @@ _$MiraiNavigationBarThemeDataImpl _$$MiraiNavigationBarThemeDataImplFromJson( json['indicatorShape'] as Map), labelTextStyle: json['labelTextStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['labelTextStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelTextStyle']), iconTheme: json['iconTheme'] == null ? null : MiraiIconThemeData.fromJson( diff --git a/packages/mirai/lib/src/parsers/mirai_padding/mirai_padding.g.dart b/packages/mirai/lib/src/parsers/mirai_padding/mirai_padding.g.dart index 46a05bb9..c611038d 100644 --- a/packages/mirai/lib/src/parsers/mirai_padding/mirai_padding.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_padding/mirai_padding.g.dart @@ -8,8 +8,7 @@ part of 'mirai_padding.dart'; _$MiraiPaddingImpl _$$MiraiPaddingImplFromJson(Map json) => _$MiraiPaddingImpl( - padding: - MiraiEdgeInsets.fromJson(json['padding'] as Map), + padding: MiraiEdgeInsets.fromJson(json['padding']), child: json['child'] as Map?, ); diff --git a/packages/mirai/lib/src/parsers/mirai_safe_area/mirai_safe_area.g.dart b/packages/mirai/lib/src/parsers/mirai_safe_area/mirai_safe_area.g.dart index aeec9e1a..bd317b61 100644 --- a/packages/mirai/lib/src/parsers/mirai_safe_area/mirai_safe_area.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_safe_area/mirai_safe_area.g.dart @@ -15,7 +15,7 @@ _$MiraiSafeAreaImpl _$$MiraiSafeAreaImplFromJson(Map json) => bottom: json['bottom'] as bool? ?? true, minimum: json['minimum'] == null ? const MiraiEdgeInsets() - : MiraiEdgeInsets.fromJson(json['minimum'] as Map), + : MiraiEdgeInsets.fromJson(json['minimum']), maintainBottomViewPadding: json['maintainBottomViewPadding'] as bool? ?? false, ); diff --git a/packages/mirai/lib/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.g.dart b/packages/mirai/lib/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.g.dart index f3100cc7..2b3e275e 100644 --- a/packages/mirai/lib/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.g.dart @@ -15,7 +15,7 @@ _$MiraiSingleChildScrollViewImpl _$$MiraiSingleChildScrollViewImplFromJson( reverse: json['reverse'] as bool? ?? false, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), primary: json['primary'] as bool?, physics: $enumDecodeNullable(_$MiraiScrollPhysicsEnumMap, json['physics']), diff --git a/packages/mirai/lib/src/parsers/mirai_tab/mirai_tab.g.dart b/packages/mirai/lib/src/parsers/mirai_tab/mirai_tab.g.dart index a0599172..72de8814 100644 --- a/packages/mirai/lib/src/parsers/mirai_tab/mirai_tab.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_tab/mirai_tab.g.dart @@ -12,8 +12,7 @@ _$MiraiTabImpl _$$MiraiTabImplFromJson(Map json) => icon: json['icon'] as Map?, iconMargin: json['iconMargin'] == null ? null - : MiraiEdgeInsets.fromJson( - json['iconMargin'] as Map), + : MiraiEdgeInsets.fromJson(json['iconMargin']), height: (json['height'] as num?)?.toDouble(), child: json['child'] as Map?, ); diff --git a/packages/mirai/lib/src/parsers/mirai_tab_bar/mirai_tab_bar.g.dart b/packages/mirai/lib/src/parsers/mirai_tab_bar/mirai_tab_bar.g.dart index 2bb48464..529446c4 100644 --- a/packages/mirai/lib/src/parsers/mirai_tab_bar/mirai_tab_bar.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_tab_bar/mirai_tab_bar.g.dart @@ -15,30 +15,27 @@ _$MiraiTabBarImpl _$$MiraiTabBarImplFromJson(Map json) => isScrollable: json['isScrollable'] as bool? ?? false, padding: json['padding'] == null ? null - : MiraiEdgeInsets.fromJson(json['padding'] as Map), + : MiraiEdgeInsets.fromJson(json['padding']), indicatorColor: json['indicatorColor'] as String?, automaticIndicatorColorAdjustment: json['automaticIndicatorColorAdjustment'] as bool? ?? true, indicatorWeight: (json['indicatorWeight'] as num?)?.toDouble() ?? 2.0, indicatorPadding: json['indicatorPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['indicatorPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['indicatorPadding']), indicatorSize: $enumDecodeNullable( _$TabBarIndicatorSizeEnumMap, json['indicatorSize']), labelColor: json['labelColor'] as String?, labelStyle: json['labelStyle'] == null ? null - : MiraiTextStyle.fromJson(json['labelStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelStyle']), labelPadding: json['labelPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['labelPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['labelPadding']), unselectedLabelColor: json['unselectedLabelColor'] as String?, unselectedLabelStyle: json['unselectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['unselectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['unselectedLabelStyle']), dragStartBehavior: $enumDecodeNullable( _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? DragStartBehavior.start, diff --git a/packages/mirai/lib/src/parsers/mirai_tab_bar_theme_data/mirai_tab_bar_theme_data.g.dart b/packages/mirai/lib/src/parsers/mirai_tab_bar_theme_data/mirai_tab_bar_theme_data.g.dart index acf15809..4044a121 100644 --- a/packages/mirai/lib/src/parsers/mirai_tab_bar_theme_data/mirai_tab_bar_theme_data.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_tab_bar_theme_data/mirai_tab_bar_theme_data.g.dart @@ -20,16 +20,14 @@ _$MiraiTabBarThemeDataImpl _$$MiraiTabBarThemeDataImplFromJson( labelColor: json['labelColor'] as String?, labelPadding: json['labelPadding'] == null ? null - : MiraiEdgeInsets.fromJson( - json['labelPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['labelPadding']), labelStyle: json['labelStyle'] == null ? null - : MiraiTextStyle.fromJson(json['labelStyle'] as Map), + : MiraiTextStyle.fromJson(json['labelStyle']), unselectedLabelColor: json['unselectedLabelColor'] as String?, unselectedLabelStyle: json['unselectedLabelStyle'] == null ? null - : MiraiTextStyle.fromJson( - json['unselectedLabelStyle'] as Map), + : MiraiTextStyle.fromJson(json['unselectedLabelStyle']), overlayColor: json['overlayColor'] as String?, ); diff --git a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart index e12d4ec7..ab3c2d8e 100644 --- a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart @@ -13,9 +13,8 @@ _$MiraiTextImpl _$$MiraiTextImplFromJson(Map json) => ?.map((e) => MiraiTextSpan.fromJson(e as Map)) .toList() ?? const [], - style: json['style'] == null - ? null - : MiraiTextStyle.fromJson(json['style'] as Map), + style: + json['style'] == null ? null : MiraiTextStyle.fromJson(json['style']), textAlign: $enumDecodeNullable(_$TextAlignEnumMap, json['textAlign']), textDirection: $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), @@ -74,9 +73,8 @@ const _$TextWidthBasisEnumMap = { _$MiraiTextSpanImpl _$$MiraiTextSpanImplFromJson(Map json) => _$MiraiTextSpanImpl( data: json['data'] as String?, - style: json['style'] == null - ? null - : MiraiTextStyle.fromJson(json['style'] as Map), + style: + json['style'] == null ? null : MiraiTextStyle.fromJson(json['style']), onTap: json['onTap'] as Map?, ); diff --git a/packages/mirai/lib/src/parsers/mirai_text_field/mirai_text_field.g.dart b/packages/mirai/lib/src/parsers/mirai_text_field/mirai_text_field.g.dart index 7812ef42..16a08147 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_field/mirai_text_field.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_field/mirai_text_field.g.dart @@ -20,9 +20,8 @@ _$MiraiTextFieldImpl _$$MiraiTextFieldImplFromJson(Map json) => textCapitalization: $enumDecodeNullable( _$TextCapitalizationEnumMap, json['textCapitalization']) ?? TextCapitalization.none, - style: json['style'] == null - ? null - : MiraiTextStyle.fromJson(json['style'] as Map), + style: + json['style'] == null ? null : MiraiTextStyle.fromJson(json['style']), textAlign: $enumDecodeNullable(_$TextAlignEnumMap, json['textAlign']) ?? TextAlign.start, textAlignVertical: $enumDecodeNullable( diff --git a/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.g.dart b/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.g.dart index 77d45108..5bd5e971 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.g.dart @@ -23,9 +23,8 @@ _$MiraiTextFormFieldImpl _$$MiraiTextFormFieldImplFromJson( textCapitalization: $enumDecodeNullable( _$TextCapitalizationEnumMap, json['textCapitalization']) ?? TextCapitalization.none, - style: json['style'] == null - ? null - : MiraiTextStyle.fromJson(json['style'] as Map), + style: + json['style'] == null ? null : MiraiTextStyle.fromJson(json['style']), textAlign: $enumDecodeNullable(_$TextAlignEnumMap, json['textAlign']) ?? TextAlign.start, textAlignVertical: $enumDecodeNullable( @@ -52,8 +51,7 @@ _$MiraiTextFormFieldImpl _$$MiraiTextFormFieldImplFromJson( $enumDecodeNullable(_$BrightnessEnumMap, json['keyboardAppearance']), scrollPadding: json['scrollPadding'] == null ? const MiraiEdgeInsets(bottom: 20, top: 20, left: 20, right: 20) - : MiraiEdgeInsets.fromJson( - json['scrollPadding'] as Map), + : MiraiEdgeInsets.fromJson(json['scrollPadding']), restorationId: json['restorationId'] as String?, enableIMEPersonalizedLearning: json['enableIMEPersonalizedLearning'] as bool? ?? true, diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart index 62e0d3f0..a4716023 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart @@ -12,6 +12,7 @@ class MiraiTextStyle with _$MiraiTextStyle { @Default(true) bool inherit, String? color, String? backgroundColor, + String? styleFromTheme, double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, @@ -23,12 +24,56 @@ class MiraiTextStyle with _$MiraiTextStyle { double? height, }) = _MiraiTextStyle; - factory MiraiTextStyle.fromJson(Map json) => - _$MiraiTextStyleFromJson(json); + factory MiraiTextStyle.fromJson(dynamic json) => _fromJson(json); + + static MiraiTextStyle _fromJson(dynamic json) { + if (json is String) { + return _$MiraiTextStyleFromJson({"styleFromTheme": json}); + } else if (json is Map) { + return _$MiraiTextStyleFromJson(json); + } + + return _$MiraiTextStyleFromJson({}); + } } extension MiraiTextStyleParser on MiraiTextStyle { TextStyle? parse(BuildContext context) { + if (styleFromTheme != null) { + switch (styleFromTheme) { + case 'displayLarge': + return Theme.of(context).textTheme.displayLarge; + case 'displayMedium': + return Theme.of(context).textTheme.displayMedium; + case 'displaySmall': + return Theme.of(context).textTheme.displaySmall; + case 'headlineLarge': + return Theme.of(context).textTheme.headlineLarge; + case 'headlineMedium': + return Theme.of(context).textTheme.headlineMedium; + case 'headlineSmall': + return Theme.of(context).textTheme.headlineSmall; + case 'titleLarge': + return Theme.of(context).textTheme.titleLarge; + case 'titleMedium': + return Theme.of(context).textTheme.titleMedium; + case 'titleSmall': + return Theme.of(context).textTheme.titleSmall; + case 'bodyLarge': + return Theme.of(context).textTheme.bodyLarge; + case 'bodyMedium': + return Theme.of(context).textTheme.bodyMedium; + case 'bodySmall': + return Theme.of(context).textTheme.bodySmall; + case 'labelLarge': + return Theme.of(context).textTheme.labelLarge; + case 'labelMedium': + return Theme.of(context).textTheme.labelMedium; + case 'labelSmall': + return Theme.of(context).textTheme.labelSmall; + } + } + return TextStyle( inherit: inherit, color: color?.toColor(context), diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart index eb871750..8cfc8dcc 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart @@ -23,6 +23,7 @@ mixin _$MiraiTextStyle { bool get inherit => throw _privateConstructorUsedError; String? get color => throw _privateConstructorUsedError; String? get backgroundColor => throw _privateConstructorUsedError; + String? get styleFromTheme => throw _privateConstructorUsedError; double? get fontSize => throw _privateConstructorUsedError; MiraiFontWeight? get fontWeight => throw _privateConstructorUsedError; FontStyle? get fontStyle => throw _privateConstructorUsedError; @@ -49,6 +50,7 @@ abstract class $MiraiTextStyleCopyWith<$Res> { {bool inherit, String? color, String? backgroundColor, + String? styleFromTheme, double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, @@ -76,6 +78,7 @@ class _$MiraiTextStyleCopyWithImpl<$Res, $Val extends MiraiTextStyle> Object? inherit = null, Object? color = freezed, Object? backgroundColor = freezed, + Object? styleFromTheme = freezed, Object? fontSize = freezed, Object? fontWeight = freezed, Object? fontStyle = freezed, @@ -99,6 +102,10 @@ class _$MiraiTextStyleCopyWithImpl<$Res, $Val extends MiraiTextStyle> ? _value.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable as String?, + styleFromTheme: freezed == styleFromTheme + ? _value.styleFromTheme + : styleFromTheme // ignore: cast_nullable_to_non_nullable + as String?, fontSize: freezed == fontSize ? _value.fontSize : fontSize // ignore: cast_nullable_to_non_nullable @@ -151,6 +158,7 @@ abstract class _$$MiraiTextStyleImplCopyWith<$Res> {bool inherit, String? color, String? backgroundColor, + String? styleFromTheme, double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, @@ -176,6 +184,7 @@ class __$$MiraiTextStyleImplCopyWithImpl<$Res> Object? inherit = null, Object? color = freezed, Object? backgroundColor = freezed, + Object? styleFromTheme = freezed, Object? fontSize = freezed, Object? fontWeight = freezed, Object? fontStyle = freezed, @@ -199,6 +208,10 @@ class __$$MiraiTextStyleImplCopyWithImpl<$Res> ? _value.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable as String?, + styleFromTheme: freezed == styleFromTheme + ? _value.styleFromTheme + : styleFromTheme // ignore: cast_nullable_to_non_nullable + as String?, fontSize: freezed == fontSize ? _value.fontSize : fontSize // ignore: cast_nullable_to_non_nullable @@ -246,6 +259,7 @@ class _$MiraiTextStyleImpl implements _MiraiTextStyle { {this.inherit = true, this.color, this.backgroundColor, + this.styleFromTheme, this.fontSize, this.fontWeight, this.fontStyle, @@ -268,6 +282,8 @@ class _$MiraiTextStyleImpl implements _MiraiTextStyle { @override final String? backgroundColor; @override + final String? styleFromTheme; + @override final double? fontSize; @override final MiraiFontWeight? fontWeight; @@ -297,7 +313,7 @@ class _$MiraiTextStyleImpl implements _MiraiTextStyle { @override String toString() { - return 'MiraiTextStyle(inherit: $inherit, color: $color, backgroundColor: $backgroundColor, fontSize: $fontSize, fontWeight: $fontWeight, fontStyle: $fontStyle, fontFamily: $fontFamily, fontFamilyFallback: $fontFamilyFallback, letterSpacing: $letterSpacing, wordSpacing: $wordSpacing, textBaseline: $textBaseline, height: $height)'; + return 'MiraiTextStyle(inherit: $inherit, color: $color, backgroundColor: $backgroundColor, styleFromTheme: $styleFromTheme, fontSize: $fontSize, fontWeight: $fontWeight, fontStyle: $fontStyle, fontFamily: $fontFamily, fontFamilyFallback: $fontFamilyFallback, letterSpacing: $letterSpacing, wordSpacing: $wordSpacing, textBaseline: $textBaseline, height: $height)'; } @override @@ -309,6 +325,8 @@ class _$MiraiTextStyleImpl implements _MiraiTextStyle { (identical(other.color, color) || other.color == color) && (identical(other.backgroundColor, backgroundColor) || other.backgroundColor == backgroundColor) && + (identical(other.styleFromTheme, styleFromTheme) || + other.styleFromTheme == styleFromTheme) && (identical(other.fontSize, fontSize) || other.fontSize == fontSize) && (identical(other.fontWeight, fontWeight) || @@ -335,6 +353,7 @@ class _$MiraiTextStyleImpl implements _MiraiTextStyle { inherit, color, backgroundColor, + styleFromTheme, fontSize, fontWeight, fontStyle, @@ -365,6 +384,7 @@ abstract class _MiraiTextStyle implements MiraiTextStyle { {final bool inherit, final String? color, final String? backgroundColor, + final String? styleFromTheme, final double? fontSize, final MiraiFontWeight? fontWeight, final FontStyle? fontStyle, @@ -385,6 +405,8 @@ abstract class _MiraiTextStyle implements MiraiTextStyle { @override String? get backgroundColor; @override + String? get styleFromTheme; + @override double? get fontSize; @override MiraiFontWeight? get fontWeight; diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart index f67e62ea..19d0d60b 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart @@ -11,6 +11,7 @@ _$MiraiTextStyleImpl _$$MiraiTextStyleImplFromJson(Map json) => inherit: json['inherit'] as bool? ?? true, color: json['color'] as String?, backgroundColor: json['backgroundColor'] as String?, + styleFromTheme: json['styleFromTheme'] as String?, fontSize: (json['fontSize'] as num?)?.toDouble(), fontWeight: $enumDecodeNullable(_$MiraiFontWeightEnumMap, json['fontWeight']), @@ -32,6 +33,7 @@ Map _$$MiraiTextStyleImplToJson( 'inherit': instance.inherit, 'color': instance.color, 'backgroundColor': instance.backgroundColor, + 'styleFromTheme': instance.styleFromTheme, 'fontSize': instance.fontSize, 'fontWeight': _$MiraiFontWeightEnumMap[instance.fontWeight], 'fontStyle': _$FontStyleEnumMap[instance.fontStyle], diff --git a/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.dart b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.dart new file mode 100644 index 00000000..96ed6271 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'mirai_wrap_parser.dart'; + +part 'mirai_wrap.freezed.dart'; +part 'mirai_wrap.g.dart'; + +@freezed +class MiraiWrap with _$MiraiWrap { + const factory MiraiWrap({ + @Default(Axis.horizontal) Axis direction, + @Default(WrapAlignment.start) WrapAlignment alignment, + @Default(0.0) double spacing, + @Default(WrapAlignment.start) WrapAlignment runAlignment, + @Default(0.0) double runSpacing, + @Default(WrapCrossAlignment.start) WrapCrossAlignment crossAxisAlignment, + TextDirection? textDirection, + @Default(VerticalDirection.down) VerticalDirection verticalDirection, + @Default(Clip.none) Clip clipBehavior, + @Default([]) List> children, + }) = _MiraiWrap; + + factory MiraiWrap.fromJson(Map json) => + _$MiraiWrapFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.freezed.dart b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.freezed.dart new file mode 100644 index 00000000..e5b2108b --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.freezed.dart @@ -0,0 +1,369 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_wrap.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +MiraiWrap _$MiraiWrapFromJson(Map json) { + return _MiraiWrap.fromJson(json); +} + +/// @nodoc +mixin _$MiraiWrap { + Axis get direction => throw _privateConstructorUsedError; + WrapAlignment get alignment => throw _privateConstructorUsedError; + double get spacing => throw _privateConstructorUsedError; + WrapAlignment get runAlignment => throw _privateConstructorUsedError; + double get runSpacing => throw _privateConstructorUsedError; + WrapCrossAlignment get crossAxisAlignment => + throw _privateConstructorUsedError; + TextDirection? get textDirection => throw _privateConstructorUsedError; + VerticalDirection get verticalDirection => throw _privateConstructorUsedError; + Clip get clipBehavior => throw _privateConstructorUsedError; + List> get children => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiWrapCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiWrapCopyWith<$Res> { + factory $MiraiWrapCopyWith(MiraiWrap value, $Res Function(MiraiWrap) then) = + _$MiraiWrapCopyWithImpl<$Res, MiraiWrap>; + @useResult + $Res call( + {Axis direction, + WrapAlignment alignment, + double spacing, + WrapAlignment runAlignment, + double runSpacing, + WrapCrossAlignment crossAxisAlignment, + TextDirection? textDirection, + VerticalDirection verticalDirection, + Clip clipBehavior, + List> children}); +} + +/// @nodoc +class _$MiraiWrapCopyWithImpl<$Res, $Val extends MiraiWrap> + implements $MiraiWrapCopyWith<$Res> { + _$MiraiWrapCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? direction = null, + Object? alignment = null, + Object? spacing = null, + Object? runAlignment = null, + Object? runSpacing = null, + Object? crossAxisAlignment = null, + Object? textDirection = freezed, + Object? verticalDirection = null, + Object? clipBehavior = null, + Object? children = null, + }) { + return _then(_value.copyWith( + direction: null == direction + ? _value.direction + : direction // ignore: cast_nullable_to_non_nullable + as Axis, + alignment: null == alignment + ? _value.alignment + : alignment // ignore: cast_nullable_to_non_nullable + as WrapAlignment, + spacing: null == spacing + ? _value.spacing + : spacing // ignore: cast_nullable_to_non_nullable + as double, + runAlignment: null == runAlignment + ? _value.runAlignment + : runAlignment // ignore: cast_nullable_to_non_nullable + as WrapAlignment, + runSpacing: null == runSpacing + ? _value.runSpacing + : runSpacing // ignore: cast_nullable_to_non_nullable + as double, + crossAxisAlignment: null == crossAxisAlignment + ? _value.crossAxisAlignment + : crossAxisAlignment // ignore: cast_nullable_to_non_nullable + as WrapCrossAlignment, + textDirection: freezed == textDirection + ? _value.textDirection + : textDirection // ignore: cast_nullable_to_non_nullable + as TextDirection?, + verticalDirection: null == verticalDirection + ? _value.verticalDirection + : verticalDirection // ignore: cast_nullable_to_non_nullable + as VerticalDirection, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + children: null == children + ? _value.children + : children // ignore: cast_nullable_to_non_nullable + as List>, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiWrapImplCopyWith<$Res> + implements $MiraiWrapCopyWith<$Res> { + factory _$$MiraiWrapImplCopyWith( + _$MiraiWrapImpl value, $Res Function(_$MiraiWrapImpl) then) = + __$$MiraiWrapImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Axis direction, + WrapAlignment alignment, + double spacing, + WrapAlignment runAlignment, + double runSpacing, + WrapCrossAlignment crossAxisAlignment, + TextDirection? textDirection, + VerticalDirection verticalDirection, + Clip clipBehavior, + List> children}); +} + +/// @nodoc +class __$$MiraiWrapImplCopyWithImpl<$Res> + extends _$MiraiWrapCopyWithImpl<$Res, _$MiraiWrapImpl> + implements _$$MiraiWrapImplCopyWith<$Res> { + __$$MiraiWrapImplCopyWithImpl( + _$MiraiWrapImpl _value, $Res Function(_$MiraiWrapImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? direction = null, + Object? alignment = null, + Object? spacing = null, + Object? runAlignment = null, + Object? runSpacing = null, + Object? crossAxisAlignment = null, + Object? textDirection = freezed, + Object? verticalDirection = null, + Object? clipBehavior = null, + Object? children = null, + }) { + return _then(_$MiraiWrapImpl( + direction: null == direction + ? _value.direction + : direction // ignore: cast_nullable_to_non_nullable + as Axis, + alignment: null == alignment + ? _value.alignment + : alignment // ignore: cast_nullable_to_non_nullable + as WrapAlignment, + spacing: null == spacing + ? _value.spacing + : spacing // ignore: cast_nullable_to_non_nullable + as double, + runAlignment: null == runAlignment + ? _value.runAlignment + : runAlignment // ignore: cast_nullable_to_non_nullable + as WrapAlignment, + runSpacing: null == runSpacing + ? _value.runSpacing + : runSpacing // ignore: cast_nullable_to_non_nullable + as double, + crossAxisAlignment: null == crossAxisAlignment + ? _value.crossAxisAlignment + : crossAxisAlignment // ignore: cast_nullable_to_non_nullable + as WrapCrossAlignment, + textDirection: freezed == textDirection + ? _value.textDirection + : textDirection // ignore: cast_nullable_to_non_nullable + as TextDirection?, + verticalDirection: null == verticalDirection + ? _value.verticalDirection + : verticalDirection // ignore: cast_nullable_to_non_nullable + as VerticalDirection, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + children: null == children + ? _value._children + : children // ignore: cast_nullable_to_non_nullable + as List>, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiWrapImpl implements _MiraiWrap { + const _$MiraiWrapImpl( + {this.direction = Axis.horizontal, + this.alignment = WrapAlignment.start, + this.spacing = 0.0, + this.runAlignment = WrapAlignment.start, + this.runSpacing = 0.0, + this.crossAxisAlignment = WrapCrossAlignment.start, + this.textDirection, + this.verticalDirection = VerticalDirection.down, + this.clipBehavior = Clip.none, + final List> children = const []}) + : _children = children; + + factory _$MiraiWrapImpl.fromJson(Map json) => + _$$MiraiWrapImplFromJson(json); + + @override + @JsonKey() + final Axis direction; + @override + @JsonKey() + final WrapAlignment alignment; + @override + @JsonKey() + final double spacing; + @override + @JsonKey() + final WrapAlignment runAlignment; + @override + @JsonKey() + final double runSpacing; + @override + @JsonKey() + final WrapCrossAlignment crossAxisAlignment; + @override + final TextDirection? textDirection; + @override + @JsonKey() + final VerticalDirection verticalDirection; + @override + @JsonKey() + final Clip clipBehavior; + final List> _children; + @override + @JsonKey() + List> get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); + } + + @override + String toString() { + return 'MiraiWrap(direction: $direction, alignment: $alignment, spacing: $spacing, runAlignment: $runAlignment, runSpacing: $runSpacing, crossAxisAlignment: $crossAxisAlignment, textDirection: $textDirection, verticalDirection: $verticalDirection, clipBehavior: $clipBehavior, children: $children)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiWrapImpl && + (identical(other.direction, direction) || + other.direction == direction) && + (identical(other.alignment, alignment) || + other.alignment == alignment) && + (identical(other.spacing, spacing) || other.spacing == spacing) && + (identical(other.runAlignment, runAlignment) || + other.runAlignment == runAlignment) && + (identical(other.runSpacing, runSpacing) || + other.runSpacing == runSpacing) && + (identical(other.crossAxisAlignment, crossAxisAlignment) || + other.crossAxisAlignment == crossAxisAlignment) && + (identical(other.textDirection, textDirection) || + other.textDirection == textDirection) && + (identical(other.verticalDirection, verticalDirection) || + other.verticalDirection == verticalDirection) && + (identical(other.clipBehavior, clipBehavior) || + other.clipBehavior == clipBehavior) && + const DeepCollectionEquality().equals(other._children, _children)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + direction, + alignment, + spacing, + runAlignment, + runSpacing, + crossAxisAlignment, + textDirection, + verticalDirection, + clipBehavior, + const DeepCollectionEquality().hash(_children)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiWrapImplCopyWith<_$MiraiWrapImpl> get copyWith => + __$$MiraiWrapImplCopyWithImpl<_$MiraiWrapImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiWrapImplToJson( + this, + ); + } +} + +abstract class _MiraiWrap implements MiraiWrap { + const factory _MiraiWrap( + {final Axis direction, + final WrapAlignment alignment, + final double spacing, + final WrapAlignment runAlignment, + final double runSpacing, + final WrapCrossAlignment crossAxisAlignment, + final TextDirection? textDirection, + final VerticalDirection verticalDirection, + final Clip clipBehavior, + final List> children}) = _$MiraiWrapImpl; + + factory _MiraiWrap.fromJson(Map json) = + _$MiraiWrapImpl.fromJson; + + @override + Axis get direction; + @override + WrapAlignment get alignment; + @override + double get spacing; + @override + WrapAlignment get runAlignment; + @override + double get runSpacing; + @override + WrapCrossAlignment get crossAxisAlignment; + @override + TextDirection? get textDirection; + @override + VerticalDirection get verticalDirection; + @override + Clip get clipBehavior; + @override + List> get children; + @override + @JsonKey(ignore: true) + _$$MiraiWrapImplCopyWith<_$MiraiWrapImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.g.dart b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.g.dart new file mode 100644 index 00000000..ea442a68 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.g.dart @@ -0,0 +1,88 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_wrap.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiWrapImpl _$$MiraiWrapImplFromJson(Map json) => + _$MiraiWrapImpl( + direction: $enumDecodeNullable(_$AxisEnumMap, json['direction']) ?? + Axis.horizontal, + alignment: + $enumDecodeNullable(_$WrapAlignmentEnumMap, json['alignment']) ?? + WrapAlignment.start, + spacing: (json['spacing'] as num?)?.toDouble() ?? 0.0, + runAlignment: + $enumDecodeNullable(_$WrapAlignmentEnumMap, json['runAlignment']) ?? + WrapAlignment.start, + runSpacing: (json['runSpacing'] as num?)?.toDouble() ?? 0.0, + crossAxisAlignment: $enumDecodeNullable( + _$WrapCrossAlignmentEnumMap, json['crossAxisAlignment']) ?? + WrapCrossAlignment.start, + textDirection: + $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), + verticalDirection: $enumDecodeNullable( + _$VerticalDirectionEnumMap, json['verticalDirection']) ?? + VerticalDirection.down, + clipBehavior: + $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.none, + children: (json['children'] as List?) + ?.map((e) => e as Map) + .toList() ?? + const [], + ); + +Map _$$MiraiWrapImplToJson(_$MiraiWrapImpl instance) => + { + 'direction': _$AxisEnumMap[instance.direction]!, + 'alignment': _$WrapAlignmentEnumMap[instance.alignment]!, + 'spacing': instance.spacing, + 'runAlignment': _$WrapAlignmentEnumMap[instance.runAlignment]!, + 'runSpacing': instance.runSpacing, + 'crossAxisAlignment': + _$WrapCrossAlignmentEnumMap[instance.crossAxisAlignment]!, + 'textDirection': _$TextDirectionEnumMap[instance.textDirection], + 'verticalDirection': + _$VerticalDirectionEnumMap[instance.verticalDirection]!, + 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, + 'children': instance.children, + }; + +const _$AxisEnumMap = { + Axis.horizontal: 'horizontal', + Axis.vertical: 'vertical', +}; + +const _$WrapAlignmentEnumMap = { + WrapAlignment.start: 'start', + WrapAlignment.end: 'end', + WrapAlignment.center: 'center', + WrapAlignment.spaceBetween: 'spaceBetween', + WrapAlignment.spaceAround: 'spaceAround', + WrapAlignment.spaceEvenly: 'spaceEvenly', +}; + +const _$WrapCrossAlignmentEnumMap = { + WrapCrossAlignment.start: 'start', + WrapCrossAlignment.end: 'end', + WrapCrossAlignment.center: 'center', +}; + +const _$TextDirectionEnumMap = { + TextDirection.rtl: 'rtl', + TextDirection.ltr: 'ltr', +}; + +const _$VerticalDirectionEnumMap = { + VerticalDirection.up: 'up', + VerticalDirection.down: 'down', +}; + +const _$ClipEnumMap = { + Clip.none: 'none', + Clip.hardEdge: 'hardEdge', + Clip.antiAlias: 'antiAlias', + Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart new file mode 100644 index 00000000..ca53a6ff --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiWrapParser extends MiraiParser { + const MiraiWrapParser(); + + @override + String get type => WidgetType.wrap.name; + + @override + MiraiWrap getModel(Map json) => MiraiWrap.fromJson(json); + + @override + Widget parse(BuildContext context, MiraiWrap model) { + return Wrap( + direction: model.direction, + alignment: model.alignment, + spacing: model.spacing, + runAlignment: model.runAlignment, + runSpacing: model.runSpacing, + crossAxisAlignment: model.crossAxisAlignment, + textDirection: model.textDirection, + verticalDirection: model.verticalDirection, + clipBehavior: model.clipBehavior, + children: model.children + .map((e) => Mirai.fromJson(e, context) ?? const SizedBox()) + .toList(), + ); + } +} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index e0f0596c..f2df2797 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -72,3 +72,4 @@ export 'package:mirai/src/parsers/mirai_text_field/mirai_text_field.dart'; export 'package:mirai/src/parsers/mirai_text_form_field/mirai_text_form_field.dart'; export 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart'; export 'package:mirai/src/parsers/mirai_theme/mirai_theme.dart'; +export 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 59f622f5..97b96b1a 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -46,4 +46,5 @@ enum WidgetType { gridView, defaultBottomNavigationController, bottomNavigationView, + wrap, }