update animation
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -38,8 +38,8 @@ class MyApp extends StatefulWidget {
|
|||||||
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||||
InitData _initData;
|
InitData _initData;
|
||||||
bool _animCompleted = false;
|
bool _animCompleted = false;
|
||||||
Animation<double> _animation;
|
Animation<double> _animation, _scaleAnimation;
|
||||||
AnimationController _animationController;
|
AnimationController _animationController, _scaleAnimationController;
|
||||||
Animation<Color> _colorAnimation;
|
Animation<Color> _colorAnimation;
|
||||||
int timeOfStartMs;
|
int timeOfStartMs;
|
||||||
|
|
||||||
@@ -70,46 +70,68 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
timeOfStartMs = DateTime.now().millisecondsSinceEpoch;
|
timeOfStartMs = DateTime.now().millisecondsSinceEpoch;
|
||||||
_animationController =
|
|
||||||
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
|
_scaleAnimationController = AnimationController(
|
||||||
_animation = Tween(begin: 0.0, end: 1000.0).animate(
|
vsync: this,
|
||||||
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut));
|
duration: Duration(
|
||||||
_colorAnimation =
|
milliseconds: 500,
|
||||||
ColorTween(begin: Color(0xff005FFF), end: Color(0xff005FFF)).animate(
|
),
|
||||||
CurvedAnimation(
|
);
|
||||||
parent: _animationController, curve: Curves.easeInOut));
|
_scaleAnimation = Tween(
|
||||||
|
begin: 1.0,
|
||||||
|
end: 1.5,
|
||||||
|
).animate(CurvedAnimation(
|
||||||
|
parent: _scaleAnimationController,
|
||||||
|
curve: Curves.easeInOutBack,
|
||||||
|
));
|
||||||
|
|
||||||
|
_animationController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: Duration(
|
||||||
|
milliseconds: 1000,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_animation = Tween(
|
||||||
|
begin: 0.0,
|
||||||
|
end: 1000.0,
|
||||||
|
).animate(CurvedAnimation(
|
||||||
|
parent: _animationController,
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
));
|
||||||
|
_colorAnimation = ColorTween(
|
||||||
|
begin: Color(0xff005FFF),
|
||||||
|
end: Color(0xff005FFF),
|
||||||
|
).animate(CurvedAnimation(
|
||||||
|
parent: _animationController,
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
));
|
||||||
_initConnection().then(
|
_initConnection().then(
|
||||||
(initData) {
|
(initData) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_initData = initData;
|
_initData = initData;
|
||||||
});
|
});
|
||||||
var theme = _initData.preferences.getInt(
|
|
||||||
'theme',
|
|
||||||
defaultValue: 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
||||||
final colorTheme = theme.getValue() == 0
|
|
||||||
? (isDark ? ColorTheme.dark() : ColorTheme.light())
|
|
||||||
: (theme.getValue() == 1 ? ColorTheme.light() : ColorTheme.dark());
|
|
||||||
|
|
||||||
_colorAnimation = ColorTween(
|
_colorAnimation = ColorTween(
|
||||||
begin: Color(0xff005FFF),
|
begin: Color(0xff005FFF),
|
||||||
end: colorTheme.white == ColorTheme.light().white
|
end: Colors.transparent,
|
||||||
? Colors.white
|
).animate(CurvedAnimation(
|
||||||
: Colors.black)
|
parent: _animationController,
|
||||||
.animate(CurvedAnimation(
|
curve: Curves.easeInOut,
|
||||||
parent: _animationController, curve: Curves.easeInOut));
|
));
|
||||||
|
|
||||||
var now = DateTime.now().millisecondsSinceEpoch;
|
var now = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
if (now - timeOfStartMs > 1500) {
|
if (now - timeOfStartMs > 1500) {
|
||||||
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
|
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
_animationController.forward();
|
_scaleAnimationController.forward().whenComplete(() {
|
||||||
|
_animationController.forward();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Future.delayed(Duration(milliseconds: 1500)).then((value) {
|
Future.delayed(Duration(milliseconds: 1500)).then((value) {
|
||||||
_animationController.forward();
|
_scaleAnimationController.forward().whenComplete(() {
|
||||||
|
_animationController.forward();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -131,22 +153,30 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
AnimatedBuilder(
|
AnimatedBuilder(
|
||||||
animation: _colorAnimation,
|
animation: _scaleAnimation,
|
||||||
builder: (context, snapshot) {
|
builder: (context, _) {
|
||||||
return Container(
|
return Transform.scale(
|
||||||
alignment: Alignment.center,
|
scale: _scaleAnimation.value,
|
||||||
constraints: BoxConstraints.expand(),
|
child: AnimatedBuilder(
|
||||||
color: _colorAnimation == null
|
animation: _colorAnimation,
|
||||||
? Color(0xff005FFF)
|
builder: (context, snapshot) {
|
||||||
: _colorAnimation.value,
|
return Container(
|
||||||
child: !_animationController.isAnimating
|
alignment: Alignment.center,
|
||||||
? Lottie.asset(
|
constraints: BoxConstraints.expand(),
|
||||||
'assets/floating_boat.json',
|
color: _colorAnimation == null
|
||||||
alignment: Alignment.center,
|
? Color(0xff005FFF)
|
||||||
)
|
: _colorAnimation.value,
|
||||||
: Container(),
|
child: !_animationController.isAnimating
|
||||||
);
|
? Lottie.asset(
|
||||||
}),
|
'assets/floating_boat.json',
|
||||||
|
alignment: Alignment.center,
|
||||||
|
)
|
||||||
|
: SizedBox(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
AnimatedBuilder(
|
AnimatedBuilder(
|
||||||
animation: _animation,
|
animation: _animation,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
|||||||
Reference in New Issue
Block a user