From 985179a43b6862ca79b3869864b7c91ff4172c37 Mon Sep 17 00:00:00 2001 From: Tomiwa Idowu Date: Fri, 10 May 2024 03:31:54 +0100 Subject: [PATCH 1/2] Add support for spacer widget --- .../assets/json/home_screen.json | 31 ++++ .../assets/json/spacer_example.json | 84 ++++++++++ packages/mirai/lib/src/framework/mirai.dart | 1 + .../mirai_mirai_spacer.dart | 16 ++ .../mirai_mirai_spacer.freezed.dart | 153 ++++++++++++++++++ .../mirai_mirai_spacer.g.dart | 19 +++ .../mirai_mirai_spacer_parser.dart | 20 +++ packages/mirai/lib/src/parsers/parsers.dart | 1 + packages/mirai/lib/src/utils/widget_type.dart | 1 + 9 files changed, 326 insertions(+) create mode 100644 examples/mirai_gallery/assets/json/spacer_example.json create mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index d5ae51c4..45cd5df3 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -836,6 +836,37 @@ } } }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "space_dashboard" + }, + "title": { + "type": "text", + "data": "Mirai Spacer", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Creates an adjustable, empty spacer that can be used to tune the spacing between widgets in a Flex container.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/spacer_example.json" + } + } + }, { "type": "listTile", "leading": { diff --git a/examples/mirai_gallery/assets/json/spacer_example.json b/examples/mirai_gallery/assets/json/spacer_example.json new file mode 100644 index 00000000..bb5fa28d --- /dev/null +++ b/examples/mirai_gallery/assets/json/spacer_example.json @@ -0,0 +1,84 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Spacer" + } + }, + "body": { + "type": "padding", + "padding": { + "left": 20, + "right": 20, + "top": 20, + "bottom": 20 + }, + "child": { + "type": "column", + "children": [ + { + "type": "textField", + "keyboardType": "text", + "maxLines": 1, + "decoration": { + "hintText": "Enter your pin" + } + }, + { + "type": "spacer" + }, + { + "type": "row", + "children": [ + { + "type": "row", + "children": [ + { + "type": "text", + "data": "Forgot Pin", + "style": { + "fontSize": 17 + } + }, + { + "type": "icon", + "iconType": "material", + "icon": "keyboard_arrow_right", + "size": 24 + } + ] + }, + { + "type": "spacer" + }, + { + "type": "text", + "data": "Need help?", + "style": { + "fontSize": 17 + } + } + ] + }, + { + "type": "spacer", + "flex": 2 + }, + { + "type": "elevatedButton", + "child": { + "type": "text", + "data": "Submit" + }, + "style": { + "backgroundColor": "primary", + "foregroundColor": "#ffffff" + }, + "onPressed": {} + } + ] + } + } + } \ 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 dfc4485e..6246a49d 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -56,6 +56,7 @@ class Mirai { const MiraiCheckBoxWidgetParser(), const MiraiExpandedParser(), const MiraiFlexibleParser(), + const MiraiMiraiSpacerParser(), const MiraiSafeAreaParser(), const MiraiSwitchParser(), const MiraiAlignParser(), diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart new file mode 100644 index 00000000..149aae67 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart'; + +part 'mirai_mirai_spacer.freezed.dart'; +part 'mirai_mirai_spacer.g.dart'; + +@freezed +class MiraiMiraiSpacer with _$MiraiMiraiSpacer { + const factory MiraiMiraiSpacer({ + @Default(1) int flex, + }) = _MiraiMiraiSpacer; + + factory MiraiMiraiSpacer.fromJson(Map json) => + _$MiraiMiraiSpacerFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart new file mode 100644 index 00000000..a806e019 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart @@ -0,0 +1,153 @@ +// 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_mirai_spacer.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'); + +MiraiMiraiSpacer _$MiraiMiraiSpacerFromJson(Map json) { + return _MiraiMiraiSpacer.fromJson(json); +} + +/// @nodoc +mixin _$MiraiMiraiSpacer { + int get flex => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiMiraiSpacerCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiMiraiSpacerCopyWith<$Res> { + factory $MiraiMiraiSpacerCopyWith( + MiraiMiraiSpacer value, $Res Function(MiraiMiraiSpacer) then) = + _$MiraiMiraiSpacerCopyWithImpl<$Res, MiraiMiraiSpacer>; + @useResult + $Res call({int flex}); +} + +/// @nodoc +class _$MiraiMiraiSpacerCopyWithImpl<$Res, $Val extends MiraiMiraiSpacer> + implements $MiraiMiraiSpacerCopyWith<$Res> { + _$MiraiMiraiSpacerCopyWithImpl(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? flex = null, + }) { + return _then(_value.copyWith( + flex: null == flex + ? _value.flex + : flex // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiMiraiSpacerImplCopyWith<$Res> + implements $MiraiMiraiSpacerCopyWith<$Res> { + factory _$$MiraiMiraiSpacerImplCopyWith(_$MiraiMiraiSpacerImpl value, + $Res Function(_$MiraiMiraiSpacerImpl) then) = + __$$MiraiMiraiSpacerImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int flex}); +} + +/// @nodoc +class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res> + extends _$MiraiMiraiSpacerCopyWithImpl<$Res, _$MiraiMiraiSpacerImpl> + implements _$$MiraiMiraiSpacerImplCopyWith<$Res> { + __$$MiraiMiraiSpacerImplCopyWithImpl(_$MiraiMiraiSpacerImpl _value, + $Res Function(_$MiraiMiraiSpacerImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? flex = null, + }) { + return _then(_$MiraiMiraiSpacerImpl( + flex: null == flex + ? _value.flex + : flex // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer { + const _$MiraiMiraiSpacerImpl({this.flex = 1}); + + factory _$MiraiMiraiSpacerImpl.fromJson(Map json) => + _$$MiraiMiraiSpacerImplFromJson(json); + + @override + @JsonKey() + final int flex; + + @override + String toString() { + return 'MiraiMiraiSpacer(flex: $flex)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiMiraiSpacerImpl && + (identical(other.flex, flex) || other.flex == flex)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, flex); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith => + __$$MiraiMiraiSpacerImplCopyWithImpl<_$MiraiMiraiSpacerImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiMiraiSpacerImplToJson( + this, + ); + } +} + +abstract class _MiraiMiraiSpacer implements MiraiMiraiSpacer { + const factory _MiraiMiraiSpacer({final int flex}) = _$MiraiMiraiSpacerImpl; + + factory _MiraiMiraiSpacer.fromJson(Map json) = + _$MiraiMiraiSpacerImpl.fromJson; + + @override + int get flex; + @override + @JsonKey(ignore: true) + _$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart new file mode 100644 index 00000000..f4e86aac --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_mirai_spacer.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiMiraiSpacerImpl _$$MiraiMiraiSpacerImplFromJson( + Map json) => + _$MiraiMiraiSpacerImpl( + flex: (json['flex'] as num?)?.toInt() ?? 1, + ); + +Map _$$MiraiMiraiSpacerImplToJson( + _$MiraiMiraiSpacerImpl instance) => + { + 'flex': instance.flex, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart new file mode 100644 index 00000000..daa68317 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart'; +import 'package:mirai/src/utils/widget_type.dart'; +import 'package:mirai_framework/mirai_framework.dart'; + +class MiraiMiraiSpacerParser extends MiraiParser { + const MiraiMiraiSpacerParser(); + + @override + MiraiMiraiSpacer getModel(Map json) => + MiraiMiraiSpacer.fromJson(json); + + @override + String get type => WidgetType.spacer.name; + + @override + Widget parse(BuildContext context, MiraiMiraiSpacer model) { + return Spacer(flex: model.flex); + } +} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 66f2a8f0..f9a5dc67 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -47,6 +47,7 @@ export 'package:mirai/src/parsers/mirai_input_formatters/mirai_input_formatter.d export 'package:mirai/src/parsers/mirai_list_tile/mirai_list_tile.dart'; export 'package:mirai/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.dart'; export 'package:mirai/src/parsers/mirai_list_view/mirai_list_view.dart'; +export 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart'; export 'package:mirai/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart'; export 'package:mirai/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.dart'; export 'package:mirai/src/parsers/mirai_network_widget/mirai_network_widget.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index d27c5716..0f9a4785 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -35,6 +35,7 @@ enum WidgetType { checkBox, expanded, flexible, + spacer, safeArea, align, pageView, From a4b73445b168a7b25632323020a83e59bba7f33b Mon Sep 17 00:00:00 2001 From: Tomiwa Idowu Date: Fri, 10 May 2024 22:29:22 +0100 Subject: [PATCH 2/2] Add support for spacer widget --- packages/mirai/lib/src/framework/mirai.dart | 2 +- .../mirai_mirai_spacer.dart | 16 ---- .../mirai_mirai_spacer_parser.dart | 20 ----- .../parsers/mirai_spacer/mirai_spacer.dart | 16 ++++ .../mirai_spacer.freezed.dart} | 75 +++++++++---------- .../mirai_spacer.g.dart} | 10 +-- .../mirai_spacer/mirai_spacer_parser.dart | 19 +++++ packages/mirai/lib/src/parsers/parsers.dart | 2 +- 8 files changed, 78 insertions(+), 82 deletions(-) delete mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart rename packages/mirai/lib/src/parsers/{mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart => mirai_spacer/mirai_spacer.freezed.dart} (55%) rename packages/mirai/lib/src/parsers/{mirai_mirai_spacer/mirai_mirai_spacer.g.dart => mirai_spacer/mirai_spacer.g.dart} (57%) create mode 100644 packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer_parser.dart diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 6246a49d..d4892d7a 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -56,7 +56,7 @@ class Mirai { const MiraiCheckBoxWidgetParser(), const MiraiExpandedParser(), const MiraiFlexibleParser(), - const MiraiMiraiSpacerParser(), + const MiraiSpacerParser(), const MiraiSafeAreaParser(), const MiraiSwitchParser(), const MiraiAlignParser(), diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart deleted file mode 100644 index 149aae67..00000000 --- a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart'; - -part 'mirai_mirai_spacer.freezed.dart'; -part 'mirai_mirai_spacer.g.dart'; - -@freezed -class MiraiMiraiSpacer with _$MiraiMiraiSpacer { - const factory MiraiMiraiSpacer({ - @Default(1) int flex, - }) = _MiraiMiraiSpacer; - - factory MiraiMiraiSpacer.fromJson(Map json) => - _$MiraiMiraiSpacerFromJson(json); -} diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart b/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart deleted file mode 100644 index daa68317..00000000 --- a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer_parser.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart'; -import 'package:mirai/src/utils/widget_type.dart'; -import 'package:mirai_framework/mirai_framework.dart'; - -class MiraiMiraiSpacerParser extends MiraiParser { - const MiraiMiraiSpacerParser(); - - @override - MiraiMiraiSpacer getModel(Map json) => - MiraiMiraiSpacer.fromJson(json); - - @override - String get type => WidgetType.spacer.name; - - @override - Widget parse(BuildContext context, MiraiMiraiSpacer model) { - return Spacer(flex: model.flex); - } -} diff --git a/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart new file mode 100644 index 00000000..03bff161 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'package:mirai/src/parsers/mirai_spacer/mirai_spacer_parser.dart'; + +part 'mirai_spacer.freezed.dart'; +part 'mirai_spacer.g.dart'; + +@freezed +class MiraiSpacer with _$MiraiSpacer { + const factory MiraiSpacer({ + @Default(1) int flex, + }) = _MiraiSpacer; + + factory MiraiSpacer.fromJson(Map json) => + _$MiraiSpacerFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.freezed.dart similarity index 55% rename from packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart rename to packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.freezed.dart index a806e019..931b1e44 100644 --- a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.freezed.dart @@ -3,7 +3,7 @@ // 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_mirai_spacer.dart'; +part of 'mirai_spacer.dart'; // ************************************************************************** // FreezedGenerator @@ -14,33 +14,33 @@ 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'); -MiraiMiraiSpacer _$MiraiMiraiSpacerFromJson(Map json) { - return _MiraiMiraiSpacer.fromJson(json); +MiraiSpacer _$MiraiSpacerFromJson(Map json) { + return _MiraiSpacer.fromJson(json); } /// @nodoc -mixin _$MiraiMiraiSpacer { +mixin _$MiraiSpacer { int get flex => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) - $MiraiMiraiSpacerCopyWith get copyWith => + $MiraiSpacerCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $MiraiMiraiSpacerCopyWith<$Res> { - factory $MiraiMiraiSpacerCopyWith( - MiraiMiraiSpacer value, $Res Function(MiraiMiraiSpacer) then) = - _$MiraiMiraiSpacerCopyWithImpl<$Res, MiraiMiraiSpacer>; +abstract class $MiraiSpacerCopyWith<$Res> { + factory $MiraiSpacerCopyWith( + MiraiSpacer value, $Res Function(MiraiSpacer) then) = + _$MiraiSpacerCopyWithImpl<$Res, MiraiSpacer>; @useResult $Res call({int flex}); } /// @nodoc -class _$MiraiMiraiSpacerCopyWithImpl<$Res, $Val extends MiraiMiraiSpacer> - implements $MiraiMiraiSpacerCopyWith<$Res> { - _$MiraiMiraiSpacerCopyWithImpl(this._value, this._then); +class _$MiraiSpacerCopyWithImpl<$Res, $Val extends MiraiSpacer> + implements $MiraiSpacerCopyWith<$Res> { + _$MiraiSpacerCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; @@ -62,22 +62,22 @@ class _$MiraiMiraiSpacerCopyWithImpl<$Res, $Val extends MiraiMiraiSpacer> } /// @nodoc -abstract class _$$MiraiMiraiSpacerImplCopyWith<$Res> - implements $MiraiMiraiSpacerCopyWith<$Res> { - factory _$$MiraiMiraiSpacerImplCopyWith(_$MiraiMiraiSpacerImpl value, - $Res Function(_$MiraiMiraiSpacerImpl) then) = - __$$MiraiMiraiSpacerImplCopyWithImpl<$Res>; +abstract class _$$MiraiSpacerImplCopyWith<$Res> + implements $MiraiSpacerCopyWith<$Res> { + factory _$$MiraiSpacerImplCopyWith( + _$MiraiSpacerImpl value, $Res Function(_$MiraiSpacerImpl) then) = + __$$MiraiSpacerImplCopyWithImpl<$Res>; @override @useResult $Res call({int flex}); } /// @nodoc -class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res> - extends _$MiraiMiraiSpacerCopyWithImpl<$Res, _$MiraiMiraiSpacerImpl> - implements _$$MiraiMiraiSpacerImplCopyWith<$Res> { - __$$MiraiMiraiSpacerImplCopyWithImpl(_$MiraiMiraiSpacerImpl _value, - $Res Function(_$MiraiMiraiSpacerImpl) _then) +class __$$MiraiSpacerImplCopyWithImpl<$Res> + extends _$MiraiSpacerCopyWithImpl<$Res, _$MiraiSpacerImpl> + implements _$$MiraiSpacerImplCopyWith<$Res> { + __$$MiraiSpacerImplCopyWithImpl( + _$MiraiSpacerImpl _value, $Res Function(_$MiraiSpacerImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -85,7 +85,7 @@ class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res> $Res call({ Object? flex = null, }) { - return _then(_$MiraiMiraiSpacerImpl( + return _then(_$MiraiSpacerImpl( flex: null == flex ? _value.flex : flex // ignore: cast_nullable_to_non_nullable @@ -96,11 +96,11 @@ class __$$MiraiMiraiSpacerImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer { - const _$MiraiMiraiSpacerImpl({this.flex = 1}); +class _$MiraiSpacerImpl implements _MiraiSpacer { + const _$MiraiSpacerImpl({this.flex = 1}); - factory _$MiraiMiraiSpacerImpl.fromJson(Map json) => - _$$MiraiMiraiSpacerImplFromJson(json); + factory _$MiraiSpacerImpl.fromJson(Map json) => + _$$MiraiSpacerImplFromJson(json); @override @JsonKey() @@ -108,14 +108,14 @@ class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer { @override String toString() { - return 'MiraiMiraiSpacer(flex: $flex)'; + return 'MiraiSpacer(flex: $flex)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$MiraiMiraiSpacerImpl && + other is _$MiraiSpacerImpl && (identical(other.flex, flex) || other.flex == flex)); } @@ -126,28 +126,27 @@ class _$MiraiMiraiSpacerImpl implements _MiraiMiraiSpacer { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith => - __$$MiraiMiraiSpacerImplCopyWithImpl<_$MiraiMiraiSpacerImpl>( - this, _$identity); + _$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith => + __$$MiraiSpacerImplCopyWithImpl<_$MiraiSpacerImpl>(this, _$identity); @override Map toJson() { - return _$$MiraiMiraiSpacerImplToJson( + return _$$MiraiSpacerImplToJson( this, ); } } -abstract class _MiraiMiraiSpacer implements MiraiMiraiSpacer { - const factory _MiraiMiraiSpacer({final int flex}) = _$MiraiMiraiSpacerImpl; +abstract class _MiraiSpacer implements MiraiSpacer { + const factory _MiraiSpacer({final int flex}) = _$MiraiSpacerImpl; - factory _MiraiMiraiSpacer.fromJson(Map json) = - _$MiraiMiraiSpacerImpl.fromJson; + factory _MiraiSpacer.fromJson(Map json) = + _$MiraiSpacerImpl.fromJson; @override int get flex; @override @JsonKey(ignore: true) - _$$MiraiMiraiSpacerImplCopyWith<_$MiraiMiraiSpacerImpl> get copyWith => + _$$MiraiSpacerImplCopyWith<_$MiraiSpacerImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.g.dart similarity index 57% rename from packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart rename to packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.g.dart index f4e86aac..07dca6e5 100644 --- a/packages/mirai/lib/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer.g.dart @@ -1,19 +1,17 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'mirai_mirai_spacer.dart'; +part of 'mirai_spacer.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$MiraiMiraiSpacerImpl _$$MiraiMiraiSpacerImplFromJson( - Map json) => - _$MiraiMiraiSpacerImpl( +_$MiraiSpacerImpl _$$MiraiSpacerImplFromJson(Map json) => + _$MiraiSpacerImpl( flex: (json['flex'] as num?)?.toInt() ?? 1, ); -Map _$$MiraiMiraiSpacerImplToJson( - _$MiraiMiraiSpacerImpl instance) => +Map _$$MiraiSpacerImplToJson(_$MiraiSpacerImpl instance) => { 'flex': instance.flex, }; diff --git a/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer_parser.dart b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer_parser.dart new file mode 100644 index 00000000..e7acd19f --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_spacer/mirai_spacer_parser.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/src/parsers/mirai_spacer/mirai_spacer.dart'; +import 'package:mirai/src/utils/widget_type.dart'; +import 'package:mirai_framework/mirai_framework.dart'; + +class MiraiSpacerParser extends MiraiParser { + const MiraiSpacerParser(); + + @override + MiraiSpacer getModel(Map json) => MiraiSpacer.fromJson(json); + + @override + String get type => WidgetType.spacer.name; + + @override + Widget parse(BuildContext context, MiraiSpacer model) { + return Spacer(flex: model.flex); + } +} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index f9a5dc67..97fd4402 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -47,7 +47,6 @@ export 'package:mirai/src/parsers/mirai_input_formatters/mirai_input_formatter.d export 'package:mirai/src/parsers/mirai_list_tile/mirai_list_tile.dart'; export 'package:mirai/src/parsers/mirai_list_tile_theme_data/mirai_list_tile_theme_data.dart'; export 'package:mirai/src/parsers/mirai_list_view/mirai_list_view.dart'; -export 'package:mirai/src/parsers/mirai_mirai_spacer/mirai_mirai_spacer.dart'; export 'package:mirai/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart'; export 'package:mirai/src/parsers/mirai_navigation_bar_theme_data/mirai_navigation_bar_theme_data.dart'; export 'package:mirai/src/parsers/mirai_network_widget/mirai_network_widget.dart'; @@ -62,6 +61,7 @@ export 'package:mirai/src/parsers/mirai_scaffold/mirai_scaffold.dart'; export 'package:mirai/src/parsers/mirai_single_child_scroll_view/mirai_single_child_scroll_view.dart'; export 'package:mirai/src/parsers/mirai_size/mirai_size.dart'; export 'package:mirai/src/parsers/mirai_sized_box/mirai_sized_box.dart'; +export 'package:mirai/src/parsers/mirai_spacer/mirai_spacer.dart'; export 'package:mirai/src/parsers/mirai_stack/mirai_stack.dart'; export 'package:mirai/src/parsers/mirai_switch/mirai_switch.dart'; export 'package:mirai/src/parsers/mirai_tab/mirai_tab.dart';