Skip to content
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

Refactor code #2957

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.1"
flutter-version: "3.13.9"
channel: "stable"
- run: flutter pub get
#- run: flutter analyze
Expand Down
159 changes: 36 additions & 123 deletions lib/get_animations/animations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ typedef OffsetBuilder = Offset Function(BuildContext, double);

class FadeInAnimation extends OpacityAnimation {
FadeInAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, super.key,
super.onComplete,
super.begin = 0,
super.end = 1,
Expand All @@ -22,10 +19,7 @@ class FadeInAnimation extends OpacityAnimation {

class FadeOutAnimation extends OpacityAnimation {
FadeOutAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, super.key,
super.onComplete,
super.begin = 1,
super.end = 0,
Expand All @@ -35,37 +29,25 @@ class FadeOutAnimation extends OpacityAnimation {

class OpacityAnimation extends GetAnimatedBuilder<double> {
OpacityAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.onComplete,
required double begin,
required double end,
required super.idleValue,
required super.duration, required super.delay, required super.child, required super.onComplete, required final double begin, required final double end, required super.idleValue, super.key,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to do this? it is not like dart lints.

}) : super(
tween: Tween<double>(begin: begin, end: end),
builder: (context, value, child) {
builder: (final context, final value, final child) {
return Opacity(
opacity: value,
child: child!,
child: child,
);
},
);
}

class RotateAnimation extends GetAnimatedBuilder<double> {
RotateAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform.rotate(
builder: (final context, final value, final child) => Transform.rotate(
angle: value,
child: child,
),
Expand All @@ -75,16 +57,11 @@ class RotateAnimation extends GetAnimatedBuilder<double> {

class ScaleAnimation extends GetAnimatedBuilder<double> {
ScaleAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform.scale(
builder: (final context, final value, final child) => Transform.scale(
scale: value,
child: child,
),
Expand Down Expand Up @@ -113,17 +90,12 @@ class ScaleAnimation extends GetAnimatedBuilder<double> {

class BounceAnimation extends GetAnimatedBuilder<double> {
BounceAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
super.curve = Curves.bounceOut,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform.scale(
builder: (final context, final value, final child) => Transform.scale(
scale: 1 + value.abs(),
child: child,
),
Expand All @@ -133,14 +105,11 @@ class BounceAnimation extends GetAnimatedBuilder<double> {

class SpinAnimation extends GetAnimatedBuilder<double> {
SpinAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, super.key,
super.onComplete,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform.rotate(
builder: (final context, final value, final child) => Transform.rotate(
angle: value * pi / 180.0,
child: child,
),
Expand All @@ -150,16 +119,11 @@ class SpinAnimation extends GetAnimatedBuilder<double> {

class SizeAnimation extends GetAnimatedBuilder<double> {
SizeAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
super.idleValue = 0,
required double begin,
required double end,
}) : super(
builder: (context, value, child) => Transform.scale(
builder: (final context, final value, final child) => Transform.scale(
scale: value,
child: child,
),
Expand All @@ -169,16 +133,11 @@ class SizeAnimation extends GetAnimatedBuilder<double> {

class BlurAnimation extends GetAnimatedBuilder<double> {
BlurAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => BackdropFilter(
builder: (final context, final value, final child) => BackdropFilter(
filter: ImageFilter.blur(
sigmaX: value,
sigmaY: value,
Expand All @@ -191,16 +150,11 @@ class BlurAnimation extends GetAnimatedBuilder<double> {

class FlipAnimation extends GetAnimatedBuilder<double> {
FlipAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) {
builder: (final context, final value, final child) {
final radians = value * pi;
return Transform(
transform: Matrix4.rotationY(radians),
Expand All @@ -214,16 +168,11 @@ class FlipAnimation extends GetAnimatedBuilder<double> {

class WaveAnimation extends GetAnimatedBuilder<double> {
WaveAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform(
builder: (final context, final value, final child) => Transform(
transform: Matrix4.translationValues(
0.0,
20.0 * sin(value * pi * 2),
Expand All @@ -237,16 +186,11 @@ class WaveAnimation extends GetAnimatedBuilder<double> {

class WobbleAnimation extends GetAnimatedBuilder<double> {
WobbleAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, super.key,
super.onComplete,
required double begin,
required double end,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform(
builder: (final context, final value, final child) => Transform(
transform: Matrix4.identity()
..setEntry(3, 2, 0.001)
..rotateZ(sin(value * pi * 2) * 0.1),
Expand All @@ -259,81 +203,55 @@ class WobbleAnimation extends GetAnimatedBuilder<double> {

class SlideInLeftAnimation extends SlideAnimation {
SlideInLeftAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required super.begin, required super.end, super.key,
super.onComplete,
required super.begin,
required super.end,
super.idleValue = 0,
}) : super(
offsetBuild: (context, value) =>
offsetBuild: (final context, final value) =>
Offset(value * MediaQuery.of(context).size.width, 0),
);
}

class SlideInRightAnimation extends SlideAnimation {
SlideInRightAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required super.begin, required super.end, super.key,
super.onComplete,
required super.begin,
required super.end,
super.idleValue = 0,
}) : super(
offsetBuild: (context, value) =>
offsetBuild: (final context, final value) =>
Offset((1 - value) * MediaQuery.of(context).size.width, 0),
);
}

class SlideInUpAnimation extends SlideAnimation {
SlideInUpAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required super.begin, required super.end, super.key,
super.onComplete,
required super.begin,
required super.end,
super.idleValue = 0,
}) : super(
offsetBuild: (context, value) =>
offsetBuild: (final context, final value) =>
Offset(0, value * MediaQuery.of(context).size.height),
);
}

class SlideInDownAnimation extends SlideAnimation {
SlideInDownAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required super.begin, required super.end, super.key,
super.onComplete,
required super.begin,
required super.end,
super.idleValue = 0,
}) : super(
offsetBuild: (context, value) =>
offsetBuild: (final context, final value) =>
Offset(0, (1 - value) * MediaQuery.of(context).size.height),
);
}

class SlideAnimation extends GetAnimatedBuilder<double> {
SlideAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required double begin,
required double end,
required OffsetBuilder offsetBuild,
required super.duration, required super.delay, required super.child, required final double begin, required final double end, required final OffsetBuilder offsetBuild, super.key,
super.onComplete,
super.idleValue = 0,
}) : super(
builder: (context, value, child) => Transform.translate(
builder: (final context, final value, final child) => Transform.translate(
offset: offsetBuild(context, value),
child: child,
),
Expand Down Expand Up @@ -362,16 +280,11 @@ class SlideAnimation extends GetAnimatedBuilder<double> {

class ColorAnimation extends GetAnimatedBuilder<Color?> {
ColorAnimation({
super.key,
required super.duration,
required super.delay,
required super.child,
required super.duration, required super.delay, required super.child, required final Color begin, required final Color end, super.key,
super.onComplete,
required Color begin,
required Color end,
Color? idleColor,
final Color? idleColor,
}) : super(
builder: (context, value, child) => ColorFiltered(
builder: (final context, final value, final child) => ColorFiltered(
colorFilter: ColorFilter.mode(
Color.lerp(begin, end, value!.value.toDouble())!,
BlendMode.srcIn,
Expand Down
Loading
Loading