From 591691bf063078fa098cfb22acd0bb3634dc6491 Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 01:45:12 +0400 Subject: [PATCH 01/24] Add support for Filled Button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created a Mirai Filled Button Parser ✅ - Added example to the Mirai gallery ✅ --- .../assets/json/filled_button_example.json | 310 +++++++++++++++ .../assets/json/home_screen.json | 34 ++ packages/mirai/lib/src/framework/mirai.dart | 1 + .../mirai_filled_button.dart | 23 ++ .../mirai_filled_button.freezed.dart | 376 ++++++++++++++++++ .../mirai_filled_button.g.dart | 43 ++ .../mirai_filled_button_parser.dart | 35 ++ packages/mirai/lib/src/parsers/parsers.dart | 1 + packages/mirai/lib/src/utils/widget_type.dart | 1 + 9 files changed, 824 insertions(+) create mode 100644 examples/mirai_gallery/assets/json/filled_button_example.json create mode 100644 packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart diff --git a/examples/mirai_gallery/assets/json/filled_button_example.json b/examples/mirai_gallery/assets/json/filled_button_example.json new file mode 100644 index 00000000..cdd5688e --- /dev/null +++ b/examples/mirai_gallery/assets/json/filled_button_example.json @@ -0,0 +1,310 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Filled Button" + } + }, + "body": { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "column", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "filledButton", + "child": { + "type": "text", + "data": "BUTTON" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + }, + "onPressed": {} + }, + { + "type": "sizedBox", + "width": 20 + }, + { + "type": "filledButton", + "child": { + "type": "row", + "children": [ + { + "type": "icon", + "iconType": "material", + "icon": "add", + "size": 18 + }, + { + "type": "sizedBox", + "width": 4 + }, + { + "type": "text", + "data": "BUTTON" + } + ] + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + }, + "onPressed": {} + } + ] + }, + { + "type": "sizedBox", + "height": 12 + }, + { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "filledButton", + "child": { + "type": "text", + "data": "BUTTON" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + }, + "shape": { + "borderRadius": { + "topLeft": 8, + "topRight": 8, + "bottomLeft": 8, + "bottomRight": 8 + } + } + }, + "onPressed": {} + }, + { + "type": "sizedBox", + "width": 20 + }, + { + "type": "filledButton", + "child": { + "type": "row", + "children": [ + { + "type": "icon", + "iconType": "material", + "icon": "add", + "size": 18 + }, + { + "type": "sizedBox", + "width": 4 + }, + { + "type": "text", + "data": "BUTTON" + } + ] + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + }, + "shape": { + "borderRadius": { + "topLeft": 8, + "topRight": 8, + "bottomLeft": 8, + "bottomRight": 8 + } + } + }, + "onPressed": {} + } + ] + }, + { + "type": "sizedBox", + "height": 12 + }, + { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "filledButton", + "child": { + "type": "text", + "data": "BUTTON" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + } + }, + { + "type": "sizedBox", + "width": 20 + }, + { + "type": "filledButton", + "child": { + "type": "row", + "children": [ + { + "type": "icon", + "iconType": "material", + "icon": "add", + "size": 18 + }, + { + "type": "sizedBox", + "width": 4 + }, + { + "type": "text", + "data": "BUTTON" + } + ] + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + } + } + ] + }, + { + "type": "sizedBox", + "height": 12 + }, + { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "filledButton", + "child": { + "type": "text", + "data": "BUTTON" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + }, + "shape": { + "side": { + "color": "#ff5454", + "width": 1, + "strokeAlign": 0, + "borderStyle": "solid" + }, + "borderRadius": { + "topLeft": 8, + "topRight": 8, + "bottomLeft": 8, + "bottomRight": 8 + } + } + }, + "onPressed": {} + }, + { + "type": "sizedBox", + "width": 20 + }, + { + "type": "filledButton", + "child": { + "type": "row", + "children": [ + { + "type": "icon", + "iconType": "material", + "icon": "add", + "size": 18 + }, + { + "type": "sizedBox", + "width": 4 + }, + { + "type": "text", + "data": "BUTTON" + } + ] + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + }, + "shape": { + "side": { + "color": "#ff5454", + "width": 1, + "strokeAlign": 0, + "borderStyle": "solid" + }, + "borderRadius": { + "topLeft": 8, + "topRight": 8, + "bottomLeft": 8, + "bottomRight": 8 + } + } + }, + "onPressed": {} + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 97c66f93..1263e483 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": "smart_button" + }, + "title": { + "type": "text", + "data": "Filled Button", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design filled button", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/filled_button_example.json" + } + } } ] } diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 09cf54af..67310555 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -66,6 +66,7 @@ class Mirai { const MiraiCircleAvatarParser(), const MiraiChipParser(), const MiraiGridViewParser(), + const MiraiFilledButtonParser() ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart new file mode 100644 index 00000000..ab80cacb --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart @@ -0,0 +1,23 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import "package:mirai/src/parsers/mirai_button_style/mirai_button_style.dart"; +import 'package:flutter/material.dart'; +export 'mirai_filled_button_parser.dart'; +part 'mirai_filled_button.freezed.dart'; +part 'mirai_filled_button.g.dart'; + +@freezed +class MiraiFilledButton with _$MiraiFilledButton { + const factory MiraiFilledButton({ + Map? onPressed, + Map? onLongPress, + Map? onHover, + Map? onFocusChange, + MiraiButtonStyle? style, + @Default(false) bool autofocus, + @Default(Clip.none) Clip clipBehavior, + Map? child, + }) = _MiraiFilledButton; + + factory MiraiFilledButton.fromJson(Map json) => + _$MiraiFilledButtonFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart new file mode 100644 index 00000000..3a23b609 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart @@ -0,0 +1,376 @@ +// 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_filled_button.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'); + +MiraiFilledButton _$MiraiFilledButtonFromJson(Map json) { + return _MiraiFilledButton.fromJson(json); +} + +/// @nodoc +mixin _$MiraiFilledButton { + Map? get onPressed => throw _privateConstructorUsedError; + Map? get onLongPress => throw _privateConstructorUsedError; + Map? get onHover => throw _privateConstructorUsedError; + Map? get onFocusChange => throw _privateConstructorUsedError; + MiraiButtonStyle? get style => throw _privateConstructorUsedError; + bool get autofocus => throw _privateConstructorUsedError; + Clip get clipBehavior => + throw _privateConstructorUsedError; //MaterialStatesController? statesController, + Map? get child => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiFilledButtonCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiFilledButtonCopyWith<$Res> { + factory $MiraiFilledButtonCopyWith( + MiraiFilledButton value, $Res Function(MiraiFilledButton) then) = + _$MiraiFilledButtonCopyWithImpl<$Res, MiraiFilledButton>; + @useResult + $Res call( + {Map? onPressed, + Map? onLongPress, + Map? onHover, + Map? onFocusChange, + MiraiButtonStyle? style, + bool autofocus, + Clip clipBehavior, + Map? child}); + + $MiraiButtonStyleCopyWith<$Res>? get style; +} + +/// @nodoc +class _$MiraiFilledButtonCopyWithImpl<$Res, $Val extends MiraiFilledButton> + implements $MiraiFilledButtonCopyWith<$Res> { + _$MiraiFilledButtonCopyWithImpl(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? onPressed = freezed, + Object? onLongPress = freezed, + Object? onHover = freezed, + Object? onFocusChange = freezed, + Object? style = freezed, + Object? autofocus = null, + Object? clipBehavior = null, + Object? child = freezed, + }) { + return _then(_value.copyWith( + onPressed: freezed == onPressed + ? _value.onPressed + : onPressed // ignore: cast_nullable_to_non_nullable + as Map?, + onLongPress: freezed == onLongPress + ? _value.onLongPress + : onLongPress // ignore: cast_nullable_to_non_nullable + as Map?, + onHover: freezed == onHover + ? _value.onHover + : onHover // ignore: cast_nullable_to_non_nullable + as Map?, + onFocusChange: freezed == onFocusChange + ? _value.onFocusChange + : onFocusChange // ignore: cast_nullable_to_non_nullable + as Map?, + style: freezed == style + ? _value.style + : style // ignore: cast_nullable_to_non_nullable + as MiraiButtonStyle?, + autofocus: null == autofocus + ? _value.autofocus + : autofocus // ignore: cast_nullable_to_non_nullable + as bool, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + child: freezed == child + ? _value.child + : child // ignore: cast_nullable_to_non_nullable + as Map?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiButtonStyleCopyWith<$Res>? get style { + if (_value.style == null) { + return null; + } + + return $MiraiButtonStyleCopyWith<$Res>(_value.style!, (value) { + return _then(_value.copyWith(style: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiFilledButtonImplCopyWith<$Res> + implements $MiraiFilledButtonCopyWith<$Res> { + factory _$$MiraiFilledButtonImplCopyWith(_$MiraiFilledButtonImpl value, + $Res Function(_$MiraiFilledButtonImpl) then) = + __$$MiraiFilledButtonImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Map? onPressed, + Map? onLongPress, + Map? onHover, + Map? onFocusChange, + MiraiButtonStyle? style, + bool autofocus, + Clip clipBehavior, + Map? child}); + + @override + $MiraiButtonStyleCopyWith<$Res>? get style; +} + +/// @nodoc +class __$$MiraiFilledButtonImplCopyWithImpl<$Res> + extends _$MiraiFilledButtonCopyWithImpl<$Res, _$MiraiFilledButtonImpl> + implements _$$MiraiFilledButtonImplCopyWith<$Res> { + __$$MiraiFilledButtonImplCopyWithImpl(_$MiraiFilledButtonImpl _value, + $Res Function(_$MiraiFilledButtonImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? onPressed = freezed, + Object? onLongPress = freezed, + Object? onHover = freezed, + Object? onFocusChange = freezed, + Object? style = freezed, + Object? autofocus = null, + Object? clipBehavior = null, + Object? child = freezed, + }) { + return _then(_$MiraiFilledButtonImpl( + onPressed: freezed == onPressed + ? _value._onPressed + : onPressed // ignore: cast_nullable_to_non_nullable + as Map?, + onLongPress: freezed == onLongPress + ? _value._onLongPress + : onLongPress // ignore: cast_nullable_to_non_nullable + as Map?, + onHover: freezed == onHover + ? _value._onHover + : onHover // ignore: cast_nullable_to_non_nullable + as Map?, + onFocusChange: freezed == onFocusChange + ? _value._onFocusChange + : onFocusChange // ignore: cast_nullable_to_non_nullable + as Map?, + style: freezed == style + ? _value.style + : style // ignore: cast_nullable_to_non_nullable + as MiraiButtonStyle?, + autofocus: null == autofocus + ? _value.autofocus + : autofocus // ignore: cast_nullable_to_non_nullable + as bool, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + child: freezed == child + ? _value._child + : child // ignore: cast_nullable_to_non_nullable + as Map?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiFilledButtonImpl implements _MiraiFilledButton { + const _$MiraiFilledButtonImpl( + {final Map? onPressed, + final Map? onLongPress, + final Map? onHover, + final Map? onFocusChange, + this.style, + this.autofocus = false, + this.clipBehavior = Clip.none, + final Map? child}) + : _onPressed = onPressed, + _onLongPress = onLongPress, + _onHover = onHover, + _onFocusChange = onFocusChange, + _child = child; + + factory _$MiraiFilledButtonImpl.fromJson(Map json) => + _$$MiraiFilledButtonImplFromJson(json); + + final Map? _onPressed; + @override + Map? get onPressed { + final value = _onPressed; + if (value == null) return null; + if (_onPressed is EqualUnmodifiableMapView) return _onPressed; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final Map? _onLongPress; + @override + Map? get onLongPress { + final value = _onLongPress; + if (value == null) return null; + if (_onLongPress is EqualUnmodifiableMapView) return _onLongPress; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final Map? _onHover; + @override + Map? get onHover { + final value = _onHover; + if (value == null) return null; + if (_onHover is EqualUnmodifiableMapView) return _onHover; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final Map? _onFocusChange; + @override + Map? get onFocusChange { + final value = _onFocusChange; + if (value == null) return null; + if (_onFocusChange is EqualUnmodifiableMapView) return _onFocusChange; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + final MiraiButtonStyle? style; + @override + @JsonKey() + final bool autofocus; + @override + @JsonKey() + final Clip clipBehavior; +//MaterialStatesController? statesController, + final Map? _child; +//MaterialStatesController? statesController, + @override + Map? get child { + final value = _child; + if (value == null) return null; + if (_child is EqualUnmodifiableMapView) return _child; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + String toString() { + return 'MiraiFilledButton(onPressed: $onPressed, onLongPress: $onLongPress, onHover: $onHover, onFocusChange: $onFocusChange, style: $style, autofocus: $autofocus, clipBehavior: $clipBehavior, child: $child)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiFilledButtonImpl && + const DeepCollectionEquality() + .equals(other._onPressed, _onPressed) && + const DeepCollectionEquality() + .equals(other._onLongPress, _onLongPress) && + const DeepCollectionEquality().equals(other._onHover, _onHover) && + const DeepCollectionEquality() + .equals(other._onFocusChange, _onFocusChange) && + (identical(other.style, style) || other.style == style) && + (identical(other.autofocus, autofocus) || + other.autofocus == autofocus) && + (identical(other.clipBehavior, clipBehavior) || + other.clipBehavior == clipBehavior) && + const DeepCollectionEquality().equals(other._child, _child)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_onPressed), + const DeepCollectionEquality().hash(_onLongPress), + const DeepCollectionEquality().hash(_onHover), + const DeepCollectionEquality().hash(_onFocusChange), + style, + autofocus, + clipBehavior, + const DeepCollectionEquality().hash(_child)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiFilledButtonImplCopyWith<_$MiraiFilledButtonImpl> get copyWith => + __$$MiraiFilledButtonImplCopyWithImpl<_$MiraiFilledButtonImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiFilledButtonImplToJson( + this, + ); + } +} + +abstract class _MiraiFilledButton implements MiraiFilledButton { + const factory _MiraiFilledButton( + {final Map? onPressed, + final Map? onLongPress, + final Map? onHover, + final Map? onFocusChange, + final MiraiButtonStyle? style, + final bool autofocus, + final Clip clipBehavior, + final Map? child}) = _$MiraiFilledButtonImpl; + + factory _MiraiFilledButton.fromJson(Map json) = + _$MiraiFilledButtonImpl.fromJson; + + @override + Map? get onPressed; + @override + Map? get onLongPress; + @override + Map? get onHover; + @override + Map? get onFocusChange; + @override + MiraiButtonStyle? get style; + @override + bool get autofocus; + @override + Clip get clipBehavior; + @override //MaterialStatesController? statesController, + Map? get child; + @override + @JsonKey(ignore: true) + _$$MiraiFilledButtonImplCopyWith<_$MiraiFilledButtonImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.g.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.g.dart new file mode 100644 index 00000000..d9ae08c3 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.g.dart @@ -0,0 +1,43 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_filled_button.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiFilledButtonImpl _$$MiraiFilledButtonImplFromJson( + Map json) => + _$MiraiFilledButtonImpl( + onPressed: json['onPressed'] as Map?, + onLongPress: json['onLongPress'] as Map?, + onHover: json['onHover'] as Map?, + onFocusChange: json['onFocusChange'] as Map?, + style: json['style'] == null + ? null + : MiraiButtonStyle.fromJson(json['style'] as Map), + autofocus: json['autofocus'] as bool? ?? false, + clipBehavior: + $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.none, + child: json['child'] as Map?, + ); + +Map _$$MiraiFilledButtonImplToJson( + _$MiraiFilledButtonImpl instance) => + { + 'onPressed': instance.onPressed, + 'onLongPress': instance.onLongPress, + 'onHover': instance.onHover, + 'onFocusChange': instance.onFocusChange, + 'style': instance.style, + 'autofocus': instance.autofocus, + 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, + 'child': instance.child, + }; + +const _$ClipEnumMap = { + Clip.none: 'none', + Clip.hardEdge: 'hardEdge', + Clip.antiAlias: 'antiAlias', + Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart new file mode 100644 index 00000000..cddc3bcb --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiFilledButtonParser extends MiraiParser { + const MiraiFilledButtonParser(); + + @override + String get type => WidgetType.filledButton.name; + + @override + MiraiFilledButton getModel(Map json) => + MiraiFilledButton.fromJson(json); + + @override + Widget parse(BuildContext context, MiraiFilledButton model) { + FocusNode? focusNode = FocusNode(); + MaterialStatesController? materialStatesController = + MaterialStatesController(); + + return FilledButton( + onPressed: model.onPressed == null ? null : () => model.onPressed, + onLongPress: model.onLongPress == null ? null : () => model.onLongPress, + onHover: (bool value) => value == false ? null : model.onHover, + onFocusChange: (bool value) => + value == false ? null : model.onFocusChange, + style: model.style?.parseElevated(context), + autofocus: model.autofocus, + clipBehavior: model.clipBehavior, + focusNode: focusNode, + statesController: materialStatesController, + child: Mirai.fromJson(model.child, context), + ); + } +} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 3510da5e..fb591fac 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -71,3 +71,4 @@ export 'package:mirai/src/parsers/mirai_text_form_field/mirai_text_form_field.da 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_chip/mirai_chip.dart'; +export 'package:mirai/src/parsers/mirai_filled_button/mirai_filled_button.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 0b7cfd56..54d8731b 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -44,4 +44,5 @@ enum WidgetType { circleAvatar, chip, gridView, + filledButton } From e660c9e600e88d1e2b74e83239bdaed714436e56 Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 02:17:19 +0400 Subject: [PATCH 02/24] Add support for Filled Button home screen updated --- .../assets/json/home_screen.json | 1183 +---------------- 1 file changed, 1 insertion(+), 1182 deletions(-) diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index c94a7de5..732541fd 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -889,37 +889,6 @@ } } }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "grid_view" - }, - "title": { - "type": "text", - "data": "Mirai GridView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, 2D array of widgets that are created on demand.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/grid_view_example.json" - } - } - }, { "type": "listTile", "leading": { @@ -1146,7 +1115,7 @@ } } }, - { + { "type": "listTile", "leading": { "type": "icon", @@ -1183,1154 +1152,4 @@ ] } } - "type": "scaffold", - "appBar": { - "type": "appBar", - "title": { - "type": "text", - "data": "Mirai Gallery" - }, - "elevation": 0 - }, - "body": { - "type": "padding", - "padding": { - "bottom": 24 - }, - "child": { - "type": "listView", - "shrinkWrap": true, - "separator": { - "type": "container", - "height": 10 - }, - "children": [ - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "app_fill" - }, - "title": { - "type": "text", - "data": "Mirai Appbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Displays information and actions relating to the current screen", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/app_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Bottom navigation with cross-fading views", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_nav_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Sheet", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design Mirai bottom sheet example", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_sheet_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "wallet_giftcard" - }, - "title": { - "type": "text", - "data": "Mirai Card", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Card is a sheet of material used to represent some related information", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/card_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that centers its child within itself.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/center_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Align", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/align_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Column", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai column widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/column_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "add_alert" - }, - "title": { - "type": "text", - "data": "Mirai Dialog", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Informs the user about situations that require acknowledgement", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/dialog_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "layers" - }, - "title": { - "type": "text", - "data": "Mirai Stack", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai stack widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/stack_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "apartment" - }, - "title": { - "type": "text", - "data": "Mirai Container", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Container combines common painting, positioning, and sizing widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/container_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button" - }, - "title": { - "type": "text", - "data": "Mirai Elevated Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design elevated button", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/elevated_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Floating Action Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A floating action button is a circular icon button that hovers over content to promote a primary action in the application", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/floating_action_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "radio_button_checked" - }, - "title": { - "type": "text", - "data": "Mirai Icon", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "An icon button is a picture printed on a Material widget that reacts to touches by filling with color", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "heart_solid" - }, - "title": { - "type": "text", - "data": "Mirai Icon Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "image" - }, - "title": { - "type": "text", - "data": "Mirai Image", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that displays an image", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/image_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows_sharp" - }, - "title": { - "type": "text", - "data": "Mirai List Tile", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A single fixed-height row that typically contains some text as well as a leading or trailing icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_tile_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "view_list" - }, - "title": { - "type": "text", - "data": "Mirai List View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, linear list of widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Shows examples of different types of navigation types and styles in Mirai", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/navigation_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button_outlined" - }, - "title": { - "type": "text", - "data": "Mirai Outlined Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design outlined button, essentially a TextButton with an outlined border", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/outlined_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "padding" - }, - "title": { - "type": "text", - "data": "Mirai Padding", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that insets its child by the given padding", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/padding_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai PageView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of pages", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/page_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "refresh" - }, - "title": { - "type": "text", - "data": "Mirai Refresh Indicator", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that supports the Material \"swipe to refresh\" idiom.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/refresh_indicator_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Row", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Layout a list of child widgets in the horizontal direction", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/row_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "widgets" - }, - "title": { - "type": "text", - "data": "Mirai Scaffold", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Implements the basic Material Design visual layout structure", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scaffold_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "swipe_down" - }, - "title": { - "type": "text", - "data": "Mirai Scroll View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box in which a single widget can be scrolled", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scroll_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box with a specified size. If given a child, this widget forces its child to have a specific dimensions.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "toggle_on" - }, - "title": { - "type": "text", - "data": "Mirai Switch", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A switch component that can be toggled via dragging or tapping on it.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/switch_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Fractionally Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that sizes its child to a fraction of the total available space.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/fractionally_sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "grid_view" - }, - "title": { - "type": "text", - "data": "Mirai GridView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, 2D array of widgets that are created on demand.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/grid_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai Tabbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of tabs", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/tab_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "text_quote" - }, - "title": { - "type": "text", - "data": "Mirai Text", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A run of text with a single style.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "textbox" - }, - "title": { - "type": "text", - "data": "Mirai Text Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text button displays an ink splash on press but does not lift", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "text_fields" - }, - "title": { - "type": "text", - "data": "Mirai Text Field", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text fields allow users to type text into an app", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_field_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Form", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Form Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/form_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "language" - }, - "title": { - "type": "text", - "data": "Mirai WebView", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Web View Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/web_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "check_box_outline_blank" - }, - "title": { - "type": "text", - "data": "Chip", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Chips are compact elements that represent an attribute, text, entity, or action", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/chip_example.json" - } - } - } - ] - } - } } \ No newline at end of file From 5af4ef1089031626166273f7088ea85c2ddc3d5c Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 02:29:25 +0400 Subject: [PATCH 03/24] Add support for Filled Button home screen updated alignment --- .../assets/json/home_screen.json | 2296 ++++++++--------- 1 file changed, 1148 insertions(+), 1148 deletions(-) diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 732541fd..88b9723d 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -1,1155 +1,1155 @@ { - "type": "scaffold", - "appBar": { - "type": "appBar", - "title": { + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Mirai Gallery" + }, + "elevation": 0 + }, + "body": { + "type": "padding", + "padding": { + "bottom": 24 + }, + "child": { + "type": "listView", + "shrinkWrap": true, + "separator": { + "type": "container", + "height": 10 + }, + "children": [ + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "app_fill" + }, + "title": { "type": "text", - "data": "Mirai Gallery" + "data": "Mirai Appbar", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Displays information and actions relating to the current screen", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/app_bar_example.json" + } + } }, - "elevation": 0 - }, - "body": { - "type": "padding", - "padding": { - "bottom": 24 + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Bottom Navigation", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Bottom navigation with cross-fading views", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/bottom_nav_bar_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Bottom Sheet", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design Mirai bottom sheet example", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/bottom_sheet_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "wallet_giftcard" + }, + "title": { + "type": "text", + "data": "Mirai Card", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Card is a sheet of material used to represent some related information", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/card_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "format_align_center" + }, + "title": { + "type": "text", + "data": "Mirai Center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that centers its child within itself.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/center_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "format_align_center" + }, + "title": { + "type": "text", + "data": "Mirai Align", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/align_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows" + }, + "title": { + "type": "text", + "data": "Mirai Column", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "This is a mirai column widget.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/column_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "add_alert" + }, + "title": { + "type": "text", + "data": "Mirai Dialog", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Informs the user about situations that require acknowledgement", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/dialog_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "layers" + }, + "title": { + "type": "text", + "data": "Mirai Stack", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "This is a mirai stack widget.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/stack_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "apartment" + }, + "title": { + "type": "text", + "data": "Mirai Container", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Container combines common painting, positioning, and sizing widgets", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/container_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button" + }, + "title": { + "type": "text", + "data": "Mirai Elevated Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design elevated button", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/elevated_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "blur_circular_rounded" + }, + "title": { + "type": "text", + "data": "Mirai Floating Action Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A floating action button is a circular icon button that hovers over content to promote a primary action in the application", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/floating_action_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "radio_button_checked" + }, + "title": { + "type": "text", + "data": "Mirai Icon", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "An icon button is a picture printed on a Material widget that reacts to touches by filling with color", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/icon_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "heart_solid" + }, + "title": { + "type": "text", + "data": "Mirai Icon Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design icon", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/icon_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "image" + }, + "title": { + "type": "text", + "data": "Mirai Image", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that displays an image", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/image_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows_sharp" + }, + "title": { + "type": "text", + "data": "Mirai List Tile", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A single fixed-height row that typically contains some text as well as a leading or trailing icon", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/list_tile_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "view_list" + }, + "title": { + "type": "text", + "data": "Mirai List View", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A scrollable, linear list of widgets", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/list_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Navigation", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Shows examples of different types of navigation types and styles in Mirai", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/navigation_example.json" + } + } }, - "child": { - "type": "listView", - "shrinkWrap": true, - "separator": { - "type": "container", - "height": 10 - }, - "children": [ - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "app_fill" - }, - "title": { - "type": "text", - "data": "Mirai Appbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Displays information and actions relating to the current screen", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/app_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Bottom navigation with cross-fading views", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_nav_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Sheet", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design Mirai bottom sheet example", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_sheet_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "wallet_giftcard" - }, - "title": { - "type": "text", - "data": "Mirai Card", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Card is a sheet of material used to represent some related information", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/card_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that centers its child within itself.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/center_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Align", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/align_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Column", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai column widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/column_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "add_alert" - }, - "title": { - "type": "text", - "data": "Mirai Dialog", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Informs the user about situations that require acknowledgement", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/dialog_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "layers" - }, - "title": { - "type": "text", - "data": "Mirai Stack", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai stack widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/stack_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "apartment" - }, - "title": { - "type": "text", - "data": "Mirai Container", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Container combines common painting, positioning, and sizing widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/container_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button" - }, - "title": { - "type": "text", - "data": "Mirai Elevated Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design elevated button", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/elevated_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Floating Action Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A floating action button is a circular icon button that hovers over content to promote a primary action in the application", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/floating_action_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "radio_button_checked" - }, - "title": { - "type": "text", - "data": "Mirai Icon", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "An icon button is a picture printed on a Material widget that reacts to touches by filling with color", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "heart_solid" - }, - "title": { - "type": "text", - "data": "Mirai Icon Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "image" - }, - "title": { - "type": "text", - "data": "Mirai Image", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that displays an image", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/image_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows_sharp" - }, - "title": { - "type": "text", - "data": "Mirai List Tile", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A single fixed-height row that typically contains some text as well as a leading or trailing icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_tile_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "view_list" - }, - "title": { - "type": "text", - "data": "Mirai List View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, linear list of widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Shows examples of different types of navigation types and styles in Mirai", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/navigation_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button_outlined" - }, - "title": { - "type": "text", - "data": "Mirai Outlined Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design outlined button, essentially a TextButton with an outlined border", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/outlined_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "padding" - }, - "title": { - "type": "text", - "data": "Mirai Padding", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that insets its child by the given padding", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/padding_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai PageView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of pages", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/page_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "refresh" - }, - "title": { - "type": "text", - "data": "Mirai Refresh Indicator", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that supports the Material \"swipe to refresh\" idiom.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/refresh_indicator_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Row", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Layout a list of child widgets in the horizontal direction", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/row_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "widgets" - }, - "title": { - "type": "text", - "data": "Mirai Scaffold", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Implements the basic Material Design visual layout structure", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scaffold_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "swipe_down" - }, - "title": { - "type": "text", - "data": "Mirai Scroll View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box in which a single widget can be scrolled", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scroll_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box with a specified size. If given a child, this widget forces its child to have a specific dimensions.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "toggle_on" - }, - "title": { - "type": "text", - "data": "Mirai Switch", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A switch component that can be toggled via dragging or tapping on it.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/switch_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Fractionally Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that sizes its child to a fraction of the total available space.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/fractionally_sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai Tabbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of tabs", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/tab_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "text_quote" - }, - "title": { - "type": "text", - "data": "Mirai Text", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A run of text with a single style.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "textbox" - }, - "title": { - "type": "text", - "data": "Mirai Text Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text button displays an ink splash on press but does not lift", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "text_fields" - }, - "title": { - "type": "text", - "data": "Mirai Text Field", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text fields allow users to type text into an app", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_field_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Form", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Form Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/form_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "language" - }, - "title": { - "type": "text", - "data": "Mirai WebView", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Web View Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/web_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "check_box_outline_blank" - }, - "title": { - "type": "text", - "data": "Chip", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Chips are compact elements that represent an attribute, text, entity, or action", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/chip_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button" - }, - "title": { - "type": "text", - "data": "Filled Button", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design filled button", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/filled_button_example.json" - } - } - } - ] + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button_outlined" + }, + "title": { + "type": "text", + "data": "Mirai Outlined Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design outlined button, essentially a TextButton with an outlined border", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/outlined_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "padding" + }, + "title": { + "type": "text", + "data": "Mirai Padding", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that insets its child by the given padding", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/padding_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_chart" + }, + "title": { + "type": "text", + "data": "Mirai PageView", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design widget that displays a horizontal row of pages", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/page_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "refresh" + }, + "title": { + "type": "text", + "data": "Mirai Refresh Indicator", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that supports the Material \"swipe to refresh\" idiom.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/refresh_indicator_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows" + }, + "title": { + "type": "text", + "data": "Mirai Row", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Layout a list of child widgets in the horizontal direction", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/row_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "widgets" + }, + "title": { + "type": "text", + "data": "Mirai Scaffold", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Implements the basic Material Design visual layout structure", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/scaffold_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "swipe_down" + }, + "title": { + "type": "text", + "data": "Mirai Scroll View", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A box in which a single widget can be scrolled", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/scroll_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "space_bar" + }, + "title": { + "type": "text", + "data": "Mirai Sizedbox", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A box with a specified size. If given a child, this widget forces its child to have a specific dimensions.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/sized_box_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "toggle_on" + }, + "title": { + "type": "text", + "data": "Mirai Switch", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A switch component that can be toggled via dragging or tapping on it.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/switch_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "space_bar" + }, + "title": { + "type": "text", + "data": "Mirai Fractionally Sizedbox", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that sizes its child to a fraction of the total available space.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/fractionally_sized_box_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_chart" + }, + "title": { + "type": "text", + "data": "Mirai Tabbar", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design widget that displays a horizontal row of tabs", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/tab_bar_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "text_quote" + }, + "title": { + "type": "text", + "data": "Mirai Text", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A run of text with a single style.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "textbox" + }, + "title": { + "type": "text", + "data": "Mirai Text Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Text button displays an ink splash on press but does not lift", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "text_fields" + }, + "title": { + "type": "text", + "data": "Mirai Text Field", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Text fields allow users to type text into an app", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_field_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "blur_circular_rounded" + }, + "title": { + "type": "text", + "data": "Mirai Form", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Form Widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/form_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "language" + }, + "title": { + "type": "text", + "data": "Mirai WebView", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Web View Widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/web_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "check_box_outline_blank" + }, + "title": { + "type": "text", + "data": "Chip", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Chips are compact elements that represent an attribute, text, entity, or action", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/chip_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button" + }, + "title": { + "type": "text", + "data": "Filled Button", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design filled button", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/filled_button_example.json" + } + } } + ] } + } } \ No newline at end of file From d7044f83a0e1f7997fd26834996052b1766df8ef Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 02:37:28 +0400 Subject: [PATCH 04/24] Add support for Filled Button --- .../assets/json/home_screen.json | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 88b9723d..e55c5817 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -889,6 +889,37 @@ } } }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "grid_view" + }, + "title": { + "type": "text", + "data": "Mirai GridView", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A scrollable, 2D array of widgets that are created on demand.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/grid_view_example.json" + } + } + }, { "type": "listTile", "leading": { From 69f19b61f278bb86c677d6f041522de9292afe9f Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Thu, 29 Feb 2024 03:24:58 +0400 Subject: [PATCH 05/24] Add defaultBottomNavigationController & bottomNavigationView --- .../assets/json/bottom_nav_bar_example.json | 127 ++++++----- packages/mirai/lib/src/framework/mirai.dart | 2 + .../mirai_bottom_navigation_bar.dart | 4 +- .../mirai_bottom_navigation_bar.freezed.dart | 68 ++---- .../mirai_bottom_navigation_bar.g.dart | 9 +- .../mirai_bottom_navigation_bar_parser.dart | 50 ++-- .../mirai_bottom_navigation_view.dart | 16 ++ .../mirai_bottom_navigation_view.freezed.dart | 168 ++++++++++++++ .../mirai_bottom_navigation_view.g.dart | 22 ++ .../mirai_bottom_navigation_view_parser.dart | 26 +++ ..._default_bottom_navigation_controller.dart | 20 ++ ..._bottom_navigation_controller.freezed.dart | 215 ++++++++++++++++++ ...efault_bottom_navigation_controller.g.dart | 24 ++ ...t_bottom_navigation_controller_parser.dart | 125 ++++++++++ .../mirai_bottom_navigation_bar_item.dart | 3 +- packages/mirai/lib/src/parsers/parsers.dart | 4 +- packages/mirai/lib/src/utils/widget_type.dart | 2 + 17 files changed, 744 insertions(+), 141 deletions(-) create mode 100644 packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view_parser.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller_parser.dart diff --git a/examples/mirai_gallery/assets/json/bottom_nav_bar_example.json b/examples/mirai_gallery/assets/json/bottom_nav_bar_example.json index 2c1e3167..58b8052a 100644 --- a/examples/mirai_gallery/assets/json/bottom_nav_bar_example.json +++ b/examples/mirai_gallery/assets/json/bottom_nav_bar_example.json @@ -1,66 +1,81 @@ { - "type": "scaffold", - "appBar": { - "type": "appBar", - "title": { - "type": "text", - "data": "Selected label" - } - }, - "body": { - "type": "row", - "mainAxisAlignment": "center", - "crossAxisAlignment": "center", - "children": [ - { - "type": "column", - "mainAxisAlignment": "center", - "crossAxisAlignment": "center", - "children": [ - { + "type": "defaultBottomNavigationController", + "length": 3, + "child": { + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Bottom Navigation Screen" + } + }, + "body": { + "type": "bottomNavigationView", + "children": [ + { + "type": "center", + "child": { "type": "text", "data": "Home", "style": { - "fontSize": 17 + "fontSize": 24 + } + } + }, + { + "type": "center", + "child": { + "type": "text", + "data": "Search", + "style": { + "fontSize": 24 + } + } + }, + { + "type": "center", + "child": { + "type": "text", + "data": "Profile", + "style": { + "fontSize": 24 } } - ] - } - ] - }, - "bottomNavigationBar": { - "type": "bottomNavigationBar", - "items": [ - { - "type": "navigationBarItem", - "label": "Comments", - "icon": { - "type": "icon", - "iconType": "material", - "icon": "comment", - "size": 24 - } - }, - { - "type": "navigationBarItem", - "label": "Calendar", - "icon": { - "type": "icon", - "iconType": "material", - "icon": "calendar_month", - "size": 24 } - }, - { - "type": "navigationBarItem", - "label": "Account", - "icon": { - "type": "icon", - "iconType": "cupertino", - "icon": "profile_circled", - "size": 24 + ] + }, + "bottomNavigationBar": { + "type": "bottomNavigationBar", + "items": [ + { + "type": "navigationBarItem", + "label": "Home", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "home" + } + }, + { + "type": "navigationBarItem", + "label": "Search", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "search" + } + }, + { + "type": "navigationBarItem", + "label": "Profile", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "account_circle" + } } - } - ] + ] + } } } \ 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 be4eb495..783ac520 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -65,6 +65,8 @@ class Mirai { const MiraiCircleAvatarParser(), const MiraiChipParser(), const MiraiGridViewParser(), + const MiraiBottomNavigationViewParser(), + const MiraiDefaultBottomNavigationControllerParser(), ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart index 385215c9..8cdd28ec 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart @@ -11,11 +11,9 @@ part 'mirai_bottom_navigation_bar.g.dart'; @freezed class MiraiBottomNavigationBar with _$MiraiBottomNavigationBar { const factory MiraiBottomNavigationBar({ - //Todo: onTap, required List items, - @Default(0) int currentIndex, double? elevation, - BottomNavigationBarType? navBarType, + BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, @Default(24) double iconSize, diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.freezed.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.freezed.dart index 61e7da52..3b382303 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.freezed.dart @@ -21,12 +21,11 @@ MiraiBottomNavigationBar _$MiraiBottomNavigationBarFromJson( /// @nodoc mixin _$MiraiBottomNavigationBar { -//Todo: onTap, List get items => throw _privateConstructorUsedError; - int get currentIndex => throw _privateConstructorUsedError; double? get elevation => throw _privateConstructorUsedError; - BottomNavigationBarType? get navBarType => throw _privateConstructorUsedError; + BottomNavigationBarType? get bottomNavigationBarType => + throw _privateConstructorUsedError; String? get fixedColor => throw _privateConstructorUsedError; String? get backgroundColor => throw _privateConstructorUsedError; double get iconSize => throw _privateConstructorUsedError; @@ -57,9 +56,8 @@ abstract class $MiraiBottomNavigationBarCopyWith<$Res> { @useResult $Res call( {List items, - int currentIndex, double? elevation, - BottomNavigationBarType? navBarType, + BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, double iconSize, @@ -93,9 +91,8 @@ class _$MiraiBottomNavigationBarCopyWithImpl<$Res, @override $Res call({ Object? items = null, - Object? currentIndex = null, Object? elevation = freezed, - Object? navBarType = freezed, + Object? bottomNavigationBarType = freezed, Object? fixedColor = freezed, Object? backgroundColor = freezed, Object? iconSize = null, @@ -115,17 +112,13 @@ class _$MiraiBottomNavigationBarCopyWithImpl<$Res, ? _value.items : items // ignore: cast_nullable_to_non_nullable as List, - currentIndex: null == currentIndex - ? _value.currentIndex - : currentIndex // ignore: cast_nullable_to_non_nullable - as int, elevation: freezed == elevation ? _value.elevation : elevation // ignore: cast_nullable_to_non_nullable as double?, - navBarType: freezed == navBarType - ? _value.navBarType - : navBarType // ignore: cast_nullable_to_non_nullable + bottomNavigationBarType: freezed == bottomNavigationBarType + ? _value.bottomNavigationBarType + : bottomNavigationBarType // ignore: cast_nullable_to_non_nullable as BottomNavigationBarType?, fixedColor: freezed == fixedColor ? _value.fixedColor @@ -218,9 +211,8 @@ abstract class _$$MiraiBottomNavigationBarImplCopyWith<$Res> @useResult $Res call( {List items, - int currentIndex, double? elevation, - BottomNavigationBarType? navBarType, + BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, double iconSize, @@ -255,9 +247,8 @@ class __$$MiraiBottomNavigationBarImplCopyWithImpl<$Res> @override $Res call({ Object? items = null, - Object? currentIndex = null, Object? elevation = freezed, - Object? navBarType = freezed, + Object? bottomNavigationBarType = freezed, Object? fixedColor = freezed, Object? backgroundColor = freezed, Object? iconSize = null, @@ -277,17 +268,13 @@ class __$$MiraiBottomNavigationBarImplCopyWithImpl<$Res> ? _value._items : items // ignore: cast_nullable_to_non_nullable as List, - currentIndex: null == currentIndex - ? _value.currentIndex - : currentIndex // ignore: cast_nullable_to_non_nullable - as int, elevation: freezed == elevation ? _value.elevation : elevation // ignore: cast_nullable_to_non_nullable as double?, - navBarType: freezed == navBarType - ? _value.navBarType - : navBarType // ignore: cast_nullable_to_non_nullable + bottomNavigationBarType: freezed == bottomNavigationBarType + ? _value.bottomNavigationBarType + : bottomNavigationBarType // ignore: cast_nullable_to_non_nullable as BottomNavigationBarType?, fixedColor: freezed == fixedColor ? _value.fixedColor @@ -350,9 +337,8 @@ class __$$MiraiBottomNavigationBarImplCopyWithImpl<$Res> class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { const _$MiraiBottomNavigationBarImpl( {required final List items, - this.currentIndex = 0, this.elevation, - this.navBarType, + this.bottomNavigationBarType, this.fixedColor, this.backgroundColor, this.iconSize = 24, @@ -371,9 +357,7 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { factory _$MiraiBottomNavigationBarImpl.fromJson(Map json) => _$$MiraiBottomNavigationBarImplFromJson(json); -//Todo: onTap, final List _items; -//Todo: onTap, @override List get items { if (_items is EqualUnmodifiableListView) return _items; @@ -381,13 +365,10 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { return EqualUnmodifiableListView(_items); } - @override - @JsonKey() - final int currentIndex; @override final double? elevation; @override - final BottomNavigationBarType? navBarType; + final BottomNavigationBarType? bottomNavigationBarType; @override final String? fixedColor; @override @@ -420,7 +401,7 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { @override String toString() { - return 'MiraiBottomNavigationBar(items: $items, currentIndex: $currentIndex, elevation: $elevation, navBarType: $navBarType, fixedColor: $fixedColor, backgroundColor: $backgroundColor, iconSize: $iconSize, selectedItemColor: $selectedItemColor, unselectedItemColor: $unselectedItemColor, selectedFontSize: $selectedFontSize, unselectedFontSize: $unselectedFontSize, selectedLabelStyle: $selectedLabelStyle, unselectedLabelStyle: $unselectedLabelStyle, showSelectedLabels: $showSelectedLabels, showUnselectedLabels: $showUnselectedLabels, enableFeedback: $enableFeedback, landscapeLayout: $landscapeLayout)'; + return 'MiraiBottomNavigationBar(items: $items, elevation: $elevation, bottomNavigationBarType: $bottomNavigationBarType, fixedColor: $fixedColor, backgroundColor: $backgroundColor, iconSize: $iconSize, selectedItemColor: $selectedItemColor, unselectedItemColor: $unselectedItemColor, selectedFontSize: $selectedFontSize, unselectedFontSize: $unselectedFontSize, selectedLabelStyle: $selectedLabelStyle, unselectedLabelStyle: $unselectedLabelStyle, showSelectedLabels: $showSelectedLabels, showUnselectedLabels: $showUnselectedLabels, enableFeedback: $enableFeedback, landscapeLayout: $landscapeLayout)'; } @override @@ -429,12 +410,11 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { (other.runtimeType == runtimeType && other is _$MiraiBottomNavigationBarImpl && const DeepCollectionEquality().equals(other._items, _items) && - (identical(other.currentIndex, currentIndex) || - other.currentIndex == currentIndex) && (identical(other.elevation, elevation) || other.elevation == elevation) && - (identical(other.navBarType, navBarType) || - other.navBarType == navBarType) && + (identical( + other.bottomNavigationBarType, bottomNavigationBarType) || + other.bottomNavigationBarType == bottomNavigationBarType) && (identical(other.fixedColor, fixedColor) || other.fixedColor == fixedColor) && (identical(other.backgroundColor, backgroundColor) || @@ -468,9 +448,8 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_items), - currentIndex, elevation, - navBarType, + bottomNavigationBarType, fixedColor, backgroundColor, iconSize, @@ -503,9 +482,8 @@ class _$MiraiBottomNavigationBarImpl implements _MiraiBottomNavigationBar { abstract class _MiraiBottomNavigationBar implements MiraiBottomNavigationBar { const factory _MiraiBottomNavigationBar( {required final List items, - final int currentIndex, final double? elevation, - final BottomNavigationBarType? navBarType, + final BottomNavigationBarType? bottomNavigationBarType, final String? fixedColor, final String? backgroundColor, final double iconSize, @@ -524,14 +502,12 @@ abstract class _MiraiBottomNavigationBar implements MiraiBottomNavigationBar { factory _MiraiBottomNavigationBar.fromJson(Map json) = _$MiraiBottomNavigationBarImpl.fromJson; - @override //Todo: onTap, - List get items; @override - int get currentIndex; + List get items; @override double? get elevation; @override - BottomNavigationBarType? get navBarType; + BottomNavigationBarType? get bottomNavigationBarType; @override String? get fixedColor; @override 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 1f6da58e..3581b116 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 @@ -13,10 +13,9 @@ _$MiraiBottomNavigationBarImpl _$$MiraiBottomNavigationBarImplFromJson( .map((e) => MiraiBottomNavigationBarItem.fromJson(e as Map)) .toList(), - currentIndex: json['currentIndex'] as int? ?? 0, elevation: (json['elevation'] as num?)?.toDouble(), - navBarType: $enumDecodeNullable( - _$BottomNavigationBarTypeEnumMap, json['navBarType']), + bottomNavigationBarType: $enumDecodeNullable( + _$BottomNavigationBarTypeEnumMap, json['bottomNavigationBarType']), fixedColor: json['fixedColor'] as String?, backgroundColor: json['backgroundColor'] as String?, iconSize: (json['iconSize'] as num?)?.toDouble() ?? 24, @@ -44,9 +43,9 @@ Map _$$MiraiBottomNavigationBarImplToJson( _$MiraiBottomNavigationBarImpl instance) => { 'items': instance.items, - 'currentIndex': instance.currentIndex, 'elevation': instance.elevation, - 'navBarType': _$BottomNavigationBarTypeEnumMap[instance.navBarType], + 'bottomNavigationBarType': + _$BottomNavigationBarTypeEnumMap[instance.bottomNavigationBarType], 'fixedColor': instance.fixedColor, 'backgroundColor': instance.backgroundColor, 'iconSize': instance.iconSize, diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar_parser.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar_parser.dart index 807cd1a7..744e9c81 100644 --- a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar_parser.dart @@ -1,10 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:mirai/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart'; -import 'package:mirai/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart'; -import 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart'; -import 'package:mirai/src/utils/color_utils.dart'; +import 'package:mirai/mirai.dart'; import 'package:mirai/src/utils/widget_type.dart'; -import 'package:mirai_framework/mirai_framework.dart'; class MiraiBottomNavigationBarParser extends MiraiParser { @@ -19,29 +15,27 @@ class MiraiBottomNavigationBarParser @override Widget parse(BuildContext context, MiraiBottomNavigationBar model) { - if (model.items.length >= 2) { - return BottomNavigationBar( - items: model.items.map((item) => item.parse(context)).toList(), - onTap: (_) {}, - currentIndex: model.currentIndex, - elevation: model.elevation, - type: model.navBarType, - fixedColor: model.fixedColor?.toColor(context), - backgroundColor: model.backgroundColor?.toColor(context), - iconSize: model.iconSize, - selectedItemColor: model.selectedItemColor?.toColor(context), - unselectedItemColor: model.unselectedItemColor?.toColor(context), - selectedFontSize: model.selectedFontSize, - unselectedFontSize: model.unselectedFontSize, - selectedLabelStyle: model.selectedLabelStyle?.parse(context), - unselectedLabelStyle: model.unselectedLabelStyle?.parse(context), - showSelectedLabels: model.showSelectedLabels, - showUnselectedLabels: model.showUnselectedLabels, - enableFeedback: model.enableFeedback, - landscapeLayout: model.landscapeLayout, - ); - } + final controller = BottomNavigationScope.of(context)?.controller; - return const SizedBox(); + return BottomNavigationBar( + items: model.items.map((item) => item.parse(context)).toList(), + onTap: (index) => controller?.index = index, + currentIndex: controller?.index ?? 0, + elevation: model.elevation, + type: model.bottomNavigationBarType, + fixedColor: model.fixedColor?.toColor(context), + backgroundColor: model.backgroundColor?.toColor(context), + iconSize: model.iconSize, + selectedItemColor: model.selectedItemColor?.toColor(context), + unselectedItemColor: model.unselectedItemColor?.toColor(context), + selectedFontSize: model.selectedFontSize, + unselectedFontSize: model.unselectedFontSize, + selectedLabelStyle: model.selectedLabelStyle?.parse(context), + unselectedLabelStyle: model.unselectedLabelStyle?.parse(context), + showSelectedLabels: model.showSelectedLabels, + showUnselectedLabels: model.showUnselectedLabels, + enableFeedback: model.enableFeedback, + landscapeLayout: model.landscapeLayout, + ); } } diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart new file mode 100644 index 00000000..4e22871b --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'mirai_bottom_navigation_view_parser.dart'; + +part 'mirai_bottom_navigation_view.freezed.dart'; +part 'mirai_bottom_navigation_view.g.dart'; + +@freezed +class MiraiBottomNavigationView with _$MiraiBottomNavigationView { + const factory MiraiBottomNavigationView({ + @Default([]) List> children, + }) = _MiraiBottomNavigationView; + + factory MiraiBottomNavigationView.fromJson(Map json) => + _$MiraiBottomNavigationViewFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.freezed.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.freezed.dart new file mode 100644 index 00000000..c879fefa --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.freezed.dart @@ -0,0 +1,168 @@ +// 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_bottom_navigation_view.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'); + +MiraiBottomNavigationView _$MiraiBottomNavigationViewFromJson( + Map json) { + return _MiraiBottomNavigationView.fromJson(json); +} + +/// @nodoc +mixin _$MiraiBottomNavigationView { + List> get children => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiBottomNavigationViewCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiBottomNavigationViewCopyWith<$Res> { + factory $MiraiBottomNavigationViewCopyWith(MiraiBottomNavigationView value, + $Res Function(MiraiBottomNavigationView) then) = + _$MiraiBottomNavigationViewCopyWithImpl<$Res, MiraiBottomNavigationView>; + @useResult + $Res call({List> children}); +} + +/// @nodoc +class _$MiraiBottomNavigationViewCopyWithImpl<$Res, + $Val extends MiraiBottomNavigationView> + implements $MiraiBottomNavigationViewCopyWith<$Res> { + _$MiraiBottomNavigationViewCopyWithImpl(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? children = null, + }) { + return _then(_value.copyWith( + children: null == children + ? _value.children + : children // ignore: cast_nullable_to_non_nullable + as List>, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiBottomNavigationViewImplCopyWith<$Res> + implements $MiraiBottomNavigationViewCopyWith<$Res> { + factory _$$MiraiBottomNavigationViewImplCopyWith( + _$MiraiBottomNavigationViewImpl value, + $Res Function(_$MiraiBottomNavigationViewImpl) then) = + __$$MiraiBottomNavigationViewImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List> children}); +} + +/// @nodoc +class __$$MiraiBottomNavigationViewImplCopyWithImpl<$Res> + extends _$MiraiBottomNavigationViewCopyWithImpl<$Res, + _$MiraiBottomNavigationViewImpl> + implements _$$MiraiBottomNavigationViewImplCopyWith<$Res> { + __$$MiraiBottomNavigationViewImplCopyWithImpl( + _$MiraiBottomNavigationViewImpl _value, + $Res Function(_$MiraiBottomNavigationViewImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? children = null, + }) { + return _then(_$MiraiBottomNavigationViewImpl( + children: null == children + ? _value._children + : children // ignore: cast_nullable_to_non_nullable + as List>, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiBottomNavigationViewImpl implements _MiraiBottomNavigationView { + const _$MiraiBottomNavigationViewImpl( + {final List> children = const []}) + : _children = children; + + factory _$MiraiBottomNavigationViewImpl.fromJson(Map json) => + _$$MiraiBottomNavigationViewImplFromJson(json); + + 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 'MiraiBottomNavigationView(children: $children)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiBottomNavigationViewImpl && + const DeepCollectionEquality().equals(other._children, _children)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_children)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiBottomNavigationViewImplCopyWith<_$MiraiBottomNavigationViewImpl> + get copyWith => __$$MiraiBottomNavigationViewImplCopyWithImpl< + _$MiraiBottomNavigationViewImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiBottomNavigationViewImplToJson( + this, + ); + } +} + +abstract class _MiraiBottomNavigationView implements MiraiBottomNavigationView { + const factory _MiraiBottomNavigationView( + {final List> children}) = + _$MiraiBottomNavigationViewImpl; + + factory _MiraiBottomNavigationView.fromJson(Map json) = + _$MiraiBottomNavigationViewImpl.fromJson; + + @override + List> get children; + @override + @JsonKey(ignore: true) + _$$MiraiBottomNavigationViewImplCopyWith<_$MiraiBottomNavigationViewImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.g.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.g.dart new file mode 100644 index 00000000..7adfe297 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_bottom_navigation_view.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiBottomNavigationViewImpl _$$MiraiBottomNavigationViewImplFromJson( + Map json) => + _$MiraiBottomNavigationViewImpl( + children: (json['children'] as List?) + ?.map((e) => e as Map) + .toList() ?? + const [], + ); + +Map _$$MiraiBottomNavigationViewImplToJson( + _$MiraiBottomNavigationViewImpl instance) => + { + 'children': instance.children, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view_parser.dart b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view_parser.dart new file mode 100644 index 00000000..d3bfc1c9 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view_parser.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/src/framework/framework.dart'; +import 'package:mirai/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart'; +import 'package:mirai/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller_parser.dart'; +import 'package:mirai/src/utils/widget_type.dart'; +import 'package:mirai_framework/mirai_framework.dart'; + +class MiraiBottomNavigationViewParser + extends MiraiParser { + const MiraiBottomNavigationViewParser(); + + @override + String get type => WidgetType.bottomNavigationView.name; + + @override + MiraiBottomNavigationView getModel(Map json) => + MiraiBottomNavigationView.fromJson(json); + + @override + Widget parse(BuildContext context, MiraiBottomNavigationView model) { + final controller = BottomNavigationScope.of(context)?.controller; + + final index = controller?.index ?? 0; + return Mirai.fromJson(model.children[index], context) ?? const SizedBox(); + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart new file mode 100644 index 00000000..798b11df --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'mirai_default_bottom_navigation_controller_parser.dart'; + +part 'mirai_default_bottom_navigation_controller.freezed.dart'; +part 'mirai_default_bottom_navigation_controller.g.dart'; + +@freezed +class MiraiDefaultBottomNavigationController + with _$MiraiDefaultBottomNavigationController { + const factory MiraiDefaultBottomNavigationController({ + required int length, + int? initialIndex, + required Map child, + }) = _MiraiDefaultBottomNavigationController; + + factory MiraiDefaultBottomNavigationController.fromJson( + Map json) => + _$MiraiDefaultBottomNavigationControllerFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.freezed.dart b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.freezed.dart new file mode 100644 index 00000000..e94252a6 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.freezed.dart @@ -0,0 +1,215 @@ +// 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_default_bottom_navigation_controller.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'); + +MiraiDefaultBottomNavigationController + _$MiraiDefaultBottomNavigationControllerFromJson( + Map json) { + return _MiraiDefaultBottomNavigationController.fromJson(json); +} + +/// @nodoc +mixin _$MiraiDefaultBottomNavigationController { + int get length => throw _privateConstructorUsedError; + int? get initialIndex => throw _privateConstructorUsedError; + Map get child => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiDefaultBottomNavigationControllerCopyWith< + MiraiDefaultBottomNavigationController> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiDefaultBottomNavigationControllerCopyWith<$Res> { + factory $MiraiDefaultBottomNavigationControllerCopyWith( + MiraiDefaultBottomNavigationController value, + $Res Function(MiraiDefaultBottomNavigationController) then) = + _$MiraiDefaultBottomNavigationControllerCopyWithImpl<$Res, + MiraiDefaultBottomNavigationController>; + @useResult + $Res call({int length, int? initialIndex, Map child}); +} + +/// @nodoc +class _$MiraiDefaultBottomNavigationControllerCopyWithImpl<$Res, + $Val extends MiraiDefaultBottomNavigationController> + implements $MiraiDefaultBottomNavigationControllerCopyWith<$Res> { + _$MiraiDefaultBottomNavigationControllerCopyWithImpl(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? length = null, + Object? initialIndex = freezed, + Object? child = null, + }) { + return _then(_value.copyWith( + length: null == length + ? _value.length + : length // ignore: cast_nullable_to_non_nullable + as int, + initialIndex: freezed == initialIndex + ? _value.initialIndex + : initialIndex // ignore: cast_nullable_to_non_nullable + as int?, + child: null == child + ? _value.child + : child // ignore: cast_nullable_to_non_nullable + as Map, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiDefaultBottomNavigationControllerImplCopyWith<$Res> + implements $MiraiDefaultBottomNavigationControllerCopyWith<$Res> { + factory _$$MiraiDefaultBottomNavigationControllerImplCopyWith( + _$MiraiDefaultBottomNavigationControllerImpl value, + $Res Function(_$MiraiDefaultBottomNavigationControllerImpl) then) = + __$$MiraiDefaultBottomNavigationControllerImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int length, int? initialIndex, Map child}); +} + +/// @nodoc +class __$$MiraiDefaultBottomNavigationControllerImplCopyWithImpl<$Res> + extends _$MiraiDefaultBottomNavigationControllerCopyWithImpl<$Res, + _$MiraiDefaultBottomNavigationControllerImpl> + implements _$$MiraiDefaultBottomNavigationControllerImplCopyWith<$Res> { + __$$MiraiDefaultBottomNavigationControllerImplCopyWithImpl( + _$MiraiDefaultBottomNavigationControllerImpl _value, + $Res Function(_$MiraiDefaultBottomNavigationControllerImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? length = null, + Object? initialIndex = freezed, + Object? child = null, + }) { + return _then(_$MiraiDefaultBottomNavigationControllerImpl( + length: null == length + ? _value.length + : length // ignore: cast_nullable_to_non_nullable + as int, + initialIndex: freezed == initialIndex + ? _value.initialIndex + : initialIndex // ignore: cast_nullable_to_non_nullable + as int?, + child: null == child + ? _value._child + : child // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiDefaultBottomNavigationControllerImpl + implements _MiraiDefaultBottomNavigationController { + const _$MiraiDefaultBottomNavigationControllerImpl( + {required this.length, + this.initialIndex, + required final Map child}) + : _child = child; + + factory _$MiraiDefaultBottomNavigationControllerImpl.fromJson( + Map json) => + _$$MiraiDefaultBottomNavigationControllerImplFromJson(json); + + @override + final int length; + @override + final int? initialIndex; + final Map _child; + @override + Map get child { + if (_child is EqualUnmodifiableMapView) return _child; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_child); + } + + @override + String toString() { + return 'MiraiDefaultBottomNavigationController(length: $length, initialIndex: $initialIndex, child: $child)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiDefaultBottomNavigationControllerImpl && + (identical(other.length, length) || other.length == length) && + (identical(other.initialIndex, initialIndex) || + other.initialIndex == initialIndex) && + const DeepCollectionEquality().equals(other._child, _child)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, length, initialIndex, + const DeepCollectionEquality().hash(_child)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiDefaultBottomNavigationControllerImplCopyWith< + _$MiraiDefaultBottomNavigationControllerImpl> + get copyWith => + __$$MiraiDefaultBottomNavigationControllerImplCopyWithImpl< + _$MiraiDefaultBottomNavigationControllerImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiDefaultBottomNavigationControllerImplToJson( + this, + ); + } +} + +abstract class _MiraiDefaultBottomNavigationController + implements MiraiDefaultBottomNavigationController { + const factory _MiraiDefaultBottomNavigationController( + {required final int length, + final int? initialIndex, + required final Map child}) = + _$MiraiDefaultBottomNavigationControllerImpl; + + factory _MiraiDefaultBottomNavigationController.fromJson( + Map json) = + _$MiraiDefaultBottomNavigationControllerImpl.fromJson; + + @override + int get length; + @override + int? get initialIndex; + @override + Map get child; + @override + @JsonKey(ignore: true) + _$$MiraiDefaultBottomNavigationControllerImplCopyWith< + _$MiraiDefaultBottomNavigationControllerImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.g.dart b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.g.dart new file mode 100644 index 00000000..4d4beb54 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_default_bottom_navigation_controller.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiDefaultBottomNavigationControllerImpl + _$$MiraiDefaultBottomNavigationControllerImplFromJson( + Map json) => + _$MiraiDefaultBottomNavigationControllerImpl( + length: json['length'] as int, + initialIndex: json['initialIndex'] as int?, + child: json['child'] as Map, + ); + +Map _$$MiraiDefaultBottomNavigationControllerImplToJson( + _$MiraiDefaultBottomNavigationControllerImpl instance) => + { + 'length': instance.length, + 'initialIndex': instance.initialIndex, + 'child': instance.child, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller_parser.dart b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller_parser.dart new file mode 100644 index 00000000..89227845 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller_parser.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/src/framework/framework.dart'; +import 'package:mirai/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart'; +import 'package:mirai/src/utils/log.dart'; +import 'package:mirai/src/utils/widget_type.dart'; +import 'package:mirai_framework/mirai_framework.dart'; + +class MiraiDefaultBottomNavigationControllerParser + extends MiraiParser { + const MiraiDefaultBottomNavigationControllerParser(); + + @override + String get type => WidgetType.defaultBottomNavigationController.name; + + @override + MiraiDefaultBottomNavigationController getModel(Map json) => + MiraiDefaultBottomNavigationController.fromJson(json); + + @override + Widget parse( + BuildContext context, + MiraiDefaultBottomNavigationController model, + ) { + return _DefaultBottomNavigationControllerWidget(model: model); + } +} + +class _DefaultBottomNavigationControllerWidget extends StatefulWidget { + const _DefaultBottomNavigationControllerWidget({ + required this.model, + }); + + final MiraiDefaultBottomNavigationController model; + @override + State<_DefaultBottomNavigationControllerWidget> createState() => + _DefaultBottomNavigationControllerWidgetState(); +} + +class _DefaultBottomNavigationControllerWidgetState + extends State<_DefaultBottomNavigationControllerWidget> { + late BottomNavigationController _controller; + + @override + void initState() { + super.initState(); + + _controller = BottomNavigationController( + length: widget.model.length, + initialIndex: widget.model.initialIndex ?? 0, + ); + + _controller.addListener(_onIndexChange); + } + + void _onIndexChange() { + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return BottomNavigationScope( + length: widget.model.length, + controller: _controller, + child: Builder( + builder: (context) => + Mirai.fromJson(widget.model.child, context) ?? const SizedBox(), + ), + ); + } +} + +class BottomNavigationScope extends InheritedWidget { + const BottomNavigationScope({ + super.key, + required super.child, + required this.length, + required this.controller, + }); + + final int length; + final BottomNavigationController controller; + + static BottomNavigationScope? of(BuildContext context) { + final BottomNavigationScope? result = + context.dependOnInheritedWidgetOfExactType(); + + if (result != null) { + return result; + } else { + Log.e( + "BottomNavigationScope.of() called with a context that does not contain a BottomNavigationScope."); + return null; + } + } + + @override + bool updateShouldNotify(covariant InheritedWidget oldWidget) { + return oldWidget.child != child; + } +} + +class BottomNavigationController extends ChangeNotifier { + BottomNavigationController({ + this.initialIndex = 0, + required this.length, + }) : _index = initialIndex; + + final int initialIndex; + final int length; + + int _index = 0; + int get index => _index; + set index(int value) => _changeIndex(value); + + void _changeIndex(int value) { + assert(value >= 0 && (value < length || length == 0)); + + if (value == _index || length < 2) { + return; + } + + _index = value; + notifyListeners(); + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart b/packages/mirai/lib/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart index 7d29fc8a..0c4d9d8c 100644 --- a/packages/mirai/lib/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart +++ b/packages/mirai/lib/src/parsers/mirai_navigation_bar_item/mirai_bottom_navigation_bar_item.dart @@ -24,8 +24,7 @@ extension MiraiBottomNavigationBarItemParser on MiraiBottomNavigationBarItem { BottomNavigationBarItem parse(BuildContext context) { return BottomNavigationBarItem( icon: Mirai.fromJson(icon, context) ?? const SizedBox(), - activeIcon: - activeIcon == null ? null : Mirai.fromJson(activeIcon, context), + activeIcon: Mirai.fromJson(activeIcon, context), label: label, backgroundColor: backgroundColor?.toColor(context), tooltip: tooltip, diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 37ae9681..e0f0596c 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -12,6 +12,7 @@ export 'package:mirai/src/parsers/mirai_border_side/mirai_border_side.dart'; export 'package:mirai/src/parsers/mirai_bottom_app_bar_theme/mirai_bottom_app_bar_theme.dart'; export 'package:mirai/src/parsers/mirai_bottom_nav_bar_theme/mirai_bottom_nav_bar_theme.dart'; export 'package:mirai/src/parsers/mirai_bottom_navigation_bar/mirai_bottom_navigation_bar.dart'; +export 'package:mirai/src/parsers/mirai_bottom_navigation_view/mirai_bottom_navigation_view.dart'; export 'package:mirai/src/parsers/mirai_box_decoration/mirai_box_decoration.dart'; export 'package:mirai/src/parsers/mirai_box_shadow/mirai_box_shadow.dart'; export 'package:mirai/src/parsers/mirai_button_style/mirai_button_style.dart'; @@ -19,10 +20,12 @@ export 'package:mirai/src/parsers/mirai_card/mirai_card.dart'; export 'package:mirai/src/parsers/mirai_card_theme_data/mirai_card_theme_data.dart'; export 'package:mirai/src/parsers/mirai_center/mirai_center.dart'; export 'package:mirai/src/parsers/mirai_check_box_widget/mirai_check_box_widget.dart'; +export 'package:mirai/src/parsers/mirai_chip/mirai_chip.dart'; export 'package:mirai/src/parsers/mirai_circle_avatar/mirai_circle_avatar.dart'; export 'package:mirai/src/parsers/mirai_column/mirai_column.dart'; export 'package:mirai/src/parsers/mirai_container/mirai_container.dart'; export 'package:mirai/src/parsers/mirai_container_image/mirai_container_image.dart'; +export 'package:mirai/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart'; export 'package:mirai/src/parsers/mirai_default_tab_controller/mirai_default_tab_controller.dart'; export 'package:mirai/src/parsers/mirai_dialog_theme/mirai_dialog_theme.dart'; export 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart'; @@ -69,4 +72,3 @@ 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_chip/mirai_chip.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 0b7cfd56..59f622f5 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -44,4 +44,6 @@ enum WidgetType { circleAvatar, chip, gridView, + defaultBottomNavigationController, + bottomNavigationView, } From ef87b981683f0ba5c8a3c2aa60f318838365149f Mon Sep 17 00:00:00 2001 From: superiorsd10 Date: Thu, 29 Feb 2024 14:56:32 +0530 Subject: [PATCH 06/24] feat(mirai_edge_insets): customize the fromJson factory to support num and List as input --- .../mirai_edge_insets/mirai_edge_insets.dart | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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..44777b24 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,33 @@ 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) { + 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? { From 613af6f8c49940a604b05cf0d5d26810f60f9fb2 Mon Sep 17 00:00:00 2001 From: superiorsd10 Date: Thu, 29 Feb 2024 14:57:34 +0530 Subject: [PATCH 07/24] chore(src): update generated code files --- .../mirai_dialog_action.g.dart | 1 - .../mirai_alert_dialog.g.dart | 18 ++++++------------ .../mirai_bottom_app_bar_theme.g.dart | 2 +- .../mirai_button_style.g.dart | 2 +- .../src/parsers/mirai_card/mirai_card.g.dart | 2 +- .../mirai_card_theme_data.g.dart | 2 +- .../src/parsers/mirai_chip/mirai_chip.g.dart | 5 ++--- .../mirai_container/mirai_container.g.dart | 4 ++-- .../mirai_dialog_theme.g.dart | 3 +-- ...ai_floating_action_button_theme_data.g.dart | 3 +-- .../mirai_grid_view/mirai_grid_view.g.dart | 2 +- .../mirai_icon_button/mirai_icon_button.g.dart | 2 +- .../mirai_input_decoration.g.dart | 3 +-- .../mirai_input_decoration_theme.g.dart | 3 +-- .../mirai_list_tile/mirai_list_tile.g.dart | 3 +-- .../mirai_list_tile_theme_data.g.dart | 3 +-- .../mirai_list_view/mirai_list_view.g.dart | 2 +- .../parsers/mirai_padding/mirai_padding.g.dart | 3 +-- .../mirai_safe_area/mirai_safe_area.g.dart | 2 +- .../mirai_single_child_scroll_view.g.dart | 2 +- .../lib/src/parsers/mirai_tab/mirai_tab.g.dart | 3 +-- .../parsers/mirai_tab_bar/mirai_tab_bar.g.dart | 8 +++----- .../mirai_tab_bar_theme_data.g.dart | 3 +-- .../mirai_text_form_field.g.dart | 3 +-- 24 files changed, 32 insertions(+), 52 deletions(-) diff --git a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart index 949d3f10..d67fc766 100644 --- a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart +++ b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart @@ -40,5 +40,4 @@ Map _$$MiraiDialogActionImplToJson( const _$TraversalEdgeBehaviorEnumMap = { TraversalEdgeBehavior.closedLoop: 'closedLoop', TraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', - TraversalEdgeBehavior.parentScope: 'parentScope', }; 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..0de9047c 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,14 +12,12 @@ _$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( @@ -27,8 +25,7 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( 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( @@ -38,8 +35,7 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( .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 +46,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_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_button_style/mirai_button_style.g.dart b/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.g.dart index e1f6534d..b71d4c8d 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 @@ -23,7 +23,7 @@ _$MiraiButtonStyleImpl _$$MiraiButtonStyleImplFromJson( : MiraiTextStyle.fromJson(json['textStyle'] as Map), 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..920fe999 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 @@ -15,8 +15,7 @@ _$MiraiChipImpl _$$MiraiChipImplFromJson(Map json) => : MiraiTextStyle.fromJson(json['labelStyle'] as Map), 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..98ef79a6 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 @@ -30,8 +30,7 @@ _$MiraiDialogThemeImpl _$$MiraiDialogThemeImplFromJson( json['contentTextStyle'] as Map), 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_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..f4ed23ed 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,8 +26,7 @@ _$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( 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..f7412c12 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 @@ -46,8 +46,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 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..1ae5b044 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 @@ -35,8 +35,7 @@ _$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 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..f88c84f0 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 @@ -31,8 +31,7 @@ _$MiraiListTileThemeDataImpl _$$MiraiListTileThemeDataImplFromJson( json['leadingAndTrailingTextStyle'] as Map), 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_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..067b77e4 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,15 +15,14 @@ _$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?, @@ -32,8 +31,7 @@ _$MiraiTabBarImpl _$$MiraiTabBarImplFromJson(Map json) => : MiraiTextStyle.fromJson(json['labelStyle'] as Map), 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 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..021eb477 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,8 +20,7 @@ _$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), 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..a0c361e3 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 @@ -52,8 +52,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, From 7c2c91543643b57d12358a00d05955fb1b5b1d09 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Thu, 29 Feb 2024 14:11:22 +0400 Subject: [PATCH 08/24] Add support to the Wrap widget --- .../assets/json/home_screen.json | 34 ++ .../assets/json/wrap_example.json | 180 +++++++++ packages/mirai/lib/src/framework/mirai.dart | 2 + .../src/parsers/mirai_wrap/mirai_wrap.dart | 26 ++ .../mirai_wrap/mirai_wrap.freezed.dart | 369 ++++++++++++++++++ .../src/parsers/mirai_wrap/mirai_wrap.g.dart | 88 +++++ .../parsers/mirai_wrap/mirai_wrap_parser.dart | 32 ++ packages/mirai/lib/src/parsers/parsers.dart | 1 + packages/mirai/lib/src/utils/widget_type.dart | 1 + 9 files changed, 733 insertions(+) create mode 100644 examples/mirai_gallery/assets/json/wrap_example.json create mode 100644 packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart 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_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, } From 6df274db3063007ed852061b3ea90bf6c5b2fd5b Mon Sep 17 00:00:00 2001 From: superiorsd10 Date: Thu, 29 Feb 2024 18:29:24 +0530 Subject: [PATCH 09/24] chore(src): upgrading the flutter on local machine and running code generators --- .../mirai_dialog_action/mirai_dialog_action.g.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart index d67fc766..949d3f10 100644 --- a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart +++ b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart @@ -40,4 +40,5 @@ Map _$$MiraiDialogActionImplToJson( const _$TraversalEdgeBehaviorEnumMap = { TraversalEdgeBehavior.closedLoop: 'closedLoop', TraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', + TraversalEdgeBehavior.parentScope: 'parentScope', }; From d8ccafa8a3d851ee56d825635ff90741dc21dc5a Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 29 Feb 2024 17:37:12 +0400 Subject: [PATCH 10/24] feat: [#258]Added app theme text styles to the text-style parser --- examples/mirai_gallery/macos/Podfile.lock | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- examples/mirai_gallery/pubspec.lock | 56 ++++++------------- .../mirai_dialog_action.g.dart | 1 - .../mirai_alert_dialog.g.dart | 6 +- .../mirai_app_bar/mirai_app_bar.g.dart | 6 +- .../mirai_app_bar_theme.g.dart | 6 +- .../mirai_bottom_nav_bar_theme.g.dart | 6 +- .../mirai_bottom_navigation_bar.g.dart | 6 +- .../mirai_button_style.g.dart | 2 +- .../src/parsers/mirai_chip/mirai_chip.g.dart | 2 +- .../mirai_dialog_theme.g.dart | 6 +- .../mirai_floating_action_button.g.dart | 5 +- ...i_floating_action_button_theme_data.g.dart | 3 +- .../mirai_input_decoration.g.dart | 21 +++---- .../mirai_input_decoration_theme.g.dart | 21 +++---- .../mirai_list_tile_theme_data.g.dart | 9 +-- .../mirai_navigation_bar_theme_data.g.dart | 3 +- .../mirai_tab_bar/mirai_tab_bar.g.dart | 5 +- .../mirai_tab_bar_theme_data.g.dart | 5 +- .../src/parsers/mirai_text/mirai_text.g.dart | 10 ++-- .../mirai_text_field/mirai_text_field.g.dart | 5 +- .../mirai_text_form_field.g.dart | 5 +- .../mirai_text_style/mirai_text_style.dart | 49 +++++++++++++++- .../mirai_text_style.freezed.dart | 24 +++++++- .../mirai_text_style/mirai_text_style.g.dart | 2 + 27 files changed, 140 insertions(+), 130 deletions(-) diff --git a/examples/mirai_gallery/macos/Podfile.lock b/examples/mirai_gallery/macos/Podfile.lock index 1f6779f9..79862f06 100644 --- a/examples/mirai_gallery/macos/Podfile.lock +++ b/examples/mirai_gallery/macos/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.14.3 +COCOAPODS: 1.12.1 diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj index 110378e8..39f233b6 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj @@ -258,7 +258,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1510; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8d1ec463..ca25b4d5 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ _$$MiraiDialogActionImplToJson( const _$TraversalEdgeBehaviorEnumMap = { TraversalEdgeBehavior.closedLoop: 'closedLoop', TraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', - TraversalEdgeBehavior.parentScope: 'parentScope', }; 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..f71dbf46 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 @@ -22,8 +22,7 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( json['titlePadding'] as Map), 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 @@ -31,8 +30,7 @@ _$MiraiAlertDialogImpl _$$MiraiAlertDialogImplFromJson( json['contentPadding'] as Map), 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(), 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_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 1f6da58e..85513c1d 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 @@ -27,12 +27,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..ec7c50fe 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,7 +20,7 @@ _$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), 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..20a8c622 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,7 +12,7 @@ _$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( 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..5d77b1b7 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,12 +22,10 @@ _$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( 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..1448d8f3 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 @@ -30,8 +30,7 @@ _$MiraiFloatingActionButtonThemeDataImpl json['extendedPadding'] as Map), 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_input_decoration/mirai_input_decoration.g.dart b/packages/mirai/lib/src/parsers/mirai_input_decoration/mirai_input_decoration.g.dart index 5da180c7..5a451bcf 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']), @@ -57,8 +55,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 +66,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..c6eb82a8 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']), @@ -41,18 +39,15 @@ _$MiraiInputDecorationThemeImpl _$$MiraiInputDecorationThemeImplFromJson( 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_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..84e79686 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,16 +19,13 @@ _$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( 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_tab_bar/mirai_tab_bar.g.dart b/packages/mirai/lib/src/parsers/mirai_tab_bar/mirai_tab_bar.g.dart index 2bb48464..95429789 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 @@ -29,7 +29,7 @@ _$MiraiTabBarImpl _$$MiraiTabBarImplFromJson(Map json) => 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( @@ -37,8 +37,7 @@ _$MiraiTabBarImpl _$$MiraiTabBarImplFromJson(Map json) => 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..e9a2c6ff 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 @@ -24,12 +24,11 @@ _$MiraiTabBarThemeDataImpl _$$MiraiTabBarThemeDataImplFromJson( json['labelPadding'] as Map), 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..7afac555 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( 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], From 6415ed7149592326c9c02425eb3e788eca9b730d Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 29 Feb 2024 18:33:01 +0400 Subject: [PATCH 11/24] fix: Cocoa pods version upgraded and fixed pubspec --- examples/mirai_gallery/macos/Podfile.lock | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- examples/mirai_gallery/pubspec.lock | 32 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/mirai_gallery/macos/Podfile.lock b/examples/mirai_gallery/macos/Podfile.lock index 79862f06..9133c7d7 100644 --- a/examples/mirai_gallery/macos/Podfile.lock +++ b/examples/mirai_gallery/macos/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.3 \ No newline at end of file diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj index 39f233b6..110378e8 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj @@ -258,7 +258,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ca25b4d5..8d1ec463 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 29 Feb 2024 18:39:32 +0400 Subject: [PATCH 12/24] fix: Updated pubspec in mirai/mirai_gallery --- examples/mirai_gallery/pubspec.lock | 90 ++++++++++++++++++----------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/examples/mirai_gallery/pubspec.lock b/examples/mirai_gallery/pubspec.lock index f80e02f5..8f5cf719 100644 --- a/examples/mirai_gallery/pubspec.lock +++ b/examples/mirai_gallery/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: bloc - sha256: f53a110e3b48dcd78136c10daa5d51512443cea5e1348c9d80a320095fa2db9e + sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49" url: "https://pub.dev" source: hosted - version: "8.1.3" + version: "8.1.2" boolean_selector: dependency: transitive description: @@ -109,10 +109,10 @@ packages: dependency: transitive description: name: built_value - sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + sha256: a3ec2e0f967bc47f69f95009bb93db936288d61d5343b9436e378b28a2f830c6 url: "https://pub.dev" source: hosted - version: "8.9.1" + version: "8.9.0" characters: dependency: transitive description: @@ -181,18 +181,18 @@ packages: dependency: transitive description: name: dart_style - sha256: "25b4624c231844a7a70a3817a729a6190a751ef1c07ded256e126a3b72261444" + sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368" url: "https://pub.dev" source: hosted - version: "2.3.5" + version: "2.3.4" dio: dependency: transitive description: name: dio - sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8" + sha256: "797e1e341c3dd2f69f2dad42564a6feff3bfb87187d05abb93b9609e6f1645c3" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "5.4.0" fake_async: dependency: transitive description: @@ -226,10 +226,10 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "87325da1ac757fcc4813e6b34ed5dd61169973871fdf181d6c2109dd6935ece1" + sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae url: "https://pub.dev" source: hosted - version: "8.1.4" + version: "8.1.3" flutter_lints: dependency: "direct dev" description: @@ -311,10 +311,10 @@ packages: dependency: transitive description: name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.7.0" json_annotation: dependency: "direct main" description: @@ -331,6 +331,30 @@ packages: url: "https://pub.dev" source: hosted version: "6.7.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -359,26 +383,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" mime: dependency: transitive description: @@ -428,10 +452,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" plugin_platform_interface: dependency: transitive description: @@ -452,10 +476,10 @@ packages: dependency: transitive description: name: provider - sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" url: "https://pub.dev" source: hosted - version: "6.1.2" + version: "6.1.1" pub_semver: dependency: transitive description: @@ -589,22 +613,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - watcher: + vm_service: dependency: transitive description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted - version: "1.1.0" - web: + version: "13.0.0" + watcher: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "1.1.0" web_socket_channel: dependency: transitive description: @@ -617,10 +641,10 @@ packages: dependency: transitive description: name: webview_flutter - sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932" + sha256: d81b68e88cc353e546afb93fb38958e3717282c5ac6e5d3be4a4aef9fc3c1413 url: "https://pub.dev" source: hosted - version: "4.7.0" + version: "4.5.0" webview_flutter_android: dependency: transitive description: @@ -655,4 +679,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.6" + flutter: ">=3.16.6" \ No newline at end of file From 4e880f9e6874270773878f4a0c17a013c54c8085 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 29 Feb 2024 18:46:06 +0400 Subject: [PATCH 13/24] fix: Updated podfile in mirai_gallery/macos and pubspec in example --- examples/mirai_gallery/macos/Podfile.lock | 2 +- examples/mirai_gallery/pubspec.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mirai_gallery/macos/Podfile.lock b/examples/mirai_gallery/macos/Podfile.lock index 9133c7d7..1f6779f9 100644 --- a/examples/mirai_gallery/macos/Podfile.lock +++ b/examples/mirai_gallery/macos/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.14.3 \ No newline at end of file +COCOAPODS: 1.14.3 diff --git a/examples/mirai_gallery/pubspec.lock b/examples/mirai_gallery/pubspec.lock index 8f5cf719..d1e81e2c 100644 --- a/examples/mirai_gallery/pubspec.lock +++ b/examples/mirai_gallery/pubspec.lock @@ -679,4 +679,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.6" \ No newline at end of file + flutter: ">=3.16.6" From 7a77957b72550636f966bd7aef5245e288425e44 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 29 Feb 2024 18:55:24 +0400 Subject: [PATCH 14/24] fix: Run melos build in packages/mirai --- .../mirai_dialog_action/mirai_dialog_action.g.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart index d67fc766..949d3f10 100644 --- a/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart +++ b/packages/mirai/lib/src/action_parsers/mirai_dialog_action/mirai_dialog_action.g.dart @@ -40,4 +40,5 @@ Map _$$MiraiDialogActionImplToJson( const _$TraversalEdgeBehaviorEnumMap = { TraversalEdgeBehavior.closedLoop: 'closedLoop', TraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', + TraversalEdgeBehavior.parentScope: 'parentScope', }; From 20bdd8b5b08544451bf73288ba3a2033c8f708b3 Mon Sep 17 00:00:00 2001 From: superiorsd10 Date: Thu, 29 Feb 2024 21:32:25 +0530 Subject: [PATCH 15/24] fix(mirai_edge_insets): replace List by List and check if all elements are num --- .../src/parsers/mirai_edge_insets/mirai_edge_insets.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 44777b24..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 @@ -25,7 +25,11 @@ class MiraiEdgeInsets with _$MiraiEdgeInsets { "right": json, "bottom": json }; - } else if (json is List && json.length == 4) { + } 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], From 7c92dc80478d102e003e85ab829c04d8a8bfb0b6 Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 20:22:52 +0400 Subject: [PATCH 16/24] Add support for Filled Button added comments are addressed++ - focusnode and materialStatesController removed - parseFilledButton added by removing parseElevated --- .../mirai_button_style.dart | 19 +++++++++++++++++++ .../mirai_filled_button_parser.dart | 8 +------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.dart b/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.dart index 8f48b27e..1b959f84 100644 --- a/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.dart +++ b/packages/mirai/lib/src/parsers/mirai_button_style/mirai_button_style.dart @@ -116,4 +116,23 @@ extension MiraiButtonStyleParser on MiraiButtonStyle { iconSize: iconSize, ); } + + ButtonStyle parseFilledButton(BuildContext context) { + return FilledButton.styleFrom( + foregroundColor: foregroundColor?.toColor(context), + backgroundColor: backgroundColor.toColor(context), + disabledForegroundColor: disabledForegroundColor.toColor(context), + disabledBackgroundColor: disabledBackgroundColor.toColor(context), + shadowColor: shadowColor.toColor(context), + surfaceTintColor: surfaceTintColor.toColor(context), + elevation: elevation, + textStyle: textStyle?.parse(context), + enableFeedback: enableFeedback, + minimumSize: minimumSize?.parse, + fixedSize: fixedSize?.parse, + maximumSize: maximumSize?.parse, + shape: shape.parse(context), + padding: padding.parse, + ); + } } diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart index cddc3bcb..b05ccf39 100644 --- a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button_parser.dart @@ -14,21 +14,15 @@ class MiraiFilledButtonParser extends MiraiParser { @override Widget parse(BuildContext context, MiraiFilledButton model) { - FocusNode? focusNode = FocusNode(); - MaterialStatesController? materialStatesController = - MaterialStatesController(); - return FilledButton( onPressed: model.onPressed == null ? null : () => model.onPressed, onLongPress: model.onLongPress == null ? null : () => model.onLongPress, onHover: (bool value) => value == false ? null : model.onHover, onFocusChange: (bool value) => value == false ? null : model.onFocusChange, - style: model.style?.parseElevated(context), + style: model.style?.parseFilledButton(context), autofocus: model.autofocus, clipBehavior: model.clipBehavior, - focusNode: focusNode, - statesController: materialStatesController, child: Mirai.fromJson(model.child, context), ); } From 85b44a5f13e7a4d53b5a441ba04b71f25d005b97 Mon Sep 17 00:00:00 2001 From: iampranabray Date: Thu, 29 Feb 2024 20:36:31 +0400 Subject: [PATCH 17/24] Add support for Filled Button freezed button file updated --- .../mirai_filled_button/mirai_filled_button.freezed.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart index 3a23b609..5b3eed87 100644 --- a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.freezed.dart @@ -26,8 +26,7 @@ mixin _$MiraiFilledButton { Map? get onFocusChange => throw _privateConstructorUsedError; MiraiButtonStyle? get style => throw _privateConstructorUsedError; bool get autofocus => throw _privateConstructorUsedError; - Clip get clipBehavior => - throw _privateConstructorUsedError; //MaterialStatesController? statesController, + Clip get clipBehavior => throw _privateConstructorUsedError; Map? get child => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -274,9 +273,7 @@ class _$MiraiFilledButtonImpl implements _MiraiFilledButton { @override @JsonKey() final Clip clipBehavior; -//MaterialStatesController? statesController, final Map? _child; -//MaterialStatesController? statesController, @override Map? get child { final value = _child; @@ -367,7 +364,7 @@ abstract class _MiraiFilledButton implements MiraiFilledButton { bool get autofocus; @override Clip get clipBehavior; - @override //MaterialStatesController? statesController, + @override Map? get child; @override @JsonKey(ignore: true) From c410410f06d64128281bbedc4d9660a8378b454a Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Thu, 29 Feb 2024 23:57:06 +0400 Subject: [PATCH 18/24] Fix imports for Mirai Wrap --- packages/mirai/lib/src/framework/mirai.dart | 1 - .../mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index bfb15294..8ba72931 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -7,7 +7,6 @@ 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'; 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 index ca53a6ff..c5c261df 100644 --- a/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_wrap/mirai_wrap_parser.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:mirai/mirai.dart'; +import 'package:mirai/src/framework/framework.dart'; import 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; import 'package:mirai/src/utils/widget_type.dart'; +import 'package:mirai_framework/mirai_framework.dart'; class MiraiWrapParser extends MiraiParser { const MiraiWrapParser(); From 91d34e30baf1b53391e28a24bfaaa588cdc621c8 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Fri, 1 Mar 2024 12:59:29 +0400 Subject: [PATCH 19/24] Fix code formatting in MiraiFilledButton --- packages/mirai/lib/src/framework/mirai.dart | 2 +- .../src/parsers/mirai_filled_button/mirai_filled_button.dart | 4 +++- packages/mirai/lib/src/parsers/parsers.dart | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index b3ccf256..cb8b3bfe 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -65,7 +65,7 @@ class Mirai { const MiraiCircleAvatarParser(), const MiraiChipParser(), const MiraiGridViewParser(), - const MiraiFilledButtonParser() + const MiraiFilledButtonParser(), const MiraiBottomNavigationViewParser(), const MiraiDefaultBottomNavigationControllerParser(), const MiraiWrapParser(), diff --git a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart index ab80cacb..23b271a5 100644 --- a/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart +++ b/packages/mirai/lib/src/parsers/mirai_filled_button/mirai_filled_button.dart @@ -1,7 +1,9 @@ +import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import "package:mirai/src/parsers/mirai_button_style/mirai_button_style.dart"; -import 'package:flutter/material.dart'; + export 'mirai_filled_button_parser.dart'; + part 'mirai_filled_button.freezed.dart'; part 'mirai_filled_button.g.dart'; diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index acfe61b9..c4c478b5 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -31,6 +31,7 @@ export 'package:mirai/src/parsers/mirai_dialog_theme/mirai_dialog_theme.dart'; export 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart'; export 'package:mirai/src/parsers/mirai_elevated_button/mirai_elevated_button.dart'; export 'package:mirai/src/parsers/mirai_expanded/mirai_expanded.dart'; +export 'package:mirai/src/parsers/mirai_filled_button/mirai_filled_button.dart'; export 'package:mirai/src/parsers/mirai_flexible/mirai_flexible.dart'; export 'package:mirai/src/parsers/mirai_floating_action_button/mirai_floating_action_button.dart'; export 'package:mirai/src/parsers/mirai_floating_action_button_theme_data/mirai_floating_action_button_theme_data.dart'; @@ -72,6 +73,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_chip/mirai_chip.dart'; -export 'package:mirai/src/parsers/mirai_filled_button/mirai_filled_button.dart'; export 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; From 2a5fcfca2ace89f07a0302b02d5dcfdb2aa43da9 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Fri, 1 Mar 2024 14:10:42 +0400 Subject: [PATCH 20/24] Enhance Icon Button Parser by adding more options and fix the model naming. --- .../mirai_icon_button/mirai_icon_button.dart | 12 +- .../mirai_icon_button.freezed.dart | 296 +++++++++++------- .../mirai_icon_button.g.dart | 26 +- .../mirai_icon_button_parser.dart | 18 +- 4 files changed, 227 insertions(+), 125 deletions(-) diff --git a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.dart b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.dart index 488666c0..fb43bd4e 100644 --- a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.dart +++ b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.dart @@ -1,5 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:mirai/src/parsers/mirai_alignment/mirai_alignment.dart'; +import 'package:mirai/src/parsers/mirai_box_constraints/mirai_box_constraints.dart'; import 'package:mirai/src/parsers/mirai_button_style/mirai_button_style.dart'; import 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart'; @@ -11,10 +12,9 @@ part 'mirai_icon_button.g.dart'; @freezed class MiraiIconButton with _$MiraiIconButton { const factory MiraiIconButton({ - Map? onPressed, double? iconSize, MiraiEdgeInsets? padding, - @Default(MiraiAlignment.center) MiraiAlignment alignment, + MiraiAlignment? alignment, double? splashRadius, String? color, String? focusColor, @@ -22,11 +22,15 @@ class MiraiIconButton with _$MiraiIconButton { String? highlightColor, String? splashColor, String? disabledColor, + Map? onPressed, + @Default(false) bool autofocus, + String? tooltip, + bool? enableFeedback, + MiraiBoxConstraints? constraints, MiraiButtonStyle? style, - @Default(false) autofocus, bool? isSelected, Map? selectedIcon, - required Map child, + Map? icon, }) = _MiraiIconButton; factory MiraiIconButton.fromJson(Map json) => diff --git a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.freezed.dart b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.freezed.dart index 09c8e60f..02a13f64 100644 --- a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button.freezed.dart @@ -20,10 +20,9 @@ MiraiIconButton _$MiraiIconButtonFromJson(Map json) { /// @nodoc mixin _$MiraiIconButton { - Map? get onPressed => throw _privateConstructorUsedError; double? get iconSize => throw _privateConstructorUsedError; MiraiEdgeInsets? get padding => throw _privateConstructorUsedError; - MiraiAlignment get alignment => throw _privateConstructorUsedError; + MiraiAlignment? get alignment => throw _privateConstructorUsedError; double? get splashRadius => throw _privateConstructorUsedError; String? get color => throw _privateConstructorUsedError; String? get focusColor => throw _privateConstructorUsedError; @@ -31,11 +30,15 @@ mixin _$MiraiIconButton { String? get highlightColor => throw _privateConstructorUsedError; String? get splashColor => throw _privateConstructorUsedError; String? get disabledColor => throw _privateConstructorUsedError; + Map? get onPressed => throw _privateConstructorUsedError; + bool get autofocus => throw _privateConstructorUsedError; + String? get tooltip => throw _privateConstructorUsedError; + bool? get enableFeedback => throw _privateConstructorUsedError; + MiraiBoxConstraints? get constraints => throw _privateConstructorUsedError; MiraiButtonStyle? get style => throw _privateConstructorUsedError; - dynamic get autofocus => throw _privateConstructorUsedError; bool? get isSelected => throw _privateConstructorUsedError; Map? get selectedIcon => throw _privateConstructorUsedError; - Map get child => throw _privateConstructorUsedError; + Map? get icon => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -50,10 +53,9 @@ abstract class $MiraiIconButtonCopyWith<$Res> { _$MiraiIconButtonCopyWithImpl<$Res, MiraiIconButton>; @useResult $Res call( - {Map? onPressed, - double? iconSize, + {double? iconSize, MiraiEdgeInsets? padding, - MiraiAlignment alignment, + MiraiAlignment? alignment, double? splashRadius, String? color, String? focusColor, @@ -61,13 +63,18 @@ abstract class $MiraiIconButtonCopyWith<$Res> { String? highlightColor, String? splashColor, String? disabledColor, + Map? onPressed, + bool autofocus, + String? tooltip, + bool? enableFeedback, + MiraiBoxConstraints? constraints, MiraiButtonStyle? style, - dynamic autofocus, bool? isSelected, Map? selectedIcon, - Map child}); + Map? icon}); $MiraiEdgeInsetsCopyWith<$Res>? get padding; + $MiraiBoxConstraintsCopyWith<$Res>? get constraints; $MiraiButtonStyleCopyWith<$Res>? get style; } @@ -84,10 +91,9 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> @pragma('vm:prefer-inline') @override $Res call({ - Object? onPressed = freezed, Object? iconSize = freezed, Object? padding = freezed, - Object? alignment = null, + Object? alignment = freezed, Object? splashRadius = freezed, Object? color = freezed, Object? focusColor = freezed, @@ -95,17 +101,17 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> Object? highlightColor = freezed, Object? splashColor = freezed, Object? disabledColor = freezed, + Object? onPressed = freezed, + Object? autofocus = null, + Object? tooltip = freezed, + Object? enableFeedback = freezed, + Object? constraints = freezed, Object? style = freezed, - Object? autofocus = freezed, Object? isSelected = freezed, Object? selectedIcon = freezed, - Object? child = null, + Object? icon = freezed, }) { return _then(_value.copyWith( - onPressed: freezed == onPressed - ? _value.onPressed - : onPressed // ignore: cast_nullable_to_non_nullable - as Map?, iconSize: freezed == iconSize ? _value.iconSize : iconSize // ignore: cast_nullable_to_non_nullable @@ -114,10 +120,10 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> ? _value.padding : padding // ignore: cast_nullable_to_non_nullable as MiraiEdgeInsets?, - alignment: null == alignment + alignment: freezed == alignment ? _value.alignment : alignment // ignore: cast_nullable_to_non_nullable - as MiraiAlignment, + as MiraiAlignment?, splashRadius: freezed == splashRadius ? _value.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable @@ -146,14 +152,30 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> ? _value.disabledColor : disabledColor // ignore: cast_nullable_to_non_nullable as String?, + onPressed: freezed == onPressed + ? _value.onPressed + : onPressed // ignore: cast_nullable_to_non_nullable + as Map?, + autofocus: null == autofocus + ? _value.autofocus + : autofocus // ignore: cast_nullable_to_non_nullable + as bool, + tooltip: freezed == tooltip + ? _value.tooltip + : tooltip // ignore: cast_nullable_to_non_nullable + as String?, + enableFeedback: freezed == enableFeedback + ? _value.enableFeedback + : enableFeedback // ignore: cast_nullable_to_non_nullable + as bool?, + constraints: freezed == constraints + ? _value.constraints + : constraints // ignore: cast_nullable_to_non_nullable + as MiraiBoxConstraints?, style: freezed == style ? _value.style : style // ignore: cast_nullable_to_non_nullable as MiraiButtonStyle?, - autofocus: freezed == autofocus - ? _value.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as dynamic, isSelected: freezed == isSelected ? _value.isSelected : isSelected // ignore: cast_nullable_to_non_nullable @@ -162,10 +184,10 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> ? _value.selectedIcon : selectedIcon // ignore: cast_nullable_to_non_nullable as Map?, - child: null == child - ? _value.child - : child // ignore: cast_nullable_to_non_nullable - as Map, + icon: freezed == icon + ? _value.icon + : icon // ignore: cast_nullable_to_non_nullable + as Map?, ) as $Val); } @@ -181,6 +203,18 @@ class _$MiraiIconButtonCopyWithImpl<$Res, $Val extends MiraiIconButton> }); } + @override + @pragma('vm:prefer-inline') + $MiraiBoxConstraintsCopyWith<$Res>? get constraints { + if (_value.constraints == null) { + return null; + } + + return $MiraiBoxConstraintsCopyWith<$Res>(_value.constraints!, (value) { + return _then(_value.copyWith(constraints: value) as $Val); + }); + } + @override @pragma('vm:prefer-inline') $MiraiButtonStyleCopyWith<$Res>? get style { @@ -203,10 +237,9 @@ abstract class _$$MiraiIconButtonImplCopyWith<$Res> @override @useResult $Res call( - {Map? onPressed, - double? iconSize, + {double? iconSize, MiraiEdgeInsets? padding, - MiraiAlignment alignment, + MiraiAlignment? alignment, double? splashRadius, String? color, String? focusColor, @@ -214,15 +247,21 @@ abstract class _$$MiraiIconButtonImplCopyWith<$Res> String? highlightColor, String? splashColor, String? disabledColor, + Map? onPressed, + bool autofocus, + String? tooltip, + bool? enableFeedback, + MiraiBoxConstraints? constraints, MiraiButtonStyle? style, - dynamic autofocus, bool? isSelected, Map? selectedIcon, - Map child}); + Map? icon}); @override $MiraiEdgeInsetsCopyWith<$Res>? get padding; @override + $MiraiBoxConstraintsCopyWith<$Res>? get constraints; + @override $MiraiButtonStyleCopyWith<$Res>? get style; } @@ -237,10 +276,9 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? onPressed = freezed, Object? iconSize = freezed, Object? padding = freezed, - Object? alignment = null, + Object? alignment = freezed, Object? splashRadius = freezed, Object? color = freezed, Object? focusColor = freezed, @@ -248,17 +286,17 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> Object? highlightColor = freezed, Object? splashColor = freezed, Object? disabledColor = freezed, + Object? onPressed = freezed, + Object? autofocus = null, + Object? tooltip = freezed, + Object? enableFeedback = freezed, + Object? constraints = freezed, Object? style = freezed, - Object? autofocus = freezed, Object? isSelected = freezed, Object? selectedIcon = freezed, - Object? child = null, + Object? icon = freezed, }) { return _then(_$MiraiIconButtonImpl( - onPressed: freezed == onPressed - ? _value._onPressed - : onPressed // ignore: cast_nullable_to_non_nullable - as Map?, iconSize: freezed == iconSize ? _value.iconSize : iconSize // ignore: cast_nullable_to_non_nullable @@ -267,10 +305,10 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> ? _value.padding : padding // ignore: cast_nullable_to_non_nullable as MiraiEdgeInsets?, - alignment: null == alignment + alignment: freezed == alignment ? _value.alignment : alignment // ignore: cast_nullable_to_non_nullable - as MiraiAlignment, + as MiraiAlignment?, splashRadius: freezed == splashRadius ? _value.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable @@ -299,11 +337,30 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> ? _value.disabledColor : disabledColor // ignore: cast_nullable_to_non_nullable as String?, + onPressed: freezed == onPressed + ? _value._onPressed + : onPressed // ignore: cast_nullable_to_non_nullable + as Map?, + autofocus: null == autofocus + ? _value.autofocus + : autofocus // ignore: cast_nullable_to_non_nullable + as bool, + tooltip: freezed == tooltip + ? _value.tooltip + : tooltip // ignore: cast_nullable_to_non_nullable + as String?, + enableFeedback: freezed == enableFeedback + ? _value.enableFeedback + : enableFeedback // ignore: cast_nullable_to_non_nullable + as bool?, + constraints: freezed == constraints + ? _value.constraints + : constraints // ignore: cast_nullable_to_non_nullable + as MiraiBoxConstraints?, style: freezed == style ? _value.style : style // ignore: cast_nullable_to_non_nullable as MiraiButtonStyle?, - autofocus: freezed == autofocus ? _value.autofocus! : autofocus, isSelected: freezed == isSelected ? _value.isSelected : isSelected // ignore: cast_nullable_to_non_nullable @@ -312,10 +369,10 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> ? _value._selectedIcon : selectedIcon // ignore: cast_nullable_to_non_nullable as Map?, - child: null == child - ? _value._child - : child // ignore: cast_nullable_to_non_nullable - as Map, + icon: freezed == icon + ? _value._icon + : icon // ignore: cast_nullable_to_non_nullable + as Map?, )); } } @@ -324,10 +381,9 @@ class __$$MiraiIconButtonImplCopyWithImpl<$Res> @JsonSerializable() class _$MiraiIconButtonImpl implements _MiraiIconButton { const _$MiraiIconButtonImpl( - {final Map? onPressed, - this.iconSize, + {this.iconSize, this.padding, - this.alignment = MiraiAlignment.center, + this.alignment, this.splashRadius, this.color, this.focusColor, @@ -335,35 +391,28 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { this.highlightColor, this.splashColor, this.disabledColor, - this.style, + final Map? onPressed, this.autofocus = false, + this.tooltip, + this.enableFeedback, + this.constraints, + this.style, this.isSelected, final Map? selectedIcon, - required final Map child}) + final Map? icon}) : _onPressed = onPressed, _selectedIcon = selectedIcon, - _child = child; + _icon = icon; factory _$MiraiIconButtonImpl.fromJson(Map json) => _$$MiraiIconButtonImplFromJson(json); - final Map? _onPressed; - @override - Map? get onPressed { - final value = _onPressed; - if (value == null) return null; - if (_onPressed is EqualUnmodifiableMapView) return _onPressed; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - @override final double? iconSize; @override final MiraiEdgeInsets? padding; @override - @JsonKey() - final MiraiAlignment alignment; + final MiraiAlignment? alignment; @override final double? splashRadius; @override @@ -378,11 +427,27 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { final String? splashColor; @override final String? disabledColor; + final Map? _onPressed; @override - final MiraiButtonStyle? style; + Map? get onPressed { + final value = _onPressed; + if (value == null) return null; + if (_onPressed is EqualUnmodifiableMapView) return _onPressed; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + @override @JsonKey() - final dynamic autofocus; + final bool autofocus; + @override + final String? tooltip; + @override + final bool? enableFeedback; + @override + final MiraiBoxConstraints? constraints; + @override + final MiraiButtonStyle? style; @override final bool? isSelected; final Map? _selectedIcon; @@ -395,17 +460,19 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { return EqualUnmodifiableMapView(value); } - final Map _child; + final Map? _icon; @override - Map get child { - if (_child is EqualUnmodifiableMapView) return _child; + Map? get icon { + final value = _icon; + if (value == null) return null; + if (_icon is EqualUnmodifiableMapView) return _icon; // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_child); + return EqualUnmodifiableMapView(value); } @override String toString() { - return 'MiraiIconButton(onPressed: $onPressed, iconSize: $iconSize, padding: $padding, alignment: $alignment, splashRadius: $splashRadius, color: $color, focusColor: $focusColor, hoverColor: $hoverColor, highlightColor: $highlightColor, splashColor: $splashColor, disabledColor: $disabledColor, style: $style, autofocus: $autofocus, isSelected: $isSelected, selectedIcon: $selectedIcon, child: $child)'; + return 'MiraiIconButton(iconSize: $iconSize, padding: $padding, alignment: $alignment, splashRadius: $splashRadius, color: $color, focusColor: $focusColor, hoverColor: $hoverColor, highlightColor: $highlightColor, splashColor: $splashColor, disabledColor: $disabledColor, onPressed: $onPressed, autofocus: $autofocus, tooltip: $tooltip, enableFeedback: $enableFeedback, constraints: $constraints, style: $style, isSelected: $isSelected, selectedIcon: $selectedIcon, icon: $icon)'; } @override @@ -413,8 +480,6 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { return identical(this, other) || (other.runtimeType == runtimeType && other is _$MiraiIconButtonImpl && - const DeepCollectionEquality() - .equals(other._onPressed, _onPressed) && (identical(other.iconSize, iconSize) || other.iconSize == iconSize) && (identical(other.padding, padding) || other.padding == padding) && @@ -433,35 +498,47 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { other.splashColor == splashColor) && (identical(other.disabledColor, disabledColor) || other.disabledColor == disabledColor) && + const DeepCollectionEquality() + .equals(other._onPressed, _onPressed) && + (identical(other.autofocus, autofocus) || + other.autofocus == autofocus) && + (identical(other.tooltip, tooltip) || other.tooltip == tooltip) && + (identical(other.enableFeedback, enableFeedback) || + other.enableFeedback == enableFeedback) && + (identical(other.constraints, constraints) || + other.constraints == constraints) && (identical(other.style, style) || other.style == style) && - const DeepCollectionEquality().equals(other.autofocus, autofocus) && (identical(other.isSelected, isSelected) || other.isSelected == isSelected) && const DeepCollectionEquality() .equals(other._selectedIcon, _selectedIcon) && - const DeepCollectionEquality().equals(other._child, _child)); + const DeepCollectionEquality().equals(other._icon, _icon)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_onPressed), - iconSize, - padding, - alignment, - splashRadius, - color, - focusColor, - hoverColor, - highlightColor, - splashColor, - disabledColor, - style, - const DeepCollectionEquality().hash(autofocus), - isSelected, - const DeepCollectionEquality().hash(_selectedIcon), - const DeepCollectionEquality().hash(_child)); + int get hashCode => Object.hashAll([ + runtimeType, + iconSize, + padding, + alignment, + splashRadius, + color, + focusColor, + hoverColor, + highlightColor, + splashColor, + disabledColor, + const DeepCollectionEquality().hash(_onPressed), + autofocus, + tooltip, + enableFeedback, + constraints, + style, + isSelected, + const DeepCollectionEquality().hash(_selectedIcon), + const DeepCollectionEquality().hash(_icon) + ]); @JsonKey(ignore: true) @override @@ -480,10 +557,9 @@ class _$MiraiIconButtonImpl implements _MiraiIconButton { abstract class _MiraiIconButton implements MiraiIconButton { const factory _MiraiIconButton( - {final Map? onPressed, - final double? iconSize, + {final double? iconSize, final MiraiEdgeInsets? padding, - final MiraiAlignment alignment, + final MiraiAlignment? alignment, final double? splashRadius, final String? color, final String? focusColor, @@ -491,23 +567,25 @@ abstract class _MiraiIconButton implements MiraiIconButton { final String? highlightColor, final String? splashColor, final String? disabledColor, + final Map? onPressed, + final bool autofocus, + final String? tooltip, + final bool? enableFeedback, + final MiraiBoxConstraints? constraints, final MiraiButtonStyle? style, - final dynamic autofocus, final bool? isSelected, final Map? selectedIcon, - required final Map child}) = _$MiraiIconButtonImpl; + final Map? icon}) = _$MiraiIconButtonImpl; factory _MiraiIconButton.fromJson(Map json) = _$MiraiIconButtonImpl.fromJson; - @override - Map? get onPressed; @override double? get iconSize; @override MiraiEdgeInsets? get padding; @override - MiraiAlignment get alignment; + MiraiAlignment? get alignment; @override double? get splashRadius; @override @@ -523,15 +601,23 @@ abstract class _MiraiIconButton implements MiraiIconButton { @override String? get disabledColor; @override - MiraiButtonStyle? get style; + Map? get onPressed; @override - dynamic get autofocus; + bool get autofocus; + @override + String? get tooltip; + @override + bool? get enableFeedback; + @override + MiraiBoxConstraints? get constraints; + @override + MiraiButtonStyle? get style; @override bool? get isSelected; @override Map? get selectedIcon; @override - Map get child; + Map? get icon; @override @JsonKey(ignore: true) _$$MiraiIconButtonImplCopyWith<_$MiraiIconButtonImpl> get copyWith => 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 b8cad032..25f702c3 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 @@ -9,14 +9,12 @@ part of 'mirai_icon_button.dart'; _$MiraiIconButtonImpl _$$MiraiIconButtonImplFromJson( Map json) => _$MiraiIconButtonImpl( - onPressed: json['onPressed'] as Map?, iconSize: (json['iconSize'] as num?)?.toDouble(), padding: json['padding'] == null ? null : MiraiEdgeInsets.fromJson(json['padding']), alignment: - $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']) ?? - MiraiAlignment.center, + $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']), splashRadius: (json['splashRadius'] as num?)?.toDouble(), color: json['color'] as String?, focusColor: json['focusColor'] as String?, @@ -24,22 +22,28 @@ _$MiraiIconButtonImpl _$$MiraiIconButtonImplFromJson( highlightColor: json['highlightColor'] as String?, splashColor: json['splashColor'] as String?, disabledColor: json['disabledColor'] as String?, + onPressed: json['onPressed'] as Map?, + autofocus: json['autofocus'] as bool? ?? false, + tooltip: json['tooltip'] as String?, + enableFeedback: json['enableFeedback'] as bool?, + constraints: json['constraints'] == null + ? null + : MiraiBoxConstraints.fromJson( + json['constraints'] as Map), style: json['style'] == null ? null : MiraiButtonStyle.fromJson(json['style'] as Map), - autofocus: json['autofocus'] ?? false, isSelected: json['isSelected'] as bool?, selectedIcon: json['selectedIcon'] as Map?, - child: json['child'] as Map, + icon: json['icon'] as Map?, ); Map _$$MiraiIconButtonImplToJson( _$MiraiIconButtonImpl instance) => { - 'onPressed': instance.onPressed, 'iconSize': instance.iconSize, 'padding': instance.padding, - 'alignment': _$MiraiAlignmentEnumMap[instance.alignment]!, + 'alignment': _$MiraiAlignmentEnumMap[instance.alignment], 'splashRadius': instance.splashRadius, 'color': instance.color, 'focusColor': instance.focusColor, @@ -47,11 +51,15 @@ Map _$$MiraiIconButtonImplToJson( 'highlightColor': instance.highlightColor, 'splashColor': instance.splashColor, 'disabledColor': instance.disabledColor, - 'style': instance.style, + 'onPressed': instance.onPressed, 'autofocus': instance.autofocus, + 'tooltip': instance.tooltip, + 'enableFeedback': instance.enableFeedback, + 'constraints': instance.constraints, + 'style': instance.style, 'isSelected': instance.isSelected, 'selectedIcon': instance.selectedIcon, - 'child': instance.child, + 'icon': instance.icon, }; const _$MiraiAlignmentEnumMap = { diff --git a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button_parser.dart b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button_parser.dart index 441b1f5d..bb43d7d9 100644 --- a/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_icon_button/mirai_icon_button_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mirai/src/framework/framework.dart'; +import 'package:mirai/src/parsers/mirai_box_constraints/mirai_box_constraints.dart'; import 'package:mirai/src/parsers/parsers.dart'; import 'package:mirai/src/utils/color_utils.dart'; import 'package:mirai/src/utils/widget_type.dart'; @@ -18,12 +19,9 @@ class MiraiIconButtonParser extends MiraiParser { @override Widget parse(BuildContext context, MiraiIconButton model) { return IconButton( - onPressed: model.onPressed == null - ? null - : () => Mirai.onCallFromJson(model.onPressed, context), iconSize: model.iconSize, - padding: model.padding?.parse, - alignment: model.alignment.value, + padding: model.padding.parse, + alignment: model.alignment?.value, splashRadius: model.splashRadius, color: model.color.toColor(context), focusColor: model.focusColor.toColor(context), @@ -31,11 +29,17 @@ class MiraiIconButtonParser extends MiraiParser { highlightColor: model.highlightColor.toColor(context), splashColor: model.splashColor.toColor(context), disabledColor: model.disabledColor.toColor(context), - style: model.style?.parseIcon(context), + onPressed: model.onPressed == null + ? null + : () => Mirai.onCallFromJson(model.onPressed, context), autofocus: model.autofocus, + tooltip: model.tooltip, + enableFeedback: model.enableFeedback, + constraints: model.constraints?.parse, + style: model.style?.parseIcon(context), isSelected: model.isSelected, selectedIcon: Mirai.fromJson(model.selectedIcon, context), - icon: Mirai.fromJson(model.child, context) ?? const SizedBox(), + icon: Mirai.fromJson(model.icon, context) ?? const SizedBox(), ); } } From a7c158c1aec1eabba8418ceda4dc9d787fb498e0 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Sat, 2 Mar 2024 12:53:59 +0400 Subject: [PATCH 21/24] Refactor Mirai Switch Widget --- .../assets/json/switch_example.json | 17 +- .../parsers/mirai_switch/mirai_switch.dart | 78 +---- .../mirai_switch/mirai_switch.freezed.dart | 313 ++++++++++-------- .../parsers/mirai_switch/mirai_switch.g.dart | 51 +-- .../mirai_switch/mirai_switch_parser.dart | 156 ++++++++- .../widget/mirai_switch_widget.dart | 147 -------- packages/mirai/lib/src/utils/widget_type.dart | 1 - 7 files changed, 367 insertions(+), 396 deletions(-) delete mode 100644 packages/mirai/lib/src/parsers/mirai_switch/widget/mirai_switch_widget.dart diff --git a/examples/mirai_gallery/assets/json/switch_example.json b/examples/mirai_gallery/assets/json/switch_example.json index e2230e88..2ba65bca 100644 --- a/examples/mirai_gallery/assets/json/switch_example.json +++ b/examples/mirai_gallery/assets/json/switch_example.json @@ -23,32 +23,27 @@ "crossAxisAlignment": "center", "children": [ { - "type": "switchButton", + "type": "switch", "switchType": "cupertino", - "initialValue": true, - "onChanged": {} + "value": true }, { "type": "sizedBox", "width": 20 }, { - "type": "switchButton", + "type": "switch", "switchType": "adaptive", - "initialValue": false, - "onChanged": {}, - "inActiveColor": "#FF0000", - "activeColor": "#0000FF" + "value": true }, { "type": "sizedBox", "width": 20 }, { - "type": "switchButton", + "type": "switch", "switchType": "material", - "initialValue": false, - "onChanged": {} + "value": false } ] }, diff --git a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.dart b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.dart index e580a744..28acaa6b 100644 --- a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.dart +++ b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.dart @@ -1,7 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:mirai/mirai.dart'; import 'package:mirai/src/parsers/mirai_material_color/mirai_material_color.dart'; export 'package:mirai/src/parsers/mirai_switch/mirai_switch_parser.dart'; @@ -13,91 +12,34 @@ enum MiraiSwitchType { adaptive, cupertino, material } @freezed class MiraiSwitch with _$MiraiSwitch { - const MiraiSwitch._(); - const factory MiraiSwitch({ @Default(MiraiSwitchType.material) MiraiSwitchType switchType, - @Default(false) initialValue, + @Default(false) value, Map? onChanged, @Default(false) bool autofocus, - @Default(false) bool disabled, String? activeColor, String? activeTrackColor, String? focusColor, String? hoverColor, String? inactiveThumbColor, String? inactiveTrackColor, + String? onLabelColor, + String? offLabelColor, double? splashRadius, - String? dragStartBehavior, + @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, MiraiMaterialColor? overlayColor, MiraiMaterialColor? thumbColor, MiraiMaterialColor? trackColor, - String? materialTapTargetSize, + MaterialTapTargetSize? materialTapTargetSize, MiraiMaterialColor? trackOutlineColor, double? trackOutlineWidth, - MiraiIcon? thumbIcon, - MiraiImage? inactiveThumbImage, - MiraiImage? activeThumbImage, + Map? thumbIcon, + String? inactiveThumbImage, + String? activeThumbImage, + bool? applyTheme, + bool? applyCupertinoTheme, }) = _MiraiSwitch; factory MiraiSwitch.fromJson(Map json) => _$MiraiSwitchFromJson(json); - - DragStartBehavior get dragStateBehaviorValue { - return DragStartBehavior.values.firstWhere( - (element) => element.name == dragStartBehavior, - orElse: () => DragStartBehavior.start, - ); - } - - Color? activeColorValue(BuildContext context) => - activeColor?.toColor(context); - - Color? activeTrackColorValue(BuildContext context) => - activeTrackColor?.toColor(context); - - Color? focusColorValue(BuildContext context) => focusColor?.toColor(context); - - Color? hoverColorValue(BuildContext context) => hoverColor?.toColor(context); - - Color? inactiveThumbColorValue(BuildContext context) => - inactiveThumbColor?.toColor(context); - - Color? inactiveTrackColorValue(BuildContext context) => - inactiveTrackColor?.toColor(context); - - MaterialTapTargetSize? get materialTapTargetSizeValue { - return MaterialTapTargetSize.values.firstWhere( - (element) => element.name == materialTapTargetSize, - orElse: () => MaterialTapTargetSize.padded, - ); - } - - Icon? thumbIconWidget(BuildContext context) { - if (thumbIcon == null) return null; - - final Widget? widget = Mirai.fromJson(thumbIcon!.toJson(), context); - if (widget != null && widget is Icon) { - return widget; - } - - return null; - } - - ImageProvider? inactiveThumbImageWidget(BuildContext context) => - _getImageProvider(context, image: inactiveThumbImage); - - ImageProvider? activeThumbImageWidget(BuildContext context) => - _getImageProvider(context, image: activeThumbImage); - - ImageProvider? _getImageProvider(BuildContext context, {MiraiImage? image}) { - if (image == null && (image?.src ?? '').isEmpty) return null; - - final Widget? widget = Mirai.fromJson(image!.toJson(), context); - if (widget != null && widget is Image) { - return widget.image; - } - - return null; - } } diff --git a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.freezed.dart b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.freezed.dart index 3fe635a1..29642642 100644 --- a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.freezed.dart @@ -21,28 +21,32 @@ MiraiSwitch _$MiraiSwitchFromJson(Map json) { /// @nodoc mixin _$MiraiSwitch { MiraiSwitchType get switchType => throw _privateConstructorUsedError; - dynamic get initialValue => throw _privateConstructorUsedError; + dynamic get value => throw _privateConstructorUsedError; Map? get onChanged => throw _privateConstructorUsedError; bool get autofocus => throw _privateConstructorUsedError; - bool get disabled => throw _privateConstructorUsedError; String? get activeColor => throw _privateConstructorUsedError; String? get activeTrackColor => throw _privateConstructorUsedError; String? get focusColor => throw _privateConstructorUsedError; String? get hoverColor => throw _privateConstructorUsedError; String? get inactiveThumbColor => throw _privateConstructorUsedError; String? get inactiveTrackColor => throw _privateConstructorUsedError; + String? get onLabelColor => throw _privateConstructorUsedError; + String? get offLabelColor => throw _privateConstructorUsedError; double? get splashRadius => throw _privateConstructorUsedError; - String? get dragStartBehavior => throw _privateConstructorUsedError; + DragStartBehavior get dragStartBehavior => throw _privateConstructorUsedError; MiraiMaterialColor? get overlayColor => throw _privateConstructorUsedError; MiraiMaterialColor? get thumbColor => throw _privateConstructorUsedError; MiraiMaterialColor? get trackColor => throw _privateConstructorUsedError; - String? get materialTapTargetSize => throw _privateConstructorUsedError; + MaterialTapTargetSize? get materialTapTargetSize => + throw _privateConstructorUsedError; MiraiMaterialColor? get trackOutlineColor => throw _privateConstructorUsedError; double? get trackOutlineWidth => throw _privateConstructorUsedError; - MiraiIcon? get thumbIcon => throw _privateConstructorUsedError; - MiraiImage? get inactiveThumbImage => throw _privateConstructorUsedError; - MiraiImage? get activeThumbImage => throw _privateConstructorUsedError; + Map? get thumbIcon => throw _privateConstructorUsedError; + String? get inactiveThumbImage => throw _privateConstructorUsedError; + String? get activeThumbImage => throw _privateConstructorUsedError; + bool? get applyTheme => throw _privateConstructorUsedError; + bool? get applyCupertinoTheme => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -58,35 +62,35 @@ abstract class $MiraiSwitchCopyWith<$Res> { @useResult $Res call( {MiraiSwitchType switchType, - dynamic initialValue, + dynamic value, Map? onChanged, bool autofocus, - bool disabled, String? activeColor, String? activeTrackColor, String? focusColor, String? hoverColor, String? inactiveThumbColor, String? inactiveTrackColor, + String? onLabelColor, + String? offLabelColor, double? splashRadius, - String? dragStartBehavior, + DragStartBehavior dragStartBehavior, MiraiMaterialColor? overlayColor, MiraiMaterialColor? thumbColor, MiraiMaterialColor? trackColor, - String? materialTapTargetSize, + MaterialTapTargetSize? materialTapTargetSize, MiraiMaterialColor? trackOutlineColor, double? trackOutlineWidth, - MiraiIcon? thumbIcon, - MiraiImage? inactiveThumbImage, - MiraiImage? activeThumbImage}); + Map? thumbIcon, + String? inactiveThumbImage, + String? activeThumbImage, + bool? applyTheme, + bool? applyCupertinoTheme}); $MiraiMaterialColorCopyWith<$Res>? get overlayColor; $MiraiMaterialColorCopyWith<$Res>? get thumbColor; $MiraiMaterialColorCopyWith<$Res>? get trackColor; $MiraiMaterialColorCopyWith<$Res>? get trackOutlineColor; - $MiraiIconCopyWith<$Res>? get thumbIcon; - $MiraiImageCopyWith<$Res>? get inactiveThumbImage; - $MiraiImageCopyWith<$Res>? get activeThumbImage; } /// @nodoc @@ -103,18 +107,19 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> @override $Res call({ Object? switchType = null, - Object? initialValue = freezed, + Object? value = freezed, Object? onChanged = freezed, Object? autofocus = null, - Object? disabled = null, Object? activeColor = freezed, Object? activeTrackColor = freezed, Object? focusColor = freezed, Object? hoverColor = freezed, Object? inactiveThumbColor = freezed, Object? inactiveTrackColor = freezed, + Object? onLabelColor = freezed, + Object? offLabelColor = freezed, Object? splashRadius = freezed, - Object? dragStartBehavior = freezed, + Object? dragStartBehavior = null, Object? overlayColor = freezed, Object? thumbColor = freezed, Object? trackColor = freezed, @@ -124,15 +129,17 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> Object? thumbIcon = freezed, Object? inactiveThumbImage = freezed, Object? activeThumbImage = freezed, + Object? applyTheme = freezed, + Object? applyCupertinoTheme = freezed, }) { return _then(_value.copyWith( switchType: null == switchType ? _value.switchType : switchType // ignore: cast_nullable_to_non_nullable as MiraiSwitchType, - initialValue: freezed == initialValue - ? _value.initialValue - : initialValue // ignore: cast_nullable_to_non_nullable + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable as dynamic, onChanged: freezed == onChanged ? _value.onChanged @@ -142,10 +149,6 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> ? _value.autofocus : autofocus // ignore: cast_nullable_to_non_nullable as bool, - disabled: null == disabled - ? _value.disabled - : disabled // ignore: cast_nullable_to_non_nullable - as bool, activeColor: freezed == activeColor ? _value.activeColor : activeColor // ignore: cast_nullable_to_non_nullable @@ -170,14 +173,22 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> ? _value.inactiveTrackColor : inactiveTrackColor // ignore: cast_nullable_to_non_nullable as String?, + onLabelColor: freezed == onLabelColor + ? _value.onLabelColor + : onLabelColor // ignore: cast_nullable_to_non_nullable + as String?, + offLabelColor: freezed == offLabelColor + ? _value.offLabelColor + : offLabelColor // ignore: cast_nullable_to_non_nullable + as String?, splashRadius: freezed == splashRadius ? _value.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable as double?, - dragStartBehavior: freezed == dragStartBehavior + dragStartBehavior: null == dragStartBehavior ? _value.dragStartBehavior : dragStartBehavior // ignore: cast_nullable_to_non_nullable - as String?, + as DragStartBehavior, overlayColor: freezed == overlayColor ? _value.overlayColor : overlayColor // ignore: cast_nullable_to_non_nullable @@ -193,7 +204,7 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> materialTapTargetSize: freezed == materialTapTargetSize ? _value.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable - as String?, + as MaterialTapTargetSize?, trackOutlineColor: freezed == trackOutlineColor ? _value.trackOutlineColor : trackOutlineColor // ignore: cast_nullable_to_non_nullable @@ -205,15 +216,23 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> thumbIcon: freezed == thumbIcon ? _value.thumbIcon : thumbIcon // ignore: cast_nullable_to_non_nullable - as MiraiIcon?, + as Map?, inactiveThumbImage: freezed == inactiveThumbImage ? _value.inactiveThumbImage : inactiveThumbImage // ignore: cast_nullable_to_non_nullable - as MiraiImage?, + as String?, activeThumbImage: freezed == activeThumbImage ? _value.activeThumbImage : activeThumbImage // ignore: cast_nullable_to_non_nullable - as MiraiImage?, + as String?, + applyTheme: freezed == applyTheme + ? _value.applyTheme + : applyTheme // ignore: cast_nullable_to_non_nullable + as bool?, + applyCupertinoTheme: freezed == applyCupertinoTheme + ? _value.applyCupertinoTheme + : applyCupertinoTheme // ignore: cast_nullable_to_non_nullable + as bool?, ) as $Val); } @@ -265,42 +284,6 @@ class _$MiraiSwitchCopyWithImpl<$Res, $Val extends MiraiSwitch> return _then(_value.copyWith(trackOutlineColor: value) as $Val); }); } - - @override - @pragma('vm:prefer-inline') - $MiraiIconCopyWith<$Res>? get thumbIcon { - if (_value.thumbIcon == null) { - return null; - } - - return $MiraiIconCopyWith<$Res>(_value.thumbIcon!, (value) { - return _then(_value.copyWith(thumbIcon: value) as $Val); - }); - } - - @override - @pragma('vm:prefer-inline') - $MiraiImageCopyWith<$Res>? get inactiveThumbImage { - if (_value.inactiveThumbImage == null) { - return null; - } - - return $MiraiImageCopyWith<$Res>(_value.inactiveThumbImage!, (value) { - return _then(_value.copyWith(inactiveThumbImage: value) as $Val); - }); - } - - @override - @pragma('vm:prefer-inline') - $MiraiImageCopyWith<$Res>? get activeThumbImage { - if (_value.activeThumbImage == null) { - return null; - } - - return $MiraiImageCopyWith<$Res>(_value.activeThumbImage!, (value) { - return _then(_value.copyWith(activeThumbImage: value) as $Val); - }); - } } /// @nodoc @@ -313,27 +296,30 @@ abstract class _$$MiraiSwitchImplCopyWith<$Res> @useResult $Res call( {MiraiSwitchType switchType, - dynamic initialValue, + dynamic value, Map? onChanged, bool autofocus, - bool disabled, String? activeColor, String? activeTrackColor, String? focusColor, String? hoverColor, String? inactiveThumbColor, String? inactiveTrackColor, + String? onLabelColor, + String? offLabelColor, double? splashRadius, - String? dragStartBehavior, + DragStartBehavior dragStartBehavior, MiraiMaterialColor? overlayColor, MiraiMaterialColor? thumbColor, MiraiMaterialColor? trackColor, - String? materialTapTargetSize, + MaterialTapTargetSize? materialTapTargetSize, MiraiMaterialColor? trackOutlineColor, double? trackOutlineWidth, - MiraiIcon? thumbIcon, - MiraiImage? inactiveThumbImage, - MiraiImage? activeThumbImage}); + Map? thumbIcon, + String? inactiveThumbImage, + String? activeThumbImage, + bool? applyTheme, + bool? applyCupertinoTheme}); @override $MiraiMaterialColorCopyWith<$Res>? get overlayColor; @@ -343,12 +329,6 @@ abstract class _$$MiraiSwitchImplCopyWith<$Res> $MiraiMaterialColorCopyWith<$Res>? get trackColor; @override $MiraiMaterialColorCopyWith<$Res>? get trackOutlineColor; - @override - $MiraiIconCopyWith<$Res>? get thumbIcon; - @override - $MiraiImageCopyWith<$Res>? get inactiveThumbImage; - @override - $MiraiImageCopyWith<$Res>? get activeThumbImage; } /// @nodoc @@ -363,18 +343,19 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> @override $Res call({ Object? switchType = null, - Object? initialValue = freezed, + Object? value = freezed, Object? onChanged = freezed, Object? autofocus = null, - Object? disabled = null, Object? activeColor = freezed, Object? activeTrackColor = freezed, Object? focusColor = freezed, Object? hoverColor = freezed, Object? inactiveThumbColor = freezed, Object? inactiveTrackColor = freezed, + Object? onLabelColor = freezed, + Object? offLabelColor = freezed, Object? splashRadius = freezed, - Object? dragStartBehavior = freezed, + Object? dragStartBehavior = null, Object? overlayColor = freezed, Object? thumbColor = freezed, Object? trackColor = freezed, @@ -384,14 +365,15 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> Object? thumbIcon = freezed, Object? inactiveThumbImage = freezed, Object? activeThumbImage = freezed, + Object? applyTheme = freezed, + Object? applyCupertinoTheme = freezed, }) { return _then(_$MiraiSwitchImpl( switchType: null == switchType ? _value.switchType : switchType // ignore: cast_nullable_to_non_nullable as MiraiSwitchType, - initialValue: - freezed == initialValue ? _value.initialValue! : initialValue, + value: freezed == value ? _value.value! : value, onChanged: freezed == onChanged ? _value._onChanged : onChanged // ignore: cast_nullable_to_non_nullable @@ -400,10 +382,6 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> ? _value.autofocus : autofocus // ignore: cast_nullable_to_non_nullable as bool, - disabled: null == disabled - ? _value.disabled - : disabled // ignore: cast_nullable_to_non_nullable - as bool, activeColor: freezed == activeColor ? _value.activeColor : activeColor // ignore: cast_nullable_to_non_nullable @@ -428,14 +406,22 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> ? _value.inactiveTrackColor : inactiveTrackColor // ignore: cast_nullable_to_non_nullable as String?, + onLabelColor: freezed == onLabelColor + ? _value.onLabelColor + : onLabelColor // ignore: cast_nullable_to_non_nullable + as String?, + offLabelColor: freezed == offLabelColor + ? _value.offLabelColor + : offLabelColor // ignore: cast_nullable_to_non_nullable + as String?, splashRadius: freezed == splashRadius ? _value.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable as double?, - dragStartBehavior: freezed == dragStartBehavior + dragStartBehavior: null == dragStartBehavior ? _value.dragStartBehavior : dragStartBehavior // ignore: cast_nullable_to_non_nullable - as String?, + as DragStartBehavior, overlayColor: freezed == overlayColor ? _value.overlayColor : overlayColor // ignore: cast_nullable_to_non_nullable @@ -451,7 +437,7 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> materialTapTargetSize: freezed == materialTapTargetSize ? _value.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable - as String?, + as MaterialTapTargetSize?, trackOutlineColor: freezed == trackOutlineColor ? _value.trackOutlineColor : trackOutlineColor // ignore: cast_nullable_to_non_nullable @@ -461,49 +447,60 @@ class __$$MiraiSwitchImplCopyWithImpl<$Res> : trackOutlineWidth // ignore: cast_nullable_to_non_nullable as double?, thumbIcon: freezed == thumbIcon - ? _value.thumbIcon + ? _value._thumbIcon : thumbIcon // ignore: cast_nullable_to_non_nullable - as MiraiIcon?, + as Map?, inactiveThumbImage: freezed == inactiveThumbImage ? _value.inactiveThumbImage : inactiveThumbImage // ignore: cast_nullable_to_non_nullable - as MiraiImage?, + as String?, activeThumbImage: freezed == activeThumbImage ? _value.activeThumbImage : activeThumbImage // ignore: cast_nullable_to_non_nullable - as MiraiImage?, + as String?, + applyTheme: freezed == applyTheme + ? _value.applyTheme + : applyTheme // ignore: cast_nullable_to_non_nullable + as bool?, + applyCupertinoTheme: freezed == applyCupertinoTheme + ? _value.applyCupertinoTheme + : applyCupertinoTheme // ignore: cast_nullable_to_non_nullable + as bool?, )); } } /// @nodoc @JsonSerializable() -class _$MiraiSwitchImpl extends _MiraiSwitch { +class _$MiraiSwitchImpl implements _MiraiSwitch { const _$MiraiSwitchImpl( {this.switchType = MiraiSwitchType.material, - this.initialValue = false, + this.value = false, final Map? onChanged, this.autofocus = false, - this.disabled = false, this.activeColor, this.activeTrackColor, this.focusColor, this.hoverColor, this.inactiveThumbColor, this.inactiveTrackColor, + this.onLabelColor, + this.offLabelColor, this.splashRadius, - this.dragStartBehavior, + this.dragStartBehavior = DragStartBehavior.start, this.overlayColor, this.thumbColor, this.trackColor, this.materialTapTargetSize, this.trackOutlineColor, this.trackOutlineWidth, - this.thumbIcon, + final Map? thumbIcon, this.inactiveThumbImage, - this.activeThumbImage}) + this.activeThumbImage, + this.applyTheme, + this.applyCupertinoTheme}) : _onChanged = onChanged, - super._(); + _thumbIcon = thumbIcon; factory _$MiraiSwitchImpl.fromJson(Map json) => _$$MiraiSwitchImplFromJson(json); @@ -513,7 +510,7 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { final MiraiSwitchType switchType; @override @JsonKey() - final dynamic initialValue; + final dynamic value; final Map? _onChanged; @override Map? get onChanged { @@ -528,9 +525,6 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { @JsonKey() final bool autofocus; @override - @JsonKey() - final bool disabled; - @override final String? activeColor; @override final String? activeTrackColor; @@ -543,9 +537,14 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { @override final String? inactiveTrackColor; @override + final String? onLabelColor; + @override + final String? offLabelColor; + @override final double? splashRadius; @override - final String? dragStartBehavior; + @JsonKey() + final DragStartBehavior dragStartBehavior; @override final MiraiMaterialColor? overlayColor; @override @@ -553,21 +552,33 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { @override final MiraiMaterialColor? trackColor; @override - final String? materialTapTargetSize; + final MaterialTapTargetSize? materialTapTargetSize; @override final MiraiMaterialColor? trackOutlineColor; @override final double? trackOutlineWidth; + final Map? _thumbIcon; + @override + Map? get thumbIcon { + final value = _thumbIcon; + if (value == null) return null; + if (_thumbIcon is EqualUnmodifiableMapView) return _thumbIcon; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + @override - final MiraiIcon? thumbIcon; + final String? inactiveThumbImage; @override - final MiraiImage? inactiveThumbImage; + final String? activeThumbImage; @override - final MiraiImage? activeThumbImage; + final bool? applyTheme; + @override + final bool? applyCupertinoTheme; @override String toString() { - return 'MiraiSwitch(switchType: $switchType, initialValue: $initialValue, onChanged: $onChanged, autofocus: $autofocus, disabled: $disabled, activeColor: $activeColor, activeTrackColor: $activeTrackColor, focusColor: $focusColor, hoverColor: $hoverColor, inactiveThumbColor: $inactiveThumbColor, inactiveTrackColor: $inactiveTrackColor, splashRadius: $splashRadius, dragStartBehavior: $dragStartBehavior, overlayColor: $overlayColor, thumbColor: $thumbColor, trackColor: $trackColor, materialTapTargetSize: $materialTapTargetSize, trackOutlineColor: $trackOutlineColor, trackOutlineWidth: $trackOutlineWidth, thumbIcon: $thumbIcon, inactiveThumbImage: $inactiveThumbImage, activeThumbImage: $activeThumbImage)'; + return 'MiraiSwitch(switchType: $switchType, value: $value, onChanged: $onChanged, autofocus: $autofocus, activeColor: $activeColor, activeTrackColor: $activeTrackColor, focusColor: $focusColor, hoverColor: $hoverColor, inactiveThumbColor: $inactiveThumbColor, inactiveTrackColor: $inactiveTrackColor, onLabelColor: $onLabelColor, offLabelColor: $offLabelColor, splashRadius: $splashRadius, dragStartBehavior: $dragStartBehavior, overlayColor: $overlayColor, thumbColor: $thumbColor, trackColor: $trackColor, materialTapTargetSize: $materialTapTargetSize, trackOutlineColor: $trackOutlineColor, trackOutlineWidth: $trackOutlineWidth, thumbIcon: $thumbIcon, inactiveThumbImage: $inactiveThumbImage, activeThumbImage: $activeThumbImage, applyTheme: $applyTheme, applyCupertinoTheme: $applyCupertinoTheme)'; } @override @@ -577,14 +588,11 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { other is _$MiraiSwitchImpl && (identical(other.switchType, switchType) || other.switchType == switchType) && - const DeepCollectionEquality() - .equals(other.initialValue, initialValue) && + const DeepCollectionEquality().equals(other.value, value) && const DeepCollectionEquality() .equals(other._onChanged, _onChanged) && (identical(other.autofocus, autofocus) || other.autofocus == autofocus) && - (identical(other.disabled, disabled) || - other.disabled == disabled) && (identical(other.activeColor, activeColor) || other.activeColor == activeColor) && (identical(other.activeTrackColor, activeTrackColor) || @@ -597,6 +605,10 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { other.inactiveThumbColor == inactiveThumbColor) && (identical(other.inactiveTrackColor, inactiveTrackColor) || other.inactiveTrackColor == inactiveTrackColor) && + (identical(other.onLabelColor, onLabelColor) || + other.onLabelColor == onLabelColor) && + (identical(other.offLabelColor, offLabelColor) || + other.offLabelColor == offLabelColor) && (identical(other.splashRadius, splashRadius) || other.splashRadius == splashRadius) && (identical(other.dragStartBehavior, dragStartBehavior) || @@ -613,12 +625,16 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { other.trackOutlineColor == trackOutlineColor) && (identical(other.trackOutlineWidth, trackOutlineWidth) || other.trackOutlineWidth == trackOutlineWidth) && - (identical(other.thumbIcon, thumbIcon) || - other.thumbIcon == thumbIcon) && + const DeepCollectionEquality() + .equals(other._thumbIcon, _thumbIcon) && (identical(other.inactiveThumbImage, inactiveThumbImage) || other.inactiveThumbImage == inactiveThumbImage) && (identical(other.activeThumbImage, activeThumbImage) || - other.activeThumbImage == activeThumbImage)); + other.activeThumbImage == activeThumbImage) && + (identical(other.applyTheme, applyTheme) || + other.applyTheme == applyTheme) && + (identical(other.applyCupertinoTheme, applyCupertinoTheme) || + other.applyCupertinoTheme == applyCupertinoTheme)); } @JsonKey(ignore: true) @@ -626,16 +642,17 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { int get hashCode => Object.hashAll([ runtimeType, switchType, - const DeepCollectionEquality().hash(initialValue), + const DeepCollectionEquality().hash(value), const DeepCollectionEquality().hash(_onChanged), autofocus, - disabled, activeColor, activeTrackColor, focusColor, hoverColor, inactiveThumbColor, inactiveTrackColor, + onLabelColor, + offLabelColor, splashRadius, dragStartBehavior, overlayColor, @@ -644,9 +661,11 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { materialTapTargetSize, trackOutlineColor, trackOutlineWidth, - thumbIcon, + const DeepCollectionEquality().hash(_thumbIcon), inactiveThumbImage, - activeThumbImage + activeThumbImage, + applyTheme, + applyCupertinoTheme ]); @JsonKey(ignore: true) @@ -663,31 +682,33 @@ class _$MiraiSwitchImpl extends _MiraiSwitch { } } -abstract class _MiraiSwitch extends MiraiSwitch { +abstract class _MiraiSwitch implements MiraiSwitch { const factory _MiraiSwitch( {final MiraiSwitchType switchType, - final dynamic initialValue, + final dynamic value, final Map? onChanged, final bool autofocus, - final bool disabled, final String? activeColor, final String? activeTrackColor, final String? focusColor, final String? hoverColor, final String? inactiveThumbColor, final String? inactiveTrackColor, + final String? onLabelColor, + final String? offLabelColor, final double? splashRadius, - final String? dragStartBehavior, + final DragStartBehavior dragStartBehavior, final MiraiMaterialColor? overlayColor, final MiraiMaterialColor? thumbColor, final MiraiMaterialColor? trackColor, - final String? materialTapTargetSize, + final MaterialTapTargetSize? materialTapTargetSize, final MiraiMaterialColor? trackOutlineColor, final double? trackOutlineWidth, - final MiraiIcon? thumbIcon, - final MiraiImage? inactiveThumbImage, - final MiraiImage? activeThumbImage}) = _$MiraiSwitchImpl; - const _MiraiSwitch._() : super._(); + final Map? thumbIcon, + final String? inactiveThumbImage, + final String? activeThumbImage, + final bool? applyTheme, + final bool? applyCupertinoTheme}) = _$MiraiSwitchImpl; factory _MiraiSwitch.fromJson(Map json) = _$MiraiSwitchImpl.fromJson; @@ -695,14 +716,12 @@ abstract class _MiraiSwitch extends MiraiSwitch { @override MiraiSwitchType get switchType; @override - dynamic get initialValue; + dynamic get value; @override Map? get onChanged; @override bool get autofocus; @override - bool get disabled; - @override String? get activeColor; @override String? get activeTrackColor; @@ -715,9 +734,13 @@ abstract class _MiraiSwitch extends MiraiSwitch { @override String? get inactiveTrackColor; @override + String? get onLabelColor; + @override + String? get offLabelColor; + @override double? get splashRadius; @override - String? get dragStartBehavior; + DragStartBehavior get dragStartBehavior; @override MiraiMaterialColor? get overlayColor; @override @@ -725,17 +748,21 @@ abstract class _MiraiSwitch extends MiraiSwitch { @override MiraiMaterialColor? get trackColor; @override - String? get materialTapTargetSize; + MaterialTapTargetSize? get materialTapTargetSize; @override MiraiMaterialColor? get trackOutlineColor; @override double? get trackOutlineWidth; @override - MiraiIcon? get thumbIcon; + Map? get thumbIcon; + @override + String? get inactiveThumbImage; + @override + String? get activeThumbImage; @override - MiraiImage? get inactiveThumbImage; + bool? get applyTheme; @override - MiraiImage? get activeThumbImage; + bool? get applyCupertinoTheme; @override @JsonKey(ignore: true) _$$MiraiSwitchImplCopyWith<_$MiraiSwitchImpl> get copyWith => diff --git a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.g.dart b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.g.dart index 0ef39e2f..521ff8a6 100644 --- a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.g.dart @@ -11,18 +11,21 @@ _$MiraiSwitchImpl _$$MiraiSwitchImplFromJson(Map json) => switchType: $enumDecodeNullable(_$MiraiSwitchTypeEnumMap, json['switchType']) ?? MiraiSwitchType.material, - initialValue: json['initialValue'] ?? false, + value: json['value'] ?? false, onChanged: json['onChanged'] as Map?, autofocus: json['autofocus'] as bool? ?? false, - disabled: json['disabled'] as bool? ?? false, activeColor: json['activeColor'] as String?, activeTrackColor: json['activeTrackColor'] as String?, focusColor: json['focusColor'] as String?, hoverColor: json['hoverColor'] as String?, inactiveThumbColor: json['inactiveThumbColor'] as String?, inactiveTrackColor: json['inactiveTrackColor'] as String?, + onLabelColor: json['onLabelColor'] as String?, + offLabelColor: json['offLabelColor'] as String?, splashRadius: (json['splashRadius'] as num?)?.toDouble(), - dragStartBehavior: json['dragStartBehavior'] as String?, + dragStartBehavior: $enumDecodeNullable( + _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? + DragStartBehavior.start, overlayColor: json['overlayColor'] == null ? null : MiraiMaterialColor.fromJson( @@ -35,49 +38,49 @@ _$MiraiSwitchImpl _$$MiraiSwitchImplFromJson(Map json) => ? null : MiraiMaterialColor.fromJson( json['trackColor'] as Map), - materialTapTargetSize: json['materialTapTargetSize'] as String?, + materialTapTargetSize: $enumDecodeNullable( + _$MaterialTapTargetSizeEnumMap, json['materialTapTargetSize']), trackOutlineColor: json['trackOutlineColor'] == null ? null : MiraiMaterialColor.fromJson( json['trackOutlineColor'] as Map), trackOutlineWidth: (json['trackOutlineWidth'] as num?)?.toDouble(), - thumbIcon: json['thumbIcon'] == null - ? null - : MiraiIcon.fromJson(json['thumbIcon'] as Map), - inactiveThumbImage: json['inactiveThumbImage'] == null - ? null - : MiraiImage.fromJson( - json['inactiveThumbImage'] as Map), - activeThumbImage: json['activeThumbImage'] == null - ? null - : MiraiImage.fromJson( - json['activeThumbImage'] as Map), + thumbIcon: json['thumbIcon'] as Map?, + inactiveThumbImage: json['inactiveThumbImage'] as String?, + activeThumbImage: json['activeThumbImage'] as String?, + applyTheme: json['applyTheme'] as bool?, + applyCupertinoTheme: json['applyCupertinoTheme'] as bool?, ); Map _$$MiraiSwitchImplToJson(_$MiraiSwitchImpl instance) => { 'switchType': _$MiraiSwitchTypeEnumMap[instance.switchType]!, - 'initialValue': instance.initialValue, + 'value': instance.value, 'onChanged': instance.onChanged, 'autofocus': instance.autofocus, - 'disabled': instance.disabled, 'activeColor': instance.activeColor, 'activeTrackColor': instance.activeTrackColor, 'focusColor': instance.focusColor, 'hoverColor': instance.hoverColor, 'inactiveThumbColor': instance.inactiveThumbColor, 'inactiveTrackColor': instance.inactiveTrackColor, + 'onLabelColor': instance.onLabelColor, + 'offLabelColor': instance.offLabelColor, 'splashRadius': instance.splashRadius, - 'dragStartBehavior': instance.dragStartBehavior, + 'dragStartBehavior': + _$DragStartBehaviorEnumMap[instance.dragStartBehavior]!, 'overlayColor': instance.overlayColor, 'thumbColor': instance.thumbColor, 'trackColor': instance.trackColor, - 'materialTapTargetSize': instance.materialTapTargetSize, + 'materialTapTargetSize': + _$MaterialTapTargetSizeEnumMap[instance.materialTapTargetSize], 'trackOutlineColor': instance.trackOutlineColor, 'trackOutlineWidth': instance.trackOutlineWidth, 'thumbIcon': instance.thumbIcon, 'inactiveThumbImage': instance.inactiveThumbImage, 'activeThumbImage': instance.activeThumbImage, + 'applyTheme': instance.applyTheme, + 'applyCupertinoTheme': instance.applyCupertinoTheme, }; const _$MiraiSwitchTypeEnumMap = { @@ -85,3 +88,13 @@ const _$MiraiSwitchTypeEnumMap = { MiraiSwitchType.cupertino: 'cupertino', MiraiSwitchType.material: 'material', }; + +const _$DragStartBehaviorEnumMap = { + DragStartBehavior.down: 'down', + DragStartBehavior.start: 'start', +}; + +const _$MaterialTapTargetSizeEnumMap = { + MaterialTapTargetSize.padded: 'padded', + MaterialTapTargetSize.shrinkWrap: 'shrinkWrap', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch_parser.dart b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch_parser.dart index d60c1f11..e635c800 100644 --- a/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_switch/mirai_switch_parser.dart @@ -1,20 +1,162 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:mirai/src/parsers/mirai_switch/mirai_switch.dart'; -import 'package:mirai/src/parsers/mirai_switch/widget/mirai_switch_widget.dart'; -import 'package:mirai/src/utils/widget_type.dart'; -import 'package:mirai_framework/mirai_framework.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/parsers/mirai_material_color/mirai_material_color.dart'; +import 'package:mirai/src/utils/action_type.dart'; class MiraiSwitchParser extends MiraiParser { const MiraiSwitchParser(); + /// The reason this type does not come from [ActionType] is because any value cannot be named as "switch". @override - MiraiSwitch getModel(Map json) => MiraiSwitch.fromJson(json); + String get type => "switch"; @override - String get type => WidgetType.switchButton.name; + MiraiSwitch getModel(Map json) => MiraiSwitch.fromJson(json); @override Widget parse(BuildContext context, MiraiSwitch model) { - return MiraiSwitchWidget(model: model); + return _SwitchWidget(model: model); + } +} + +class _SwitchWidget extends StatefulWidget { + const _SwitchWidget({required this.model}); + + final MiraiSwitch model; + + @override + State<_SwitchWidget> createState() => _SwitchWidgetState(); +} + +class _SwitchWidgetState extends State<_SwitchWidget> { + bool isSelected = false; + + @override + void initState() { + super.initState(); + isSelected = widget.model.value ?? false; + } + + @override + Widget build(BuildContext context) { + final MiraiSwitch model = widget.model; + + switch (model.switchType) { + case MiraiSwitchType.cupertino: + return _buildCupertinoSwitch(context, model); + case MiraiSwitchType.adaptive: + return _buildAdaptiveSwitch(context, model); + case MiraiSwitchType.material: + default: + return _buildMaterialSwitch(context, model); + } + } + + /// Change the value of the switch as the user toggles it. + void _onChanged(bool value) { + isSelected = value; + if (widget.model.onChanged != null) { + Mirai.onCallFromJson(widget.model.onChanged, context); + } + setState(() {}); + } + + Icon? thumbIconWidget(BuildContext context, Map? thumbIcon) { + if (thumbIcon == null) return null; + + final Widget? widget = Mirai.fromJson(thumbIcon, context); + if (widget != null && widget is Icon) { + return widget; + } + + return null; + } + + Widget _buildCupertinoSwitch(BuildContext context, MiraiSwitch model) { + return CupertinoSwitch( + value: isSelected, + onChanged: _onChanged, + activeColor: model.activeColor.toColor(context), + trackColor: model.trackColor?.parse(context), + thumbColor: model.thumbColor?.parse(context), + applyTheme: model.applyTheme, + focusColor: model.focusColor?.toColor(context), + onLabelColor: model.onLabelColor?.toColor(context), + offLabelColor: model.offLabelColor?.toColor(context), + autofocus: model.autofocus, + dragStartBehavior: model.dragStartBehavior, + ); + } + + Widget _buildAdaptiveSwitch(BuildContext context, MiraiSwitch model) { + return Switch.adaptive( + value: isSelected, + onChanged: _onChanged, + activeColor: model.activeColor?.toColor(context), + activeTrackColor: model.activeTrackColor?.toColor(context), + inactiveThumbColor: model.inactiveThumbColor?.toColor(context), + inactiveTrackColor: model.inactiveTrackColor?.toColor(context), + activeThumbImage: model.activeThumbImage != null + ? NetworkImage(model.activeThumbImage!) + : null, + inactiveThumbImage: model.inactiveThumbImage != null + ? NetworkImage(model.inactiveThumbImage!) + : null, + materialTapTargetSize: model.materialTapTargetSize, + thumbColor: MaterialStateProperty.all(model.thumbColor?.parse(context)), + trackColor: MaterialStateProperty.all(model.trackColor?.parse(context)), + trackOutlineColor: MaterialStateProperty.all( + model.trackOutlineColor?.parse(context), + ), + trackOutlineWidth: MaterialStateProperty.all(model.trackOutlineWidth), + thumbIcon: MaterialStateProperty.all( + Mirai.fromJson(model.thumbIcon, context) as Icon?, + ), + dragStartBehavior: model.dragStartBehavior, + focusColor: model.focusColor?.toColor(context), + hoverColor: model.hoverColor?.toColor(context), + overlayColor: MaterialStateProperty.all( + model.overlayColor?.parse(context), + ), + splashRadius: model.splashRadius, + autofocus: model.autofocus, + applyCupertinoTheme: model.applyCupertinoTheme, + ); + } + + Widget _buildMaterialSwitch(BuildContext context, MiraiSwitch model) { + return Switch( + value: isSelected, + onChanged: _onChanged, + activeColor: model.activeColor.toColor(context), + activeTrackColor: model.activeTrackColor.toColor(context), + inactiveThumbColor: model.inactiveThumbColor.toColor(context), + inactiveTrackColor: model.inactiveTrackColor.toColor(context), + activeThumbImage: model.activeThumbImage != null + ? NetworkImage(model.activeThumbImage!) + : null, + inactiveThumbImage: model.inactiveThumbImage != null + ? NetworkImage(model.inactiveThumbImage!) + : null, + thumbColor: MaterialStateProperty.all(model.thumbColor?.parse(context)), + trackColor: MaterialStateProperty.all(model.trackColor?.parse(context)), + trackOutlineColor: MaterialStateProperty.all( + model.trackOutlineColor?.parse(context), + ), + trackOutlineWidth: MaterialStateProperty.all(model.trackOutlineWidth), + thumbIcon: MaterialStateProperty.all( + Mirai.fromJson(model.thumbIcon, context) as Icon?, + ), + materialTapTargetSize: model.materialTapTargetSize, + dragStartBehavior: model.dragStartBehavior, + focusColor: model.focusColor?.toColor(context), + hoverColor: model.hoverColor?.toColor(context), + overlayColor: MaterialStateProperty.all( + model.overlayColor?.parse(context), + ), + splashRadius: model.splashRadius, + autofocus: model.autofocus, + ); } } diff --git a/packages/mirai/lib/src/parsers/mirai_switch/widget/mirai_switch_widget.dart b/packages/mirai/lib/src/parsers/mirai_switch/widget/mirai_switch_widget.dart deleted file mode 100644 index c0c15e9a..00000000 --- a/packages/mirai/lib/src/parsers/mirai_switch/widget/mirai_switch_widget.dart +++ /dev/null @@ -1,147 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:mirai/src/framework/framework.dart'; -import 'package:mirai/src/parsers/mirai_material_color/mirai_material_color.dart'; -import 'package:mirai/src/parsers/mirai_switch/mirai_switch.dart'; - -class MiraiSwitchWidget extends StatefulWidget { - const MiraiSwitchWidget({super.key, required this.model}); - - final MiraiSwitch model; - - @override - State createState() => _MiraiSwitchUiWidget(); -} - -class _MiraiSwitchUiWidget extends State { - //#region State based properties - bool isSelected = false; - //#endregion - - //#region State based methods - /// Change the value of the switch as the user toggles it. - void _changeValue(bool value) { - isSelected = value; - if (widget.model.onChanged != null) { - Mirai.onCallFromJson(widget.model.onChanged, context); - } - setState(() {}); - } - //#endregion - - @override - void initState() { - super.initState(); - isSelected = widget.model.initialValue ?? false; - } - - @override - Widget build(BuildContext context) { - final MiraiSwitch model = widget.model; - - switch (model.switchType) { - case MiraiSwitchType.cupertino: - return _buildCupertinoSwitch( - context, - model, - isSelected: isSelected, - onChanged: _changeValue, - ); - case MiraiSwitchType.adaptive: - return _buildAdaptiveSwitch( - context, - model, - isSelected: isSelected, - onChanged: _changeValue, - ); - case MiraiSwitchType.material: - default: - return _buildMaterialSwitch( - context, - model, - isSelected: isSelected, - onChanged: _changeValue, - ); - } - } -} - -Widget _buildCupertinoSwitch( - BuildContext context, - MiraiSwitch model, { - required bool isSelected, - required void Function(bool value) onChanged, -}) { - return CupertinoSwitch( - value: isSelected, - onChanged: !model.disabled ? onChanged : null, - thumbColor: model.thumbColor?.parse(context), - dragStartBehavior: model.dragStateBehaviorValue, - trackColor: model.trackColor?.parse(context), - activeColor: model.activeColorValue(context), - autofocus: model.autofocus, - focusColor: model.focusColorValue(context), - ); -} - -Widget _buildAdaptiveSwitch( - BuildContext context, - MiraiSwitch model, { - required bool isSelected, - required void Function(bool value) onChanged, -}) { - return Switch.adaptive( - value: isSelected, - onChanged: !model.disabled ? onChanged : null, - activeColor: model.activeColorValue(context), - activeTrackColor: model.activeTrackColorValue(context), - autofocus: model.autofocus, - focusColor: model.focusColorValue(context), - hoverColor: model.hoverColorValue(context), - inactiveThumbColor: model.inactiveThumbColorValue(context), - inactiveTrackColor: model.inactiveTrackColorValue(context), - splashRadius: model.splashRadius, - dragStartBehavior: model.dragStateBehaviorValue, - materialTapTargetSize: model.materialTapTargetSizeValue, - overlayColor: MaterialStateProperty.all(model.overlayColor?.parse(context)), - thumbColor: MaterialStateProperty.all(model.thumbColor?.parse(context)), - trackColor: MaterialStateProperty.all(model.trackColor?.parse(context)), - trackOutlineColor: - MaterialStateProperty.all(model.trackOutlineColor?.parse(context)), - trackOutlineWidth: MaterialStateProperty.all(model.trackOutlineWidth), - thumbIcon: MaterialStateProperty.all(model.thumbIconWidget(context)), - inactiveThumbImage: model.inactiveThumbImageWidget(context), - activeThumbImage: model.activeThumbImageWidget(context), - ); -} - -Widget _buildMaterialSwitch( - BuildContext context, - MiraiSwitch model, { - required bool isSelected, - required void Function(bool value) onChanged, -}) { - return Switch( - value: isSelected, - onChanged: !model.disabled ? onChanged : null, - activeColor: model.activeColorValue(context), - activeTrackColor: model.activeTrackColorValue(context), - autofocus: model.autofocus, - focusColor: model.focusColorValue(context), - hoverColor: model.hoverColorValue(context), - inactiveThumbColor: model.inactiveThumbColorValue(context), - inactiveTrackColor: model.inactiveTrackColorValue(context), - splashRadius: model.splashRadius, - dragStartBehavior: model.dragStateBehaviorValue, - materialTapTargetSize: model.materialTapTargetSizeValue, - overlayColor: MaterialStateProperty.all(model.overlayColor?.parse(context)), - thumbColor: MaterialStateProperty.all(model.thumbColor?.parse(context)), - trackColor: MaterialStateProperty.all(model.trackColor?.parse(context)), - trackOutlineColor: - MaterialStateProperty.all(model.trackOutlineColor?.parse(context)), - trackOutlineWidth: MaterialStateProperty.all(model.trackOutlineWidth), - thumbIcon: MaterialStateProperty.all(model.thumbIconWidget(context)), - inactiveThumbImage: model.inactiveThumbImageWidget(context), - activeThumbImage: model.activeThumbImageWidget(context), - ); -} diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index def20a2c..1e7f6435 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -36,7 +36,6 @@ enum WidgetType { expanded, flexible, safeArea, - switchButton, align, pageView, refreshIndicator, From 57242096756d7c19d5b65a1adc05cbffc58a10a1 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Sun, 3 Mar 2024 00:15:51 +0400 Subject: [PATCH 22/24] Refactor Mirai Container --- .../assets/json/container_example.json | 6 +- .../mirai_box_decoration.dart | 9 +- .../mirai_box_decoration.freezed.dart | 85 ++-- .../mirai_box_decoration.g.dart | 17 +- .../mirai_container/mirai_container.dart | 4 + .../mirai_container.freezed.dart | 78 +++- .../mirai_container/mirai_container.g.dart | 10 + .../mirai_container_parser.dart | 22 +- .../mirai_container_image.dart | 62 --- .../mirai_container_image.freezed.dart | 220 --------- .../mirai_container_image.g.dart | 57 --- .../mirai_decoration_image.dart | 68 +++ .../mirai_decoration_image.freezed.dart | 424 ++++++++++++++++++ .../mirai_decoration_image.g.dart | 92 ++++ packages/mirai/lib/src/parsers/parsers.dart | 1 - 15 files changed, 725 insertions(+), 430 deletions(-) delete mode 100644 packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.freezed.dart delete mode 100644 packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.g.dart diff --git a/examples/mirai_gallery/assets/json/container_example.json b/examples/mirai_gallery/assets/json/container_example.json index 8ac7c25b..32391e0d 100644 --- a/examples/mirai_gallery/assets/json/container_example.json +++ b/examples/mirai_gallery/assets/json/container_example.json @@ -19,11 +19,8 @@ { "type": "container", "color": "#672BFF", - "clipBehavior": "hardEdge", "height": 250, - "width": 200, - "decoration": { - } + "width": 200 }, { "type": "sizedBox", @@ -32,7 +29,6 @@ { "type": "container", "color": "#FC5632", - "clipBehavior": "hardEdge", "height": 250, "width": 200, "child": { diff --git a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.dart b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.dart index 1834145d..ebf84275 100644 --- a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.dart +++ b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.dart @@ -3,7 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:mirai/src/parsers/mirai_border/mirai_border.dart'; import 'package:mirai/src/parsers/mirai_border_radius/mirai_border_radius.dart'; import 'package:mirai/src/parsers/mirai_box_shadow/mirai_box_shadow.dart'; -import 'package:mirai/src/parsers/mirai_container_image/mirai_container_image.dart'; +import 'package:mirai/src/parsers/mirai_decoration_image/mirai_decoration_image.dart'; import 'package:mirai/src/parsers/mirai_gradient/mirai_gradient.dart'; import 'package:mirai/src/utils/color_utils.dart'; @@ -14,13 +14,12 @@ part 'mirai_box_decoration.g.dart'; class MiraiBoxDecoration with _$MiraiBoxDecoration { const factory MiraiBoxDecoration({ String? color, - @Default(BorderStyle.none) BorderStyle borderStyle, - BlendMode? blendMode, + BlendMode? backgroundBlendMode, List? boxShadow, @Default(BoxShape.rectangle) BoxShape shape, MiraiBorder? border, MiraiBorderRadius? borderRadius, - MiraiContainerImage? image, + MiraiDecorationImage? image, MiraiGradient? gradient, }) = _MiraiBoxDecoration; @@ -32,7 +31,7 @@ extension MiraiBoxDecorationParser on MiraiBoxDecoration? { BoxDecoration? parse(BuildContext context) { return BoxDecoration( color: this?.color.toColor(context), - backgroundBlendMode: this?.blendMode, + backgroundBlendMode: this?.backgroundBlendMode, boxShadow: this?.boxShadow?.map((elem) => elem.parse(context)).toList(), shape: this?.shape ?? BoxShape.rectangle, border: this?.border?.parse(context), diff --git a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.freezed.dart b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.freezed.dart index 65b625e6..24ae756c 100644 --- a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.freezed.dart @@ -21,13 +21,12 @@ MiraiBoxDecoration _$MiraiBoxDecorationFromJson(Map json) { /// @nodoc mixin _$MiraiBoxDecoration { String? get color => throw _privateConstructorUsedError; - BorderStyle get borderStyle => throw _privateConstructorUsedError; - BlendMode? get blendMode => throw _privateConstructorUsedError; + BlendMode? get backgroundBlendMode => throw _privateConstructorUsedError; List? get boxShadow => throw _privateConstructorUsedError; BoxShape get shape => throw _privateConstructorUsedError; MiraiBorder? get border => throw _privateConstructorUsedError; MiraiBorderRadius? get borderRadius => throw _privateConstructorUsedError; - MiraiContainerImage? get image => throw _privateConstructorUsedError; + MiraiDecorationImage? get image => throw _privateConstructorUsedError; MiraiGradient? get gradient => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -44,18 +43,17 @@ abstract class $MiraiBoxDecorationCopyWith<$Res> { @useResult $Res call( {String? color, - BorderStyle borderStyle, - BlendMode? blendMode, + BlendMode? backgroundBlendMode, List? boxShadow, BoxShape shape, MiraiBorder? border, MiraiBorderRadius? borderRadius, - MiraiContainerImage? image, + MiraiDecorationImage? image, MiraiGradient? gradient}); $MiraiBorderCopyWith<$Res>? get border; $MiraiBorderRadiusCopyWith<$Res>? get borderRadius; - $MiraiContainerImageCopyWith<$Res>? get image; + $MiraiDecorationImageCopyWith<$Res>? get image; $MiraiGradientCopyWith<$Res>? get gradient; } @@ -73,8 +71,7 @@ class _$MiraiBoxDecorationCopyWithImpl<$Res, $Val extends MiraiBoxDecoration> @override $Res call({ Object? color = freezed, - Object? borderStyle = null, - Object? blendMode = freezed, + Object? backgroundBlendMode = freezed, Object? boxShadow = freezed, Object? shape = null, Object? border = freezed, @@ -87,13 +84,9 @@ class _$MiraiBoxDecorationCopyWithImpl<$Res, $Val extends MiraiBoxDecoration> ? _value.color : color // ignore: cast_nullable_to_non_nullable as String?, - borderStyle: null == borderStyle - ? _value.borderStyle - : borderStyle // ignore: cast_nullable_to_non_nullable - as BorderStyle, - blendMode: freezed == blendMode - ? _value.blendMode - : blendMode // ignore: cast_nullable_to_non_nullable + backgroundBlendMode: freezed == backgroundBlendMode + ? _value.backgroundBlendMode + : backgroundBlendMode // ignore: cast_nullable_to_non_nullable as BlendMode?, boxShadow: freezed == boxShadow ? _value.boxShadow @@ -114,7 +107,7 @@ class _$MiraiBoxDecorationCopyWithImpl<$Res, $Val extends MiraiBoxDecoration> image: freezed == image ? _value.image : image // ignore: cast_nullable_to_non_nullable - as MiraiContainerImage?, + as MiraiDecorationImage?, gradient: freezed == gradient ? _value.gradient : gradient // ignore: cast_nullable_to_non_nullable @@ -148,12 +141,12 @@ class _$MiraiBoxDecorationCopyWithImpl<$Res, $Val extends MiraiBoxDecoration> @override @pragma('vm:prefer-inline') - $MiraiContainerImageCopyWith<$Res>? get image { + $MiraiDecorationImageCopyWith<$Res>? get image { if (_value.image == null) { return null; } - return $MiraiContainerImageCopyWith<$Res>(_value.image!, (value) { + return $MiraiDecorationImageCopyWith<$Res>(_value.image!, (value) { return _then(_value.copyWith(image: value) as $Val); }); } @@ -181,13 +174,12 @@ abstract class _$$MiraiBoxDecorationImplCopyWith<$Res> @useResult $Res call( {String? color, - BorderStyle borderStyle, - BlendMode? blendMode, + BlendMode? backgroundBlendMode, List? boxShadow, BoxShape shape, MiraiBorder? border, MiraiBorderRadius? borderRadius, - MiraiContainerImage? image, + MiraiDecorationImage? image, MiraiGradient? gradient}); @override @@ -195,7 +187,7 @@ abstract class _$$MiraiBoxDecorationImplCopyWith<$Res> @override $MiraiBorderRadiusCopyWith<$Res>? get borderRadius; @override - $MiraiContainerImageCopyWith<$Res>? get image; + $MiraiDecorationImageCopyWith<$Res>? get image; @override $MiraiGradientCopyWith<$Res>? get gradient; } @@ -212,8 +204,7 @@ class __$$MiraiBoxDecorationImplCopyWithImpl<$Res> @override $Res call({ Object? color = freezed, - Object? borderStyle = null, - Object? blendMode = freezed, + Object? backgroundBlendMode = freezed, Object? boxShadow = freezed, Object? shape = null, Object? border = freezed, @@ -226,13 +217,9 @@ class __$$MiraiBoxDecorationImplCopyWithImpl<$Res> ? _value.color : color // ignore: cast_nullable_to_non_nullable as String?, - borderStyle: null == borderStyle - ? _value.borderStyle - : borderStyle // ignore: cast_nullable_to_non_nullable - as BorderStyle, - blendMode: freezed == blendMode - ? _value.blendMode - : blendMode // ignore: cast_nullable_to_non_nullable + backgroundBlendMode: freezed == backgroundBlendMode + ? _value.backgroundBlendMode + : backgroundBlendMode // ignore: cast_nullable_to_non_nullable as BlendMode?, boxShadow: freezed == boxShadow ? _value._boxShadow @@ -253,7 +240,7 @@ class __$$MiraiBoxDecorationImplCopyWithImpl<$Res> image: freezed == image ? _value.image : image // ignore: cast_nullable_to_non_nullable - as MiraiContainerImage?, + as MiraiDecorationImage?, gradient: freezed == gradient ? _value.gradient : gradient // ignore: cast_nullable_to_non_nullable @@ -267,8 +254,7 @@ class __$$MiraiBoxDecorationImplCopyWithImpl<$Res> class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { const _$MiraiBoxDecorationImpl( {this.color, - this.borderStyle = BorderStyle.none, - this.blendMode, + this.backgroundBlendMode, final List? boxShadow, this.shape = BoxShape.rectangle, this.border, @@ -283,10 +269,7 @@ class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { @override final String? color; @override - @JsonKey() - final BorderStyle borderStyle; - @override - final BlendMode? blendMode; + final BlendMode? backgroundBlendMode; final List? _boxShadow; @override List? get boxShadow { @@ -305,13 +288,13 @@ class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { @override final MiraiBorderRadius? borderRadius; @override - final MiraiContainerImage? image; + final MiraiDecorationImage? image; @override final MiraiGradient? gradient; @override String toString() { - return 'MiraiBoxDecoration(color: $color, borderStyle: $borderStyle, blendMode: $blendMode, boxShadow: $boxShadow, shape: $shape, border: $border, borderRadius: $borderRadius, image: $image, gradient: $gradient)'; + return 'MiraiBoxDecoration(color: $color, backgroundBlendMode: $backgroundBlendMode, boxShadow: $boxShadow, shape: $shape, border: $border, borderRadius: $borderRadius, image: $image, gradient: $gradient)'; } @override @@ -320,10 +303,8 @@ class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { (other.runtimeType == runtimeType && other is _$MiraiBoxDecorationImpl && (identical(other.color, color) || other.color == color) && - (identical(other.borderStyle, borderStyle) || - other.borderStyle == borderStyle) && - (identical(other.blendMode, blendMode) || - other.blendMode == blendMode) && + (identical(other.backgroundBlendMode, backgroundBlendMode) || + other.backgroundBlendMode == backgroundBlendMode) && const DeepCollectionEquality() .equals(other._boxShadow, _boxShadow) && (identical(other.shape, shape) || other.shape == shape) && @@ -340,8 +321,7 @@ class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { int get hashCode => Object.hash( runtimeType, color, - borderStyle, - blendMode, + backgroundBlendMode, const DeepCollectionEquality().hash(_boxShadow), shape, border, @@ -367,13 +347,12 @@ class _$MiraiBoxDecorationImpl implements _MiraiBoxDecoration { abstract class _MiraiBoxDecoration implements MiraiBoxDecoration { const factory _MiraiBoxDecoration( {final String? color, - final BorderStyle borderStyle, - final BlendMode? blendMode, + final BlendMode? backgroundBlendMode, final List? boxShadow, final BoxShape shape, final MiraiBorder? border, final MiraiBorderRadius? borderRadius, - final MiraiContainerImage? image, + final MiraiDecorationImage? image, final MiraiGradient? gradient}) = _$MiraiBoxDecorationImpl; factory _MiraiBoxDecoration.fromJson(Map json) = @@ -382,9 +361,7 @@ abstract class _MiraiBoxDecoration implements MiraiBoxDecoration { @override String? get color; @override - BorderStyle get borderStyle; - @override - BlendMode? get blendMode; + BlendMode? get backgroundBlendMode; @override List? get boxShadow; @override @@ -394,7 +371,7 @@ abstract class _MiraiBoxDecoration implements MiraiBoxDecoration { @override MiraiBorderRadius? get borderRadius; @override - MiraiContainerImage? get image; + MiraiDecorationImage? get image; @override MiraiGradient? get gradient; @override diff --git a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart index 9638fcd5..e351d611 100644 --- a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart @@ -10,10 +10,8 @@ _$MiraiBoxDecorationImpl _$$MiraiBoxDecorationImplFromJson( Map json) => _$MiraiBoxDecorationImpl( color: json['color'] as String?, - borderStyle: - $enumDecodeNullable(_$BorderStyleEnumMap, json['borderStyle']) ?? - BorderStyle.none, - blendMode: $enumDecodeNullable(_$BlendModeEnumMap, json['blendMode']), + backgroundBlendMode: + $enumDecodeNullable(_$BlendModeEnumMap, json['backgroundBlendMode']), boxShadow: (json['boxShadow'] as List?) ?.map((e) => e == null ? null @@ -30,7 +28,8 @@ _$MiraiBoxDecorationImpl _$$MiraiBoxDecorationImplFromJson( json['borderRadius'] as Map), image: json['image'] == null ? null - : MiraiContainerImage.fromJson(json['image'] as Map), + : MiraiDecorationImage.fromJson( + json['image'] as Map), gradient: json['gradient'] == null ? null : MiraiGradient.fromJson(json['gradient'] as Map), @@ -40,8 +39,7 @@ Map _$$MiraiBoxDecorationImplToJson( _$MiraiBoxDecorationImpl instance) => { 'color': instance.color, - 'borderStyle': _$BorderStyleEnumMap[instance.borderStyle]!, - 'blendMode': _$BlendModeEnumMap[instance.blendMode], + 'backgroundBlendMode': _$BlendModeEnumMap[instance.backgroundBlendMode], 'boxShadow': instance.boxShadow, 'shape': _$BoxShapeEnumMap[instance.shape]!, 'border': instance.border, @@ -50,11 +48,6 @@ Map _$$MiraiBoxDecorationImplToJson( 'gradient': instance.gradient, }; -const _$BorderStyleEnumMap = { - BorderStyle.none: 'none', - BorderStyle.solid: 'solid', -}; - const _$BlendModeEnumMap = { BlendMode.clear: 'clear', BlendMode.src: 'src', diff --git a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.dart b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.dart index 1e7fe0d2..ceae7114 100644 --- a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.dart +++ b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.dart @@ -1,6 +1,8 @@ import 'dart:ui'; + import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:mirai/src/parsers/mirai_alignment/mirai_alignment.dart'; +import 'package:mirai/src/parsers/mirai_box_constraints/mirai_box_constraints.dart'; import 'package:mirai/src/parsers/mirai_box_decoration/mirai_box_decoration.dart'; import 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart'; @@ -15,9 +17,11 @@ class MiraiContainer with _$MiraiContainer { MiraiAlignment? alignment, MiraiEdgeInsets? padding, MiraiBoxDecoration? decoration, + MiraiBoxDecoration? foregroundDecoration, String? color, double? width, double? height, + MiraiBoxConstraints? constraints, MiraiEdgeInsets? margin, Map? child, @Default(Clip.none) Clip clipBehavior, diff --git a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.freezed.dart b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.freezed.dart index 33a4eb1f..31362361 100644 --- a/packages/mirai/lib/src/parsers/mirai_container/mirai_container.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_container/mirai_container.freezed.dart @@ -23,9 +23,12 @@ mixin _$MiraiContainer { MiraiAlignment? get alignment => throw _privateConstructorUsedError; MiraiEdgeInsets? get padding => throw _privateConstructorUsedError; MiraiBoxDecoration? get decoration => throw _privateConstructorUsedError; + MiraiBoxDecoration? get foregroundDecoration => + throw _privateConstructorUsedError; String? get color => throw _privateConstructorUsedError; double? get width => throw _privateConstructorUsedError; double? get height => throw _privateConstructorUsedError; + MiraiBoxConstraints? get constraints => throw _privateConstructorUsedError; MiraiEdgeInsets? get margin => throw _privateConstructorUsedError; Map? get child => throw _privateConstructorUsedError; Clip get clipBehavior => throw _privateConstructorUsedError; @@ -46,15 +49,19 @@ abstract class $MiraiContainerCopyWith<$Res> { {MiraiAlignment? alignment, MiraiEdgeInsets? padding, MiraiBoxDecoration? decoration, + MiraiBoxDecoration? foregroundDecoration, String? color, double? width, double? height, + MiraiBoxConstraints? constraints, MiraiEdgeInsets? margin, Map? child, Clip clipBehavior}); $MiraiEdgeInsetsCopyWith<$Res>? get padding; $MiraiBoxDecorationCopyWith<$Res>? get decoration; + $MiraiBoxDecorationCopyWith<$Res>? get foregroundDecoration; + $MiraiBoxConstraintsCopyWith<$Res>? get constraints; $MiraiEdgeInsetsCopyWith<$Res>? get margin; } @@ -74,9 +81,11 @@ class _$MiraiContainerCopyWithImpl<$Res, $Val extends MiraiContainer> Object? alignment = freezed, Object? padding = freezed, Object? decoration = freezed, + Object? foregroundDecoration = freezed, Object? color = freezed, Object? width = freezed, Object? height = freezed, + Object? constraints = freezed, Object? margin = freezed, Object? child = freezed, Object? clipBehavior = null, @@ -94,6 +103,10 @@ class _$MiraiContainerCopyWithImpl<$Res, $Val extends MiraiContainer> ? _value.decoration : decoration // ignore: cast_nullable_to_non_nullable as MiraiBoxDecoration?, + foregroundDecoration: freezed == foregroundDecoration + ? _value.foregroundDecoration + : foregroundDecoration // ignore: cast_nullable_to_non_nullable + as MiraiBoxDecoration?, color: freezed == color ? _value.color : color // ignore: cast_nullable_to_non_nullable @@ -106,6 +119,10 @@ class _$MiraiContainerCopyWithImpl<$Res, $Val extends MiraiContainer> ? _value.height : height // ignore: cast_nullable_to_non_nullable as double?, + constraints: freezed == constraints + ? _value.constraints + : constraints // ignore: cast_nullable_to_non_nullable + as MiraiBoxConstraints?, margin: freezed == margin ? _value.margin : margin // ignore: cast_nullable_to_non_nullable @@ -145,6 +162,31 @@ class _$MiraiContainerCopyWithImpl<$Res, $Val extends MiraiContainer> }); } + @override + @pragma('vm:prefer-inline') + $MiraiBoxDecorationCopyWith<$Res>? get foregroundDecoration { + if (_value.foregroundDecoration == null) { + return null; + } + + return $MiraiBoxDecorationCopyWith<$Res>(_value.foregroundDecoration!, + (value) { + return _then(_value.copyWith(foregroundDecoration: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBoxConstraintsCopyWith<$Res>? get constraints { + if (_value.constraints == null) { + return null; + } + + return $MiraiBoxConstraintsCopyWith<$Res>(_value.constraints!, (value) { + return _then(_value.copyWith(constraints: value) as $Val); + }); + } + @override @pragma('vm:prefer-inline') $MiraiEdgeInsetsCopyWith<$Res>? get margin { @@ -170,9 +212,11 @@ abstract class _$$MiraiContainerImplCopyWith<$Res> {MiraiAlignment? alignment, MiraiEdgeInsets? padding, MiraiBoxDecoration? decoration, + MiraiBoxDecoration? foregroundDecoration, String? color, double? width, double? height, + MiraiBoxConstraints? constraints, MiraiEdgeInsets? margin, Map? child, Clip clipBehavior}); @@ -182,6 +226,10 @@ abstract class _$$MiraiContainerImplCopyWith<$Res> @override $MiraiBoxDecorationCopyWith<$Res>? get decoration; @override + $MiraiBoxDecorationCopyWith<$Res>? get foregroundDecoration; + @override + $MiraiBoxConstraintsCopyWith<$Res>? get constraints; + @override $MiraiEdgeInsetsCopyWith<$Res>? get margin; } @@ -199,9 +247,11 @@ class __$$MiraiContainerImplCopyWithImpl<$Res> Object? alignment = freezed, Object? padding = freezed, Object? decoration = freezed, + Object? foregroundDecoration = freezed, Object? color = freezed, Object? width = freezed, Object? height = freezed, + Object? constraints = freezed, Object? margin = freezed, Object? child = freezed, Object? clipBehavior = null, @@ -219,6 +269,10 @@ class __$$MiraiContainerImplCopyWithImpl<$Res> ? _value.decoration : decoration // ignore: cast_nullable_to_non_nullable as MiraiBoxDecoration?, + foregroundDecoration: freezed == foregroundDecoration + ? _value.foregroundDecoration + : foregroundDecoration // ignore: cast_nullable_to_non_nullable + as MiraiBoxDecoration?, color: freezed == color ? _value.color : color // ignore: cast_nullable_to_non_nullable @@ -231,6 +285,10 @@ class __$$MiraiContainerImplCopyWithImpl<$Res> ? _value.height : height // ignore: cast_nullable_to_non_nullable as double?, + constraints: freezed == constraints + ? _value.constraints + : constraints // ignore: cast_nullable_to_non_nullable + as MiraiBoxConstraints?, margin: freezed == margin ? _value.margin : margin // ignore: cast_nullable_to_non_nullable @@ -254,9 +312,11 @@ class _$MiraiContainerImpl implements _MiraiContainer { {this.alignment, this.padding, this.decoration, + this.foregroundDecoration, this.color, this.width, this.height, + this.constraints, this.margin, final Map? child, this.clipBehavior = Clip.none}) @@ -272,12 +332,16 @@ class _$MiraiContainerImpl implements _MiraiContainer { @override final MiraiBoxDecoration? decoration; @override + final MiraiBoxDecoration? foregroundDecoration; + @override final String? color; @override final double? width; @override final double? height; @override + final MiraiBoxConstraints? constraints; + @override final MiraiEdgeInsets? margin; final Map? _child; @override @@ -295,7 +359,7 @@ class _$MiraiContainerImpl implements _MiraiContainer { @override String toString() { - return 'MiraiContainer(alignment: $alignment, padding: $padding, decoration: $decoration, color: $color, width: $width, height: $height, margin: $margin, child: $child, clipBehavior: $clipBehavior)'; + return 'MiraiContainer(alignment: $alignment, padding: $padding, decoration: $decoration, foregroundDecoration: $foregroundDecoration, color: $color, width: $width, height: $height, constraints: $constraints, margin: $margin, child: $child, clipBehavior: $clipBehavior)'; } @override @@ -308,9 +372,13 @@ class _$MiraiContainerImpl implements _MiraiContainer { (identical(other.padding, padding) || other.padding == padding) && (identical(other.decoration, decoration) || other.decoration == decoration) && + (identical(other.foregroundDecoration, foregroundDecoration) || + other.foregroundDecoration == foregroundDecoration) && (identical(other.color, color) || other.color == color) && (identical(other.width, width) || other.width == width) && (identical(other.height, height) || other.height == height) && + (identical(other.constraints, constraints) || + other.constraints == constraints) && (identical(other.margin, margin) || other.margin == margin) && const DeepCollectionEquality().equals(other._child, _child) && (identical(other.clipBehavior, clipBehavior) || @@ -324,9 +392,11 @@ class _$MiraiContainerImpl implements _MiraiContainer { alignment, padding, decoration, + foregroundDecoration, color, width, height, + constraints, margin, const DeepCollectionEquality().hash(_child), clipBehavior); @@ -351,9 +421,11 @@ abstract class _MiraiContainer implements MiraiContainer { {final MiraiAlignment? alignment, final MiraiEdgeInsets? padding, final MiraiBoxDecoration? decoration, + final MiraiBoxDecoration? foregroundDecoration, final String? color, final double? width, final double? height, + final MiraiBoxConstraints? constraints, final MiraiEdgeInsets? margin, final Map? child, final Clip clipBehavior}) = _$MiraiContainerImpl; @@ -368,12 +440,16 @@ abstract class _MiraiContainer implements MiraiContainer { @override MiraiBoxDecoration? get decoration; @override + MiraiBoxDecoration? get foregroundDecoration; + @override String? get color; @override double? get width; @override double? get height; @override + MiraiBoxConstraints? get constraints; + @override MiraiEdgeInsets? get margin; @override Map? get child; 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 8ddede8c..b5dc6901 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 @@ -17,9 +17,17 @@ _$MiraiContainerImpl _$$MiraiContainerImplFromJson(Map json) => ? null : MiraiBoxDecoration.fromJson( json['decoration'] as Map), + foregroundDecoration: json['foregroundDecoration'] == null + ? null + : MiraiBoxDecoration.fromJson( + json['foregroundDecoration'] as Map), color: json['color'] as String?, width: (json['width'] as num?)?.toDouble(), height: (json['height'] as num?)?.toDouble(), + constraints: json['constraints'] == null + ? null + : MiraiBoxConstraints.fromJson( + json['constraints'] as Map), margin: json['margin'] == null ? null : MiraiEdgeInsets.fromJson(json['margin']), @@ -34,9 +42,11 @@ Map _$$MiraiContainerImplToJson( 'alignment': _$MiraiAlignmentEnumMap[instance.alignment], 'padding': instance.padding, 'decoration': instance.decoration, + 'foregroundDecoration': instance.foregroundDecoration, 'color': instance.color, 'width': instance.width, 'height': instance.height, + 'constraints': instance.constraints, 'margin': instance.margin, 'child': instance.child, 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, diff --git a/packages/mirai/lib/src/parsers/mirai_container/mirai_container_parser.dart b/packages/mirai/lib/src/parsers/mirai_container/mirai_container_parser.dart index 067b415b..506c2be1 100644 --- a/packages/mirai/lib/src/parsers/mirai_container/mirai_container_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_container/mirai_container_parser.dart @@ -1,11 +1,7 @@ import 'package:flutter/cupertino.dart'; -import 'package:mirai/src/framework/framework.dart'; -import 'package:mirai/src/parsers/mirai_box_decoration/mirai_box_decoration.dart'; -import 'package:mirai/src/parsers/mirai_container/mirai_container.dart'; -import 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart'; -import 'package:mirai/src/utils/color_utils.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/parsers/mirai_box_constraints/mirai_box_constraints.dart'; import 'package:mirai/src/utils/widget_type.dart'; -import 'package:mirai_framework/mirai_framework.dart'; class MiraiContainerParser extends MiraiParser { const MiraiContainerParser(); @@ -21,15 +17,15 @@ class MiraiContainerParser extends MiraiParser { Widget parse(BuildContext context, MiraiContainer model) { return Container( alignment: model.alignment?.value, - padding: model.padding.parse, - decoration: model.color == null - ? model.decoration.parse(context) - : model.decoration.parse(context)?.copyWith( - color: model.color.toColor(context), - ), + padding: model.padding?.parse, + color: model.color.toColor(context), + decoration: model.decoration?.parse(context), + foregroundDecoration: model.foregroundDecoration?.parse(context), width: model.width, height: model.height, - margin: model.margin.parse, + constraints: model.constraints?.parse, + margin: model.margin?.parse, + clipBehavior: model.clipBehavior, child: Mirai.fromJson(model.child, context), ); } diff --git a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.dart b/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.dart deleted file mode 100644 index b58dafb3..00000000 --- a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:io'; -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:mirai/src/parsers/parsers.dart'; - -part 'mirai_container_image.freezed.dart'; -part 'mirai_container_image.g.dart'; - -enum MiraiContainerImageType { file, network, asset } - -@freezed -class MiraiContainerImage with _$MiraiContainerImage { - const factory MiraiContainerImage({ - required String src, - @Default(MiraiAlignment.center) MiraiAlignment alignment, - @Default(MiraiContainerImageType.network) MiraiContainerImageType imageType, - BoxFit? fit, - }) = _MiraiContainerImage; - - factory MiraiContainerImage.fromJson(Map json) => - _$MiraiContainerImageFromJson(json); -} - -extension MiraiContainerImageParser on MiraiContainerImage? { - DecorationImage? get parse { - if (this?.src == null) return null; - DecorationImage? networkImage() => DecorationImage( - image: NetworkImage( - this?.src ?? '', - ), - alignment: this?.alignment.value ?? Alignment.center, - fit: this?.fit, - ); - - DecorationImage? fileImage() => DecorationImage( - image: FileImage( - File(this?.src ?? ''), - ), - alignment: this?.alignment.value ?? Alignment.center, - fit: this?.fit, - ); - - DecorationImage? assetImage() => DecorationImage( - image: AssetImage( - this?.src ?? '', - ), - alignment: this?.alignment.value ?? Alignment.center, - fit: this?.fit, - ); - - switch (this?.imageType) { - case MiraiContainerImageType.network: - return networkImage(); - case MiraiContainerImageType.file: - return fileImage(); - case MiraiContainerImageType.asset: - return assetImage(); - default: - return null; - } - } -} diff --git a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.freezed.dart b/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.freezed.dart deleted file mode 100644 index 30ae184f..00000000 --- a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.freezed.dart +++ /dev/null @@ -1,220 +0,0 @@ -// 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_container_image.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'); - -MiraiContainerImage _$MiraiContainerImageFromJson(Map json) { - return _MiraiContainerImage.fromJson(json); -} - -/// @nodoc -mixin _$MiraiContainerImage { - String get src => throw _privateConstructorUsedError; - MiraiAlignment get alignment => throw _privateConstructorUsedError; - MiraiContainerImageType get imageType => throw _privateConstructorUsedError; - BoxFit? get fit => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $MiraiContainerImageCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MiraiContainerImageCopyWith<$Res> { - factory $MiraiContainerImageCopyWith( - MiraiContainerImage value, $Res Function(MiraiContainerImage) then) = - _$MiraiContainerImageCopyWithImpl<$Res, MiraiContainerImage>; - @useResult - $Res call( - {String src, - MiraiAlignment alignment, - MiraiContainerImageType imageType, - BoxFit? fit}); -} - -/// @nodoc -class _$MiraiContainerImageCopyWithImpl<$Res, $Val extends MiraiContainerImage> - implements $MiraiContainerImageCopyWith<$Res> { - _$MiraiContainerImageCopyWithImpl(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? src = null, - Object? alignment = null, - Object? imageType = null, - Object? fit = freezed, - }) { - return _then(_value.copyWith( - src: null == src - ? _value.src - : src // ignore: cast_nullable_to_non_nullable - as String, - alignment: null == alignment - ? _value.alignment - : alignment // ignore: cast_nullable_to_non_nullable - as MiraiAlignment, - imageType: null == imageType - ? _value.imageType - : imageType // ignore: cast_nullable_to_non_nullable - as MiraiContainerImageType, - fit: freezed == fit - ? _value.fit - : fit // ignore: cast_nullable_to_non_nullable - as BoxFit?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MiraiContainerImageImplCopyWith<$Res> - implements $MiraiContainerImageCopyWith<$Res> { - factory _$$MiraiContainerImageImplCopyWith(_$MiraiContainerImageImpl value, - $Res Function(_$MiraiContainerImageImpl) then) = - __$$MiraiContainerImageImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String src, - MiraiAlignment alignment, - MiraiContainerImageType imageType, - BoxFit? fit}); -} - -/// @nodoc -class __$$MiraiContainerImageImplCopyWithImpl<$Res> - extends _$MiraiContainerImageCopyWithImpl<$Res, _$MiraiContainerImageImpl> - implements _$$MiraiContainerImageImplCopyWith<$Res> { - __$$MiraiContainerImageImplCopyWithImpl(_$MiraiContainerImageImpl _value, - $Res Function(_$MiraiContainerImageImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? src = null, - Object? alignment = null, - Object? imageType = null, - Object? fit = freezed, - }) { - return _then(_$MiraiContainerImageImpl( - src: null == src - ? _value.src - : src // ignore: cast_nullable_to_non_nullable - as String, - alignment: null == alignment - ? _value.alignment - : alignment // ignore: cast_nullable_to_non_nullable - as MiraiAlignment, - imageType: null == imageType - ? _value.imageType - : imageType // ignore: cast_nullable_to_non_nullable - as MiraiContainerImageType, - fit: freezed == fit - ? _value.fit - : fit // ignore: cast_nullable_to_non_nullable - as BoxFit?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MiraiContainerImageImpl implements _MiraiContainerImage { - const _$MiraiContainerImageImpl( - {required this.src, - this.alignment = MiraiAlignment.center, - this.imageType = MiraiContainerImageType.network, - this.fit}); - - factory _$MiraiContainerImageImpl.fromJson(Map json) => - _$$MiraiContainerImageImplFromJson(json); - - @override - final String src; - @override - @JsonKey() - final MiraiAlignment alignment; - @override - @JsonKey() - final MiraiContainerImageType imageType; - @override - final BoxFit? fit; - - @override - String toString() { - return 'MiraiContainerImage(src: $src, alignment: $alignment, imageType: $imageType, fit: $fit)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MiraiContainerImageImpl && - (identical(other.src, src) || other.src == src) && - (identical(other.alignment, alignment) || - other.alignment == alignment) && - (identical(other.imageType, imageType) || - other.imageType == imageType) && - (identical(other.fit, fit) || other.fit == fit)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, src, alignment, imageType, fit); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$MiraiContainerImageImplCopyWith<_$MiraiContainerImageImpl> get copyWith => - __$$MiraiContainerImageImplCopyWithImpl<_$MiraiContainerImageImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$MiraiContainerImageImplToJson( - this, - ); - } -} - -abstract class _MiraiContainerImage implements MiraiContainerImage { - const factory _MiraiContainerImage( - {required final String src, - final MiraiAlignment alignment, - final MiraiContainerImageType imageType, - final BoxFit? fit}) = _$MiraiContainerImageImpl; - - factory _MiraiContainerImage.fromJson(Map json) = - _$MiraiContainerImageImpl.fromJson; - - @override - String get src; - @override - MiraiAlignment get alignment; - @override - MiraiContainerImageType get imageType; - @override - BoxFit? get fit; - @override - @JsonKey(ignore: true) - _$$MiraiContainerImageImplCopyWith<_$MiraiContainerImageImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.g.dart b/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.g.dart deleted file mode 100644 index 5efdedec..00000000 --- a/packages/mirai/lib/src/parsers/mirai_container_image/mirai_container_image.g.dart +++ /dev/null @@ -1,57 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'mirai_container_image.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$MiraiContainerImageImpl _$$MiraiContainerImageImplFromJson( - Map json) => - _$MiraiContainerImageImpl( - src: json['src'] as String, - alignment: - $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']) ?? - MiraiAlignment.center, - imageType: $enumDecodeNullable( - _$MiraiContainerImageTypeEnumMap, json['imageType']) ?? - MiraiContainerImageType.network, - fit: $enumDecodeNullable(_$BoxFitEnumMap, json['fit']), - ); - -Map _$$MiraiContainerImageImplToJson( - _$MiraiContainerImageImpl instance) => - { - 'src': instance.src, - 'alignment': _$MiraiAlignmentEnumMap[instance.alignment]!, - 'imageType': _$MiraiContainerImageTypeEnumMap[instance.imageType]!, - 'fit': _$BoxFitEnumMap[instance.fit], - }; - -const _$MiraiAlignmentEnumMap = { - MiraiAlignment.topLeft: 'topLeft', - MiraiAlignment.topCenter: 'topCenter', - MiraiAlignment.topRight: 'topRight', - MiraiAlignment.centerLeft: 'centerLeft', - MiraiAlignment.center: 'center', - MiraiAlignment.centerRight: 'centerRight', - MiraiAlignment.bottomLeft: 'bottomLeft', - MiraiAlignment.bottomCenter: 'bottomCenter', - MiraiAlignment.bottomRight: 'bottomRight', -}; - -const _$MiraiContainerImageTypeEnumMap = { - MiraiContainerImageType.file: 'file', - MiraiContainerImageType.network: 'network', - MiraiContainerImageType.asset: 'asset', -}; - -const _$BoxFitEnumMap = { - BoxFit.fill: 'fill', - BoxFit.contain: 'contain', - BoxFit.cover: 'cover', - BoxFit.fitWidth: 'fitWidth', - BoxFit.fitHeight: 'fitHeight', - BoxFit.none: 'none', - BoxFit.scaleDown: 'scaleDown', -}; diff --git a/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.dart b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.dart new file mode 100644 index 00000000..95945e59 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.dart @@ -0,0 +1,68 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/parsers/mirai_rect/mirai_rect.dart'; + +part 'mirai_decoration_image.freezed.dart'; +part 'mirai_decoration_image.g.dart'; + +enum MiraiDecorationImageType { file, network, asset } + +@freezed +class MiraiDecorationImage with _$MiraiDecorationImage { + const factory MiraiDecorationImage({ + required String src, + BoxFit? fit, + @Default(MiraiDecorationImageType.network) + MiraiDecorationImageType imageType, + @Default(MiraiAlignment.center) MiraiAlignment alignment, + MiraiRect? centerSlice, + @Default(ImageRepeat.noRepeat) ImageRepeat repeat, + @Default(false) bool matchTextDirection, + @Default(1.0) double scale, + @Default(1.0) double opacity, + @Default(FilterQuality.low) FilterQuality filterQuality, + @Default(false) bool invertColors, + @Default(false) bool isAntiAlias, + }) = _MiraiDecorationImage; + + factory MiraiDecorationImage.fromJson(Map json) => + _$MiraiDecorationImageFromJson(json); +} + +extension MiraiDecorationImageParser on MiraiDecorationImage? { + DecorationImage? get parse { + if (this?.src == null) return null; + + late ImageProvider image; + switch (this?.imageType) { + case MiraiDecorationImageType.network: + image = NetworkImage(this?.src ?? ''); + break; + case MiraiDecorationImageType.file: + image = FileImage(File(this?.src ?? '')); + break; + case MiraiDecorationImageType.asset: + image = AssetImage(this?.src ?? ''); + break; + default: + return null; + } + + return DecorationImage( + image: image, + fit: this?.fit, + alignment: this?.alignment.value ?? Alignment.center, + centerSlice: this?.centerSlice?.parse, + repeat: this?.repeat ?? ImageRepeat.noRepeat, + matchTextDirection: this?.matchTextDirection ?? false, + scale: this?.scale ?? 1.0, + opacity: this?.opacity ?? 1.0, + filterQuality: this?.filterQuality ?? FilterQuality.low, + invertColors: this?.invertColors ?? false, + isAntiAlias: this?.isAntiAlias ?? false, + ); + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.freezed.dart b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.freezed.dart new file mode 100644 index 00000000..c3b345a0 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.freezed.dart @@ -0,0 +1,424 @@ +// 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_decoration_image.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'); + +MiraiDecorationImage _$MiraiDecorationImageFromJson(Map json) { + return _MiraiDecorationImage.fromJson(json); +} + +/// @nodoc +mixin _$MiraiDecorationImage { + String get src => throw _privateConstructorUsedError; + BoxFit? get fit => throw _privateConstructorUsedError; + MiraiDecorationImageType get imageType => throw _privateConstructorUsedError; + MiraiAlignment get alignment => throw _privateConstructorUsedError; + MiraiRect? get centerSlice => throw _privateConstructorUsedError; + ImageRepeat get repeat => throw _privateConstructorUsedError; + bool get matchTextDirection => throw _privateConstructorUsedError; + double get scale => throw _privateConstructorUsedError; + double get opacity => throw _privateConstructorUsedError; + FilterQuality get filterQuality => throw _privateConstructorUsedError; + bool get invertColors => throw _privateConstructorUsedError; + bool get isAntiAlias => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiDecorationImageCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiDecorationImageCopyWith<$Res> { + factory $MiraiDecorationImageCopyWith(MiraiDecorationImage value, + $Res Function(MiraiDecorationImage) then) = + _$MiraiDecorationImageCopyWithImpl<$Res, MiraiDecorationImage>; + @useResult + $Res call( + {String src, + BoxFit? fit, + MiraiDecorationImageType imageType, + MiraiAlignment alignment, + MiraiRect? centerSlice, + ImageRepeat repeat, + bool matchTextDirection, + double scale, + double opacity, + FilterQuality filterQuality, + bool invertColors, + bool isAntiAlias}); + + $MiraiRectCopyWith<$Res>? get centerSlice; +} + +/// @nodoc +class _$MiraiDecorationImageCopyWithImpl<$Res, + $Val extends MiraiDecorationImage> + implements $MiraiDecorationImageCopyWith<$Res> { + _$MiraiDecorationImageCopyWithImpl(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? src = null, + Object? fit = freezed, + Object? imageType = null, + Object? alignment = null, + Object? centerSlice = freezed, + Object? repeat = null, + Object? matchTextDirection = null, + Object? scale = null, + Object? opacity = null, + Object? filterQuality = null, + Object? invertColors = null, + Object? isAntiAlias = null, + }) { + return _then(_value.copyWith( + src: null == src + ? _value.src + : src // ignore: cast_nullable_to_non_nullable + as String, + fit: freezed == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as BoxFit?, + imageType: null == imageType + ? _value.imageType + : imageType // ignore: cast_nullable_to_non_nullable + as MiraiDecorationImageType, + alignment: null == alignment + ? _value.alignment + : alignment // ignore: cast_nullable_to_non_nullable + as MiraiAlignment, + centerSlice: freezed == centerSlice + ? _value.centerSlice + : centerSlice // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + repeat: null == repeat + ? _value.repeat + : repeat // ignore: cast_nullable_to_non_nullable + as ImageRepeat, + matchTextDirection: null == matchTextDirection + ? _value.matchTextDirection + : matchTextDirection // ignore: cast_nullable_to_non_nullable + as bool, + scale: null == scale + ? _value.scale + : scale // ignore: cast_nullable_to_non_nullable + as double, + opacity: null == opacity + ? _value.opacity + : opacity // ignore: cast_nullable_to_non_nullable + as double, + filterQuality: null == filterQuality + ? _value.filterQuality + : filterQuality // ignore: cast_nullable_to_non_nullable + as FilterQuality, + invertColors: null == invertColors + ? _value.invertColors + : invertColors // ignore: cast_nullable_to_non_nullable + as bool, + isAntiAlias: null == isAntiAlias + ? _value.isAntiAlias + : isAntiAlias // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiRectCopyWith<$Res>? get centerSlice { + if (_value.centerSlice == null) { + return null; + } + + return $MiraiRectCopyWith<$Res>(_value.centerSlice!, (value) { + return _then(_value.copyWith(centerSlice: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiDecorationImageImplCopyWith<$Res> + implements $MiraiDecorationImageCopyWith<$Res> { + factory _$$MiraiDecorationImageImplCopyWith(_$MiraiDecorationImageImpl value, + $Res Function(_$MiraiDecorationImageImpl) then) = + __$$MiraiDecorationImageImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String src, + BoxFit? fit, + MiraiDecorationImageType imageType, + MiraiAlignment alignment, + MiraiRect? centerSlice, + ImageRepeat repeat, + bool matchTextDirection, + double scale, + double opacity, + FilterQuality filterQuality, + bool invertColors, + bool isAntiAlias}); + + @override + $MiraiRectCopyWith<$Res>? get centerSlice; +} + +/// @nodoc +class __$$MiraiDecorationImageImplCopyWithImpl<$Res> + extends _$MiraiDecorationImageCopyWithImpl<$Res, _$MiraiDecorationImageImpl> + implements _$$MiraiDecorationImageImplCopyWith<$Res> { + __$$MiraiDecorationImageImplCopyWithImpl(_$MiraiDecorationImageImpl _value, + $Res Function(_$MiraiDecorationImageImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? src = null, + Object? fit = freezed, + Object? imageType = null, + Object? alignment = null, + Object? centerSlice = freezed, + Object? repeat = null, + Object? matchTextDirection = null, + Object? scale = null, + Object? opacity = null, + Object? filterQuality = null, + Object? invertColors = null, + Object? isAntiAlias = null, + }) { + return _then(_$MiraiDecorationImageImpl( + src: null == src + ? _value.src + : src // ignore: cast_nullable_to_non_nullable + as String, + fit: freezed == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as BoxFit?, + imageType: null == imageType + ? _value.imageType + : imageType // ignore: cast_nullable_to_non_nullable + as MiraiDecorationImageType, + alignment: null == alignment + ? _value.alignment + : alignment // ignore: cast_nullable_to_non_nullable + as MiraiAlignment, + centerSlice: freezed == centerSlice + ? _value.centerSlice + : centerSlice // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + repeat: null == repeat + ? _value.repeat + : repeat // ignore: cast_nullable_to_non_nullable + as ImageRepeat, + matchTextDirection: null == matchTextDirection + ? _value.matchTextDirection + : matchTextDirection // ignore: cast_nullable_to_non_nullable + as bool, + scale: null == scale + ? _value.scale + : scale // ignore: cast_nullable_to_non_nullable + as double, + opacity: null == opacity + ? _value.opacity + : opacity // ignore: cast_nullable_to_non_nullable + as double, + filterQuality: null == filterQuality + ? _value.filterQuality + : filterQuality // ignore: cast_nullable_to_non_nullable + as FilterQuality, + invertColors: null == invertColors + ? _value.invertColors + : invertColors // ignore: cast_nullable_to_non_nullable + as bool, + isAntiAlias: null == isAntiAlias + ? _value.isAntiAlias + : isAntiAlias // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiDecorationImageImpl implements _MiraiDecorationImage { + const _$MiraiDecorationImageImpl( + {required this.src, + this.fit, + this.imageType = MiraiDecorationImageType.network, + this.alignment = MiraiAlignment.center, + this.centerSlice, + this.repeat = ImageRepeat.noRepeat, + this.matchTextDirection = false, + this.scale = 1.0, + this.opacity = 1.0, + this.filterQuality = FilterQuality.low, + this.invertColors = false, + this.isAntiAlias = false}); + + factory _$MiraiDecorationImageImpl.fromJson(Map json) => + _$$MiraiDecorationImageImplFromJson(json); + + @override + final String src; + @override + final BoxFit? fit; + @override + @JsonKey() + final MiraiDecorationImageType imageType; + @override + @JsonKey() + final MiraiAlignment alignment; + @override + final MiraiRect? centerSlice; + @override + @JsonKey() + final ImageRepeat repeat; + @override + @JsonKey() + final bool matchTextDirection; + @override + @JsonKey() + final double scale; + @override + @JsonKey() + final double opacity; + @override + @JsonKey() + final FilterQuality filterQuality; + @override + @JsonKey() + final bool invertColors; + @override + @JsonKey() + final bool isAntiAlias; + + @override + String toString() { + return 'MiraiDecorationImage(src: $src, fit: $fit, imageType: $imageType, alignment: $alignment, centerSlice: $centerSlice, repeat: $repeat, matchTextDirection: $matchTextDirection, scale: $scale, opacity: $opacity, filterQuality: $filterQuality, invertColors: $invertColors, isAntiAlias: $isAntiAlias)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiDecorationImageImpl && + (identical(other.src, src) || other.src == src) && + (identical(other.fit, fit) || other.fit == fit) && + (identical(other.imageType, imageType) || + other.imageType == imageType) && + (identical(other.alignment, alignment) || + other.alignment == alignment) && + (identical(other.centerSlice, centerSlice) || + other.centerSlice == centerSlice) && + (identical(other.repeat, repeat) || other.repeat == repeat) && + (identical(other.matchTextDirection, matchTextDirection) || + other.matchTextDirection == matchTextDirection) && + (identical(other.scale, scale) || other.scale == scale) && + (identical(other.opacity, opacity) || other.opacity == opacity) && + (identical(other.filterQuality, filterQuality) || + other.filterQuality == filterQuality) && + (identical(other.invertColors, invertColors) || + other.invertColors == invertColors) && + (identical(other.isAntiAlias, isAntiAlias) || + other.isAntiAlias == isAntiAlias)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + src, + fit, + imageType, + alignment, + centerSlice, + repeat, + matchTextDirection, + scale, + opacity, + filterQuality, + invertColors, + isAntiAlias); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiDecorationImageImplCopyWith<_$MiraiDecorationImageImpl> + get copyWith => + __$$MiraiDecorationImageImplCopyWithImpl<_$MiraiDecorationImageImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiDecorationImageImplToJson( + this, + ); + } +} + +abstract class _MiraiDecorationImage implements MiraiDecorationImage { + const factory _MiraiDecorationImage( + {required final String src, + final BoxFit? fit, + final MiraiDecorationImageType imageType, + final MiraiAlignment alignment, + final MiraiRect? centerSlice, + final ImageRepeat repeat, + final bool matchTextDirection, + final double scale, + final double opacity, + final FilterQuality filterQuality, + final bool invertColors, + final bool isAntiAlias}) = _$MiraiDecorationImageImpl; + + factory _MiraiDecorationImage.fromJson(Map json) = + _$MiraiDecorationImageImpl.fromJson; + + @override + String get src; + @override + BoxFit? get fit; + @override + MiraiDecorationImageType get imageType; + @override + MiraiAlignment get alignment; + @override + MiraiRect? get centerSlice; + @override + ImageRepeat get repeat; + @override + bool get matchTextDirection; + @override + double get scale; + @override + double get opacity; + @override + FilterQuality get filterQuality; + @override + bool get invertColors; + @override + bool get isAntiAlias; + @override + @JsonKey(ignore: true) + _$$MiraiDecorationImageImplCopyWith<_$MiraiDecorationImageImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.g.dart b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.g.dart new file mode 100644 index 00000000..9de5e79a --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_decoration_image/mirai_decoration_image.g.dart @@ -0,0 +1,92 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_decoration_image.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiDecorationImageImpl _$$MiraiDecorationImageImplFromJson( + Map json) => + _$MiraiDecorationImageImpl( + src: json['src'] as String, + fit: $enumDecodeNullable(_$BoxFitEnumMap, json['fit']), + imageType: $enumDecodeNullable( + _$MiraiDecorationImageTypeEnumMap, json['imageType']) ?? + MiraiDecorationImageType.network, + alignment: + $enumDecodeNullable(_$MiraiAlignmentEnumMap, json['alignment']) ?? + MiraiAlignment.center, + centerSlice: json['centerSlice'] == null + ? null + : MiraiRect.fromJson(json['centerSlice'] as Map), + repeat: $enumDecodeNullable(_$ImageRepeatEnumMap, json['repeat']) ?? + ImageRepeat.noRepeat, + matchTextDirection: json['matchTextDirection'] as bool? ?? false, + scale: (json['scale'] as num?)?.toDouble() ?? 1.0, + opacity: (json['opacity'] as num?)?.toDouble() ?? 1.0, + filterQuality: + $enumDecodeNullable(_$FilterQualityEnumMap, json['filterQuality']) ?? + FilterQuality.low, + invertColors: json['invertColors'] as bool? ?? false, + isAntiAlias: json['isAntiAlias'] as bool? ?? false, + ); + +Map _$$MiraiDecorationImageImplToJson( + _$MiraiDecorationImageImpl instance) => + { + 'src': instance.src, + 'fit': _$BoxFitEnumMap[instance.fit], + 'imageType': _$MiraiDecorationImageTypeEnumMap[instance.imageType]!, + 'alignment': _$MiraiAlignmentEnumMap[instance.alignment]!, + 'centerSlice': instance.centerSlice, + 'repeat': _$ImageRepeatEnumMap[instance.repeat]!, + 'matchTextDirection': instance.matchTextDirection, + 'scale': instance.scale, + 'opacity': instance.opacity, + 'filterQuality': _$FilterQualityEnumMap[instance.filterQuality]!, + 'invertColors': instance.invertColors, + 'isAntiAlias': instance.isAntiAlias, + }; + +const _$BoxFitEnumMap = { + BoxFit.fill: 'fill', + BoxFit.contain: 'contain', + BoxFit.cover: 'cover', + BoxFit.fitWidth: 'fitWidth', + BoxFit.fitHeight: 'fitHeight', + BoxFit.none: 'none', + BoxFit.scaleDown: 'scaleDown', +}; + +const _$MiraiDecorationImageTypeEnumMap = { + MiraiDecorationImageType.file: 'file', + MiraiDecorationImageType.network: 'network', + MiraiDecorationImageType.asset: 'asset', +}; + +const _$MiraiAlignmentEnumMap = { + MiraiAlignment.topLeft: 'topLeft', + MiraiAlignment.topCenter: 'topCenter', + MiraiAlignment.topRight: 'topRight', + MiraiAlignment.centerLeft: 'centerLeft', + MiraiAlignment.center: 'center', + MiraiAlignment.centerRight: 'centerRight', + MiraiAlignment.bottomLeft: 'bottomLeft', + MiraiAlignment.bottomCenter: 'bottomCenter', + MiraiAlignment.bottomRight: 'bottomRight', +}; + +const _$ImageRepeatEnumMap = { + ImageRepeat.repeat: 'repeat', + ImageRepeat.repeatX: 'repeatX', + ImageRepeat.repeatY: 'repeatY', + ImageRepeat.noRepeat: 'noRepeat', +}; + +const _$FilterQualityEnumMap = { + FilterQuality.none: 'none', + FilterQuality.low: 'low', + FilterQuality.medium: 'medium', + FilterQuality.high: 'high', +}; diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index c4c478b5..3c6dda43 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -24,7 +24,6 @@ export 'package:mirai/src/parsers/mirai_chip/mirai_chip.dart'; export 'package:mirai/src/parsers/mirai_circle_avatar/mirai_circle_avatar.dart'; export 'package:mirai/src/parsers/mirai_column/mirai_column.dart'; export 'package:mirai/src/parsers/mirai_container/mirai_container.dart'; -export 'package:mirai/src/parsers/mirai_container_image/mirai_container_image.dart'; export 'package:mirai/src/parsers/mirai_default_bottom_navigation_controller/mirai_default_bottom_navigation_controller.dart'; export 'package:mirai/src/parsers/mirai_default_tab_controller/mirai_default_tab_controller.dart'; export 'package:mirai/src/parsers/mirai_dialog_theme/mirai_dialog_theme.dart'; From 6274a8e963dfe4bbc071c3d26f26c1750f620db2 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Sun, 3 Mar 2024 01:22:57 +0400 Subject: [PATCH 23/24] Added a new way to redefine how we declare BorderRadius --- .../assets/json/text_field_example.json | 7 +--- .../mirai_border_radius.dart | 33 +++++++++++++++++-- .../mirai_box_decoration.g.dart | 3 +- .../mirai_input_border.g.dart | 3 +- .../mirai_rounded_rectangle_border.g.dart | 3 +- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/examples/mirai_gallery/assets/json/text_field_example.json b/examples/mirai_gallery/assets/json/text_field_example.json index e96fdd70..37d6eea0 100644 --- a/examples/mirai_gallery/assets/json/text_field_example.json +++ b/examples/mirai_gallery/assets/json/text_field_example.json @@ -246,12 +246,7 @@ "labelText": "Gradient TextField", "border": { "type": "outlineInputBorder", - "borderRadius": { - "topLeft": 8, - "topRight": 8, - "bottomLeft": 8, - "bottomRight": 8 - }, + "borderRadius": 80, "gradient": { "colors": [ "#FF0000", diff --git a/packages/mirai/lib/src/parsers/mirai_border_radius/mirai_border_radius.dart b/packages/mirai/lib/src/parsers/mirai_border_radius/mirai_border_radius.dart index fde28f83..47fbfd18 100644 --- a/packages/mirai/lib/src/parsers/mirai_border_radius/mirai_border_radius.dart +++ b/packages/mirai/lib/src/parsers/mirai_border_radius/mirai_border_radius.dart @@ -13,8 +13,37 @@ class MiraiBorderRadius with _$MiraiBorderRadius { @Default(0.0) double bottomRight, }) = _MiraiBorder; - factory MiraiBorderRadius.fromJson(Map json) => - _$MiraiBorderRadiusFromJson(json); + factory MiraiBorderRadius.fromJson(dynamic json) => _fromJson(json); + + static MiraiBorderRadius _fromJson(dynamic json) { + Map resultantJson; + + if (json is num) { + resultantJson = { + "topLeft": json, + "topRight": json, + "bottomLeft": json, + "bottomRight": 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 = { + "topLeft": json[0], + "topRight": json[1], + "bottomLeft": json[2], + "bottomRight": json[3] + }; + } else if (json is Map) { + resultantJson = json; + } else { + throw ArgumentError('Invalid input format for MiraiEdgeInsets'); + } + + return _$MiraiBorderRadiusFromJson(resultantJson); + } } extension MiraiBorderRadiusParser on MiraiBorderRadius? { diff --git a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart index e351d611..3aaa751d 100644 --- a/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_box_decoration/mirai_box_decoration.g.dart @@ -24,8 +24,7 @@ _$MiraiBoxDecorationImpl _$$MiraiBoxDecorationImplFromJson( : MiraiBorder.fromJson(json['border'] as Map), borderRadius: json['borderRadius'] == null ? null - : MiraiBorderRadius.fromJson( - json['borderRadius'] as Map), + : MiraiBorderRadius.fromJson(json['borderRadius']), image: json['image'] == null ? null : MiraiDecorationImage.fromJson( diff --git a/packages/mirai/lib/src/parsers/mirai_input_border/mirai_input_border.g.dart b/packages/mirai/lib/src/parsers/mirai_input_border/mirai_input_border.g.dart index 4936236a..4e16d044 100644 --- a/packages/mirai/lib/src/parsers/mirai_input_border/mirai_input_border.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_input_border/mirai_input_border.g.dart @@ -13,8 +13,7 @@ _$MiraiInputBorderImpl _$$MiraiInputBorderImplFromJson( MiraiInputBorderType.underlineInputBorder, borderRadius: json['borderRadius'] == null ? null - : MiraiBorderRadius.fromJson( - json['borderRadius'] as Map), + : MiraiBorderRadius.fromJson(json['borderRadius']), gapPadding: (json['gapPadding'] as num?)?.toDouble() ?? 4.0, width: (json['width'] as num?)?.toDouble() ?? 0.0, color: json['color'] as String?, diff --git a/packages/mirai/lib/src/parsers/mirai_rounded_rectangle_border/mirai_rounded_rectangle_border.g.dart b/packages/mirai/lib/src/parsers/mirai_rounded_rectangle_border/mirai_rounded_rectangle_border.g.dart index fe142de0..531ee33b 100644 --- a/packages/mirai/lib/src/parsers/mirai_rounded_rectangle_border/mirai_rounded_rectangle_border.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_rounded_rectangle_border/mirai_rounded_rectangle_border.g.dart @@ -14,8 +14,7 @@ _$MiraiRoundedRectangleBorderImpl _$$MiraiRoundedRectangleBorderImplFromJson( : MiraiBorderSide.fromJson(json['side'] as Map), borderRadius: json['borderRadius'] == null ? null - : MiraiBorderRadius.fromJson( - json['borderRadius'] as Map), + : MiraiBorderRadius.fromJson(json['borderRadius']), ); Map _$$MiraiRoundedRectangleBorderImplToJson( From 2e7528724547fac907423953eece0be319ed37e7 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Tue, 5 Mar 2024 14:48:41 +0400 Subject: [PATCH 24/24] Update Mirai to v0.7 --- packages/mirai/CHANGELOG.md | 11 +++++++++++ packages/mirai/pubspec.yaml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/mirai/CHANGELOG.md b/packages/mirai/CHANGELOG.md index 137f8e89..8850d994 100644 --- a/packages/mirai/CHANGELOG.md +++ b/packages/mirai/CHANGELOG.md @@ -1,3 +1,14 @@ +## 0.7.0 + +* Added support for new widgets: CircleAvatar, GridView, Chip, Wrap & FilledButton +* Rename scrollView to SingleChildScrollView +* Added defaultBottomNavigationController & bottomNavigationView +* A new and better way to define Mirai Network Request & Network Result +* Revamp Mirai Form to add form validation, getting form values and submitting Form +* Use app text theme in text styles +* A new way to declare EdgeInsets & BorderRadius +* A lot of enhancement, refactoring and bug fixes + ## 0.6.0 * chore: update readme by @divyanshub024 in https://github.com/Securrency-OSS/mirai/pull/210 diff --git a/packages/mirai/pubspec.yaml b/packages/mirai/pubspec.yaml index c6be04f3..7a9111f6 100644 --- a/packages/mirai/pubspec.yaml +++ b/packages/mirai/pubspec.yaml @@ -1,6 +1,6 @@ name: mirai description: Mirai is a Server-Driven UI (SDUI) library for Flutter. Mirai allows you to build beautiful cross-platform applications with JSON in real time. -version: 0.6.0 +version: 0.7.0 homepage: https://github.com/Securrency-OSS/mirai.git environment: