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';