Skip to content

Commit

Permalink
rect tween extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Khattar committed Jan 8, 2025
1 parent 92b6be7 commit 406e3a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'package:flutter/widgets.dart';
import 'package:mirai/mirai.dart';
import 'package:mirai/src/utils/widget_type.dart';
import 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween_parser.dart';

class MiraiHeroParser extends MiraiParser<MiraiHero> {
const MiraiHeroParser();
final _rectTweenParser = const MiraiRectTweenParser();

@override
String get type => WidgetType.hero.name;
Expand All @@ -18,7 +16,7 @@ class MiraiHeroParser extends MiraiParser<MiraiHero> {
return Hero(
tag: model.tag,
createRectTween: model.createRectTween != null
? (_, __) => _rectTweenParser.parse(context, model.createRectTween!)
? (_, __) => model.createRectTween!.parse(context)
: null,
flightShuttleBuilder: model.flightShuttleBuilder != null
? (flightContext, animation, flightDirection, fromHeroContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/mirai_rect/mirai_rect.dart';

export 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween_parser.dart';

part 'mirai_rect_tween.freezed.dart';
part 'mirai_rect_tween.g.dart';

Expand All @@ -17,3 +16,19 @@ class MiraiRectTween with _$MiraiRectTween {
factory MiraiRectTween.fromJson(Map<String, dynamic> 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);
}
}
}

This file was deleted.

0 comments on commit 406e3a2

Please sign in to comment.