-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Mirai parser for hero widget #82
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this amazing PR!! 💯
Please check my suggestions.
@@ -53,5 +53,6 @@ enum WidgetType { | |||
tableCell, | |||
carouselView, | |||
coloredBox, | |||
divider | |||
divider, | |||
hero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the comma ,
at the end.
@@ -0,0 +1,19 @@ | |||
import 'package:flutter/widgets.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this import.
CreateRectTween? parseCreateRectTween(Map<String, dynamic> json) { | ||
final type = json['type'] as String?; | ||
|
||
switch (type) { | ||
case 'materialRectArcTween': | ||
return (Rect? begin, Rect? end) => | ||
MaterialRectArcTween(begin: begin, end: end); | ||
case 'materialRectCenterArcTween': | ||
return (Rect? begin, Rect? end) => | ||
MaterialRectCenterArcTween(begin: begin, end: end); | ||
case 'rectTween': | ||
return (Rect? begin, Rect? end) => RectTween(begin: begin, end: end); | ||
default: | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this into a freezed class like other parsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how can a user pass the begin and end values from JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, understood !!
- I'll create a proper parser for it and move it from utils to the parsers folder
- just saw the repo has a parser already made for Rect (mirai_rect.dart) I'll use that to implement this functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, Thank you so much!! 🙌🏻
hey, lemme know if there are any more changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Yash-Khattar,
Thanks for the previous changes. Here is one last change suggestion. Please check it out.
import 'package:flutter/material.dart'; | ||
import 'package:mirai/src/parsers/mirai_rect_tween/mirai_rect_tween.dart'; | ||
import 'package:mirai/src/parsers/mirai_rect/mirai_rect.dart'; | ||
|
||
class MiraiRectTweenParser { | ||
const MiraiRectTweenParser(); | ||
|
||
MiraiRectTween getModel(Map<String, dynamic> json) => | ||
MiraiRectTween.fromJson(json); | ||
|
||
RectTween parse(BuildContext context, MiraiRectTween model) { | ||
final begin = model.begin?.parse; | ||
final end = model.end?.parse; | ||
|
||
switch (model.type) { | ||
case 'materialRectArcTween': | ||
return MaterialRectArcTween(begin: begin, end: end); | ||
case 'materialRectCenterArcTween': | ||
return MaterialRectCenterArcTween(begin: begin, end: end); | ||
default: | ||
return RectTween(begin: begin, end: end); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this as an extension
method in mirai_rect_tweetn.dart
. Just how it's done in mirai dialog theme
This makes it easier to use MiraiRectTween just by calling model.rectTween.parse
. Also we can avoid the getModel
method as it's not used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for such a great PR @Yash-Khattar 🎉
thanks a lot, @divyanshub024 !! |
Added Hero Animation support
Related Issues
close #16
Type of Change
Demo video of the changes
screen-capture.webm