-
Notifications
You must be signed in to change notification settings - Fork 144
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
如何高度自定义SmartDialog动画? #75
Labels
enhancement
New feature or request
Comments
目前动画入口内部没有收敛,动画和一些参数有强耦合关系,例如:alignment,animationTime之类,想了还是可以去实现,新增animationBuilder,将这些参数回调出来,让用户自主实现开始或结束动画
|
dependencies:
flutter_smart_dialog: ^4.5.5+2
SmartDialog.show(
animationTime: const Duration(milliseconds: 3000),
animationBuilder: (
AnimationController controller,
Widget child,
AnimationParam animationParam,
) {
return RotationTransition(
turns: CurvedAnimation(parent: controller, curve: Curves.elasticIn),
child: child,
);
},
builder: (_) {
return Container(
color: Colors.white,
padding: const EdgeInsets.all(30),
child: const Text('custom animation dialog'),
);
},
);
SmartDialog.show(
animationTime: const Duration(milliseconds: 3000),
animationBuilder: (
AnimationController controller,
Widget child,
AnimationParam animationParam,
) {
return CustomAnimation(child: child, animationParam: animationParam);
},
builder: (_) {
return Container(
color: Colors.white,
padding: const EdgeInsets.all(30),
child: const Text('custom animation dialog'),
);
},
);
class CustomAnimation extends StatefulWidget {
const CustomAnimation({
Key? key,
required this.child,
required this.animationParam,
}) : super(key: key);
final Widget child;
final AnimationParam animationParam;
@override
State<CustomAnimation> createState() => _CustomAnimationState();
}
class _CustomAnimationState extends State<CustomAnimation>
with TickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: widget.animationParam.animationTime,
);
widget.animationParam.onForward = () {
_controller.value = 0;
_controller.forward();
};
widget.animationParam.onDismiss = () {
_controller.reverse();
};
super.initState();
}
@override
Widget build(BuildContext context) {
return RotationTransition(
turns: CurvedAnimation(parent: _controller, curve: Curves.elasticIn),
child: widget.child,
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
} |
@xdd666t 好的辛苦了谢谢! |
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SmartAnimationType 只有四种选择。
The text was updated successfully, but these errors were encountered: