diff --git a/examples/mirai_gallery/assets/json/hero_example.json b/examples/mirai_gallery/assets/json/hero_example.json new file mode 100644 index 00000000..cc249cc7 --- /dev/null +++ b/examples/mirai_gallery/assets/json/hero_example.json @@ -0,0 +1,127 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Hero Example" + } + }, + "body": { + "type": "center", + "child": { + "type": "column", + "mainAxisAlignment": "center", + "children": [ + { + "type": "hero", + "tag": "hero-icon", + "createRectTween": { + "type": "materialRectArcTween", + "begin": { + "rectType": "fromCenter", + "center": { + "dx": 120.0, + "dy": 140.0 + }, + "width": 100.0, + "height": 100.0 + }, + "end": { + "rectType": "fromCenter", + "center": { + "dx": 200.0, + "dy": 200.0 + }, + "width": 50.0, + "height": 50.0 + } + }, + "child": { + "type": "icon", + "iconType": "material", + "icon": "flight_takeoff", + "size": 150.0 + } + }, + { + "type": "sizedBox", + "height": 24.0 + }, + { + "type": "textButton", + "child": { + "type": "text", + "data": "Tap to see Hero Animation" + }, + "onPressed": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Flight Details" + } + }, + "body": { + "type": "center", + "child": { + "type": "column", + "mainAxisAlignment": "center", + "children": [ + { + "type": "hero", + "tag": "hero-icon", + "createRectTween": { + "type": "materialRectArcTween", + "begin": { + "rectType": "fromCenter", + "center": { + "dx": 120.0, + "dy": 140.0 + }, + "width": 100.0, + "height": 100.0 + }, + "end": { + "rectType": "fromCenter", + "center": { + "dx": 200.0, + "dy": 200.0 + }, + "width": 50.0, + "height": 50.0 + } + }, + "child": { + "type": "icon", + "iconType": "material", + "icon": "flight_takeoff", + "size": 50.0 + } + }, + { + "type": "sizedBox", + "height": 16.0 + }, + { + "type": "text", + "data": "Flight AB123", + "style": { + "fontSize": 24.0, + "fontWeight": "w500" + } + } + ] + } + } + } + } + } + ] + } + } +} diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index f69a0dd1..1eccbf10 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -1421,6 +1421,40 @@ } } }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "flight_takeoff" + }, + "title": { + "type": "text", + "data": "Mirai Hero", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Hero Widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/hero_example.json" + } + } + }, { "type": "sizedBox", "height": 24.0 diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 01f92f4f..42528a75 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -86,6 +86,7 @@ class Mirai { const MiraiDividerParser(), const MiraiCircularProgressIndicatorParser(), const MiraiLinearProgressIndicatorParser(), + const MiraiHeroParser(), ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.dart b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.dart new file mode 100644 index 00000000..78cf4b14 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.dart @@ -0,0 +1,21 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween.dart'; +export 'package:mirai/src/parsers/mirai_hero/mirai_hero_parser.dart'; + +part 'mirai_hero.freezed.dart'; +part 'mirai_hero.g.dart'; + +@freezed +class MiraiHero with _$MiraiHero { + const factory MiraiHero({ + required Object tag, + required Map child, + MiraiRectTween? createRectTween, + Map? flightShuttleBuilder, + Map? placeholderBuilder, + @Default(false) bool transitionOnUserGestures, + }) = _MiraiHero; + + factory MiraiHero.fromJson(Map json) => + _$MiraiHeroFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.freezed.dart b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.freezed.dart new file mode 100644 index 00000000..769a5a6a --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.freezed.dart @@ -0,0 +1,322 @@ +// 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_hero.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'); + +MiraiHero _$MiraiHeroFromJson(Map json) { + return _MiraiHero.fromJson(json); +} + +/// @nodoc +mixin _$MiraiHero { + Object get tag => throw _privateConstructorUsedError; + Map get child => throw _privateConstructorUsedError; + MiraiRectTween? get createRectTween => throw _privateConstructorUsedError; + Map? get flightShuttleBuilder => + throw _privateConstructorUsedError; + Map? get placeholderBuilder => + throw _privateConstructorUsedError; + bool get transitionOnUserGestures => throw _privateConstructorUsedError; + + /// Serializes this MiraiHero to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $MiraiHeroCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiHeroCopyWith<$Res> { + factory $MiraiHeroCopyWith(MiraiHero value, $Res Function(MiraiHero) then) = + _$MiraiHeroCopyWithImpl<$Res, MiraiHero>; + @useResult + $Res call( + {Object tag, + Map child, + MiraiRectTween? createRectTween, + Map? flightShuttleBuilder, + Map? placeholderBuilder, + bool transitionOnUserGestures}); + + $MiraiRectTweenCopyWith<$Res>? get createRectTween; +} + +/// @nodoc +class _$MiraiHeroCopyWithImpl<$Res, $Val extends MiraiHero> + implements $MiraiHeroCopyWith<$Res> { + _$MiraiHeroCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? tag = null, + Object? child = null, + Object? createRectTween = freezed, + Object? flightShuttleBuilder = freezed, + Object? placeholderBuilder = freezed, + Object? transitionOnUserGestures = null, + }) { + return _then(_value.copyWith( + tag: null == tag ? _value.tag : tag, + child: null == child + ? _value.child + : child // ignore: cast_nullable_to_non_nullable + as Map, + createRectTween: freezed == createRectTween + ? _value.createRectTween + : createRectTween // ignore: cast_nullable_to_non_nullable + as MiraiRectTween?, + flightShuttleBuilder: freezed == flightShuttleBuilder + ? _value.flightShuttleBuilder + : flightShuttleBuilder // ignore: cast_nullable_to_non_nullable + as Map?, + placeholderBuilder: freezed == placeholderBuilder + ? _value.placeholderBuilder + : placeholderBuilder // ignore: cast_nullable_to_non_nullable + as Map?, + transitionOnUserGestures: null == transitionOnUserGestures + ? _value.transitionOnUserGestures + : transitionOnUserGestures // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MiraiRectTweenCopyWith<$Res>? get createRectTween { + if (_value.createRectTween == null) { + return null; + } + + return $MiraiRectTweenCopyWith<$Res>(_value.createRectTween!, (value) { + return _then(_value.copyWith(createRectTween: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiHeroImplCopyWith<$Res> + implements $MiraiHeroCopyWith<$Res> { + factory _$$MiraiHeroImplCopyWith( + _$MiraiHeroImpl value, $Res Function(_$MiraiHeroImpl) then) = + __$$MiraiHeroImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Object tag, + Map child, + MiraiRectTween? createRectTween, + Map? flightShuttleBuilder, + Map? placeholderBuilder, + bool transitionOnUserGestures}); + + @override + $MiraiRectTweenCopyWith<$Res>? get createRectTween; +} + +/// @nodoc +class __$$MiraiHeroImplCopyWithImpl<$Res> + extends _$MiraiHeroCopyWithImpl<$Res, _$MiraiHeroImpl> + implements _$$MiraiHeroImplCopyWith<$Res> { + __$$MiraiHeroImplCopyWithImpl( + _$MiraiHeroImpl _value, $Res Function(_$MiraiHeroImpl) _then) + : super(_value, _then); + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? tag = null, + Object? child = null, + Object? createRectTween = freezed, + Object? flightShuttleBuilder = freezed, + Object? placeholderBuilder = freezed, + Object? transitionOnUserGestures = null, + }) { + return _then(_$MiraiHeroImpl( + tag: null == tag ? _value.tag : tag, + child: null == child + ? _value._child + : child // ignore: cast_nullable_to_non_nullable + as Map, + createRectTween: freezed == createRectTween + ? _value.createRectTween + : createRectTween // ignore: cast_nullable_to_non_nullable + as MiraiRectTween?, + flightShuttleBuilder: freezed == flightShuttleBuilder + ? _value._flightShuttleBuilder + : flightShuttleBuilder // ignore: cast_nullable_to_non_nullable + as Map?, + placeholderBuilder: freezed == placeholderBuilder + ? _value._placeholderBuilder + : placeholderBuilder // ignore: cast_nullable_to_non_nullable + as Map?, + transitionOnUserGestures: null == transitionOnUserGestures + ? _value.transitionOnUserGestures + : transitionOnUserGestures // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiHeroImpl implements _MiraiHero { + const _$MiraiHeroImpl( + {required this.tag, + required final Map child, + this.createRectTween, + final Map? flightShuttleBuilder, + final Map? placeholderBuilder, + this.transitionOnUserGestures = false}) + : _child = child, + _flightShuttleBuilder = flightShuttleBuilder, + _placeholderBuilder = placeholderBuilder; + + factory _$MiraiHeroImpl.fromJson(Map json) => + _$$MiraiHeroImplFromJson(json); + + @override + final Object tag; + final Map _child; + @override + Map get child { + if (_child is EqualUnmodifiableMapView) return _child; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_child); + } + + @override + final MiraiRectTween? createRectTween; + final Map? _flightShuttleBuilder; + @override + Map? get flightShuttleBuilder { + final value = _flightShuttleBuilder; + if (value == null) return null; + if (_flightShuttleBuilder is EqualUnmodifiableMapView) + return _flightShuttleBuilder; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final Map? _placeholderBuilder; + @override + Map? get placeholderBuilder { + final value = _placeholderBuilder; + if (value == null) return null; + if (_placeholderBuilder is EqualUnmodifiableMapView) + return _placeholderBuilder; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey() + final bool transitionOnUserGestures; + + @override + String toString() { + return 'MiraiHero(tag: $tag, child: $child, createRectTween: $createRectTween, flightShuttleBuilder: $flightShuttleBuilder, placeholderBuilder: $placeholderBuilder, transitionOnUserGestures: $transitionOnUserGestures)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiHeroImpl && + const DeepCollectionEquality().equals(other.tag, tag) && + const DeepCollectionEquality().equals(other._child, _child) && + (identical(other.createRectTween, createRectTween) || + other.createRectTween == createRectTween) && + const DeepCollectionEquality() + .equals(other._flightShuttleBuilder, _flightShuttleBuilder) && + const DeepCollectionEquality() + .equals(other._placeholderBuilder, _placeholderBuilder) && + (identical( + other.transitionOnUserGestures, transitionOnUserGestures) || + other.transitionOnUserGestures == transitionOnUserGestures)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(tag), + const DeepCollectionEquality().hash(_child), + createRectTween, + const DeepCollectionEquality().hash(_flightShuttleBuilder), + const DeepCollectionEquality().hash(_placeholderBuilder), + transitionOnUserGestures); + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MiraiHeroImplCopyWith<_$MiraiHeroImpl> get copyWith => + __$$MiraiHeroImplCopyWithImpl<_$MiraiHeroImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiHeroImplToJson( + this, + ); + } +} + +abstract class _MiraiHero implements MiraiHero { + const factory _MiraiHero( + {required final Object tag, + required final Map child, + final MiraiRectTween? createRectTween, + final Map? flightShuttleBuilder, + final Map? placeholderBuilder, + final bool transitionOnUserGestures}) = _$MiraiHeroImpl; + + factory _MiraiHero.fromJson(Map json) = + _$MiraiHeroImpl.fromJson; + + @override + Object get tag; + @override + Map get child; + @override + MiraiRectTween? get createRectTween; + @override + Map? get flightShuttleBuilder; + @override + Map? get placeholderBuilder; + @override + bool get transitionOnUserGestures; + + /// Create a copy of MiraiHero + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$MiraiHeroImplCopyWith<_$MiraiHeroImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.g.dart b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.g.dart new file mode 100644 index 00000000..a6808ac5 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_hero.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiHeroImpl _$$MiraiHeroImplFromJson(Map json) => + _$MiraiHeroImpl( + tag: json['tag'] as Object, + child: json['child'] as Map, + createRectTween: json['createRectTween'] == null + ? null + : MiraiRectTween.fromJson( + json['createRectTween'] as Map), + flightShuttleBuilder: + json['flightShuttleBuilder'] as Map?, + placeholderBuilder: json['placeholderBuilder'] as Map?, + transitionOnUserGestures: + json['transitionOnUserGestures'] as bool? ?? false, + ); + +Map _$$MiraiHeroImplToJson(_$MiraiHeroImpl instance) => + { + 'tag': instance.tag, + 'child': instance.child, + 'createRectTween': instance.createRectTween, + 'flightShuttleBuilder': instance.flightShuttleBuilder, + 'placeholderBuilder': instance.placeholderBuilder, + 'transitionOnUserGestures': instance.transitionOnUserGestures, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero_parser.dart b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero_parser.dart new file mode 100644 index 00000000..deddd895 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_hero/mirai_hero_parser.dart @@ -0,0 +1,39 @@ +import 'package:flutter/widgets.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiHeroParser extends MiraiParser { + const MiraiHeroParser(); + + @override + String get type => WidgetType.hero.name; + + @override + MiraiHero getModel(Map json) => MiraiHero.fromJson(json); + + @override + Widget parse(BuildContext context, MiraiHero model) { + return Hero( + tag: model.tag, + createRectTween: model.createRectTween != null + ? (_, __) => model.createRectTween!.parse(context) + : null, + flightShuttleBuilder: model.flightShuttleBuilder != null + ? (flightContext, animation, flightDirection, fromHeroContext, + toHeroContext) { + final widget = + Mirai.fromJson(model.flightShuttleBuilder!, context); + return widget ?? const SizedBox(); + } + : null, + placeholderBuilder: model.placeholderBuilder != null + ? (context, heroSize, child) { + final widget = Mirai.fromJson(model.placeholderBuilder!, context); + return widget ?? const SizedBox(); + } + : null, + transitionOnUserGestures: model.transitionOnUserGestures, + child: Mirai.fromJson(model.child, context) ?? const SizedBox(), + ); + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.dart b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.dart new file mode 100644 index 00000000..a57ef6df --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/src/parsers/mirai_rect/mirai_rect.dart'; + +part 'mirai_rect_tween.freezed.dart'; +part 'mirai_rect_tween.g.dart'; + +@freezed +class MiraiRectTween with _$MiraiRectTween { + const factory MiraiRectTween({ + required String type, + MiraiRect? begin, + MiraiRect? end, + }) = _MiraiRectTween; + + factory MiraiRectTween.fromJson(Map json) => + _$MiraiRectTweenFromJson(json); +} + +extension MiraiRectTweenParser on MiraiRectTween { + RectTween parse(BuildContext context) { + final begin = this.begin?.parse; + final end = this.end?.parse; + + switch (type) { + case 'materialRectArcTween': + return MaterialRectArcTween(begin: begin, end: end); + case 'materialRectCenterArcTween': + return MaterialRectCenterArcTween(begin: begin, end: end); + default: + return RectTween(begin: begin, end: end); + } + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.freezed.dart b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.freezed.dart new file mode 100644 index 00000000..9979935c --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.freezed.dart @@ -0,0 +1,236 @@ +// 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_rect_tween.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'); + +MiraiRectTween _$MiraiRectTweenFromJson(Map json) { + return _MiraiRectTween.fromJson(json); +} + +/// @nodoc +mixin _$MiraiRectTween { + String get type => throw _privateConstructorUsedError; + MiraiRect? get begin => throw _privateConstructorUsedError; + MiraiRect? get end => throw _privateConstructorUsedError; + + /// Serializes this MiraiRectTween to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $MiraiRectTweenCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiRectTweenCopyWith<$Res> { + factory $MiraiRectTweenCopyWith( + MiraiRectTween value, $Res Function(MiraiRectTween) then) = + _$MiraiRectTweenCopyWithImpl<$Res, MiraiRectTween>; + @useResult + $Res call({String type, MiraiRect? begin, MiraiRect? end}); + + $MiraiRectCopyWith<$Res>? get begin; + $MiraiRectCopyWith<$Res>? get end; +} + +/// @nodoc +class _$MiraiRectTweenCopyWithImpl<$Res, $Val extends MiraiRectTween> + implements $MiraiRectTweenCopyWith<$Res> { + _$MiraiRectTweenCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? begin = freezed, + Object? end = freezed, + }) { + return _then(_value.copyWith( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + begin: freezed == begin + ? _value.begin + : begin // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + end: freezed == end + ? _value.end + : end // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + ) as $Val); + } + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MiraiRectCopyWith<$Res>? get begin { + if (_value.begin == null) { + return null; + } + + return $MiraiRectCopyWith<$Res>(_value.begin!, (value) { + return _then(_value.copyWith(begin: value) as $Val); + }); + } + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MiraiRectCopyWith<$Res>? get end { + if (_value.end == null) { + return null; + } + + return $MiraiRectCopyWith<$Res>(_value.end!, (value) { + return _then(_value.copyWith(end: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiRectTweenImplCopyWith<$Res> + implements $MiraiRectTweenCopyWith<$Res> { + factory _$$MiraiRectTweenImplCopyWith(_$MiraiRectTweenImpl value, + $Res Function(_$MiraiRectTweenImpl) then) = + __$$MiraiRectTweenImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String type, MiraiRect? begin, MiraiRect? end}); + + @override + $MiraiRectCopyWith<$Res>? get begin; + @override + $MiraiRectCopyWith<$Res>? get end; +} + +/// @nodoc +class __$$MiraiRectTweenImplCopyWithImpl<$Res> + extends _$MiraiRectTweenCopyWithImpl<$Res, _$MiraiRectTweenImpl> + implements _$$MiraiRectTweenImplCopyWith<$Res> { + __$$MiraiRectTweenImplCopyWithImpl( + _$MiraiRectTweenImpl _value, $Res Function(_$MiraiRectTweenImpl) _then) + : super(_value, _then); + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? begin = freezed, + Object? end = freezed, + }) { + return _then(_$MiraiRectTweenImpl( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + begin: freezed == begin + ? _value.begin + : begin // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + end: freezed == end + ? _value.end + : end // ignore: cast_nullable_to_non_nullable + as MiraiRect?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiRectTweenImpl implements _MiraiRectTween { + const _$MiraiRectTweenImpl({required this.type, this.begin, this.end}); + + factory _$MiraiRectTweenImpl.fromJson(Map json) => + _$$MiraiRectTweenImplFromJson(json); + + @override + final String type; + @override + final MiraiRect? begin; + @override + final MiraiRect? end; + + @override + String toString() { + return 'MiraiRectTween(type: $type, begin: $begin, end: $end)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiRectTweenImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.begin, begin) || other.begin == begin) && + (identical(other.end, end) || other.end == end)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, type, begin, end); + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MiraiRectTweenImplCopyWith<_$MiraiRectTweenImpl> get copyWith => + __$$MiraiRectTweenImplCopyWithImpl<_$MiraiRectTweenImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiRectTweenImplToJson( + this, + ); + } +} + +abstract class _MiraiRectTween implements MiraiRectTween { + const factory _MiraiRectTween( + {required final String type, + final MiraiRect? begin, + final MiraiRect? end}) = _$MiraiRectTweenImpl; + + factory _MiraiRectTween.fromJson(Map json) = + _$MiraiRectTweenImpl.fromJson; + + @override + String get type; + @override + MiraiRect? get begin; + @override + MiraiRect? get end; + + /// Create a copy of MiraiRectTween + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$MiraiRectTweenImplCopyWith<_$MiraiRectTweenImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.g.dart b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.g.dart new file mode 100644 index 00000000..ff0a202c --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_rect_tween/mirai_rect_tween.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_rect_tween.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiRectTweenImpl _$$MiraiRectTweenImplFromJson(Map json) => + _$MiraiRectTweenImpl( + type: json['type'] as String, + begin: json['begin'] == null + ? null + : MiraiRect.fromJson(json['begin'] as Map), + end: json['end'] == null + ? null + : MiraiRect.fromJson(json['end'] as Map), + ); + +Map _$$MiraiRectTweenImplToJson( + _$MiraiRectTweenImpl instance) => + { + 'type': instance.type, + 'begin': instance.begin, + 'end': instance.end, + }; diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 9f66006a..60a5980b 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -80,3 +80,5 @@ export 'package:mirai/src/parsers/mirai_theme/mirai_theme.dart'; export 'package:mirai/src/parsers/mirai_wrap/mirai_wrap.dart'; export 'package:mirai/src/parsers/mirai_circular_progress_indicator/mirai_circular_progress_indicator.dart'; export 'package:mirai/src/parsers/mirai_linear_progress_indicator/mirai_linear_progress_indicator.dart'; +export 'package:mirai/src/parsers/mirai_hero/mirai_hero.dart'; +export 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index a2564cc9..b10a0bc3 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -55,5 +55,6 @@ enum WidgetType { coloredBox, divider, circularProgressIndicator, - linearProgressIndicator + linearProgressIndicator, + hero, }