|
|
|
@ -4,10 +4,9 @@ import 'package:flutter/material.dart'; |
|
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; |
|
|
|
|
|
|
|
class GlobeAnimation extends StatefulWidget { |
|
|
|
const GlobeAnimation({super.key, required this.child, this.state = true}); |
|
|
|
const GlobeAnimation({super.key, required this.child}); |
|
|
|
|
|
|
|
final Widget child; |
|
|
|
final bool state; |
|
|
|
|
|
|
|
@override |
|
|
|
State<GlobeAnimation> createState() => _GlobeAnimationState(); |
|
|
|
@ -25,55 +24,34 @@ class _GlobeAnimationState extends State<GlobeAnimation> |
|
|
|
super.initState(); |
|
|
|
_controller = AnimationController( |
|
|
|
vsync: this, |
|
|
|
duration: const Duration(seconds: 1), |
|
|
|
reverseDuration: const Duration(seconds: 1), |
|
|
|
duration: const Duration(hours: 1), |
|
|
|
reverseDuration: const Duration(hours: 1), |
|
|
|
); |
|
|
|
_animation = Tween<double>( |
|
|
|
begin: 1, |
|
|
|
end: 1.05, |
|
|
|
).animate(CurvedAnimation(parent: _controller, curve: Curves.linear)); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void didUpdateWidget(covariant GlobeAnimation oldWidget) { |
|
|
|
super.didUpdateWidget(oldWidget); |
|
|
|
if (widget.state) { |
|
|
|
_controller.repeat(reverse: true); |
|
|
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) { |
|
|
|
if (_gradient == null) { |
|
|
|
if (!mounted) return; |
|
|
|
setState(() { |
|
|
|
_gradient = RadialGradient( |
|
|
|
colors: [ |
|
|
|
const Color(0XFFDFCD00), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0.35), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0), |
|
|
|
], |
|
|
|
center: Alignment.center, |
|
|
|
); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
setState(() { |
|
|
|
_gradient = null; |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
_timer?.cancel(); |
|
|
|
_timer = null; |
|
|
|
_controller.stop(); |
|
|
|
if (!mounted) return; |
|
|
|
setState(() { |
|
|
|
_gradient = RadialGradient( |
|
|
|
colors: [ |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0), |
|
|
|
], |
|
|
|
center: Alignment.center, |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
_controller.repeat(reverse: true); |
|
|
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) { |
|
|
|
if (_gradient == null) { |
|
|
|
if (!mounted) return; |
|
|
|
setState(() { |
|
|
|
_gradient = RadialGradient( |
|
|
|
colors: [ |
|
|
|
const Color(0XFFDFCD00), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0.35), |
|
|
|
const Color(0XFFDFCD00).withValues(alpha: 0), |
|
|
|
], |
|
|
|
center: Alignment.center, |
|
|
|
); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
setState(() { |
|
|
|
_gradient = null; |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
|