From 99a796929529ba74d84bd017a4fb75feebceae4c Mon Sep 17 00:00:00 2001 From: mem3Dealer <43483419+mem3Dealer@users.noreply.github.com> Date: Sun, 10 Jan 2021 20:09:46 +0300 Subject: [PATCH] smth --- lib/main.dart | 123 +++++++++++++++++--------------------------------- 1 file changed, 42 insertions(+), 81 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 3fd40b2..6b4f0c5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,14 +18,17 @@ class App extends StatefulWidget { class AppState extends State with SingleTickerProviderStateMixin { AnimationController _controller; + String param; + double tm; @override void initState() { super.initState(); + param = "beginning"; _controller = AnimationController( - duration: Duration(seconds: 10), + duration: Duration(milliseconds: 10000), vsync: this, - ); + )..addListener(() => contrVal()); } @override @@ -43,6 +46,15 @@ class AppState extends State with SingleTickerProviderStateMixin { } } + contrVal() { + setState(() { + tm = _controller.value; + if (_controller.value >= 0.2) param = 'two seconds'; + if (_controller.value >= 0.5) param = "five seconds"; + if (_controller.value >= 1) param = "ten seconds"; + }); + } + @override Widget build(BuildContext context) { return Material( @@ -58,20 +70,28 @@ class AppState extends State with SingleTickerProviderStateMixin { fit: BoxFit.cover, ), ColorFiltered( - colorFilter: - ColorFilter.mode(Colors.black.withOpacity(0.8), BlendMode.srcOut), // This one will create the magic + colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.8), + BlendMode.srcOut), // This one will create the magic child: Stack( fit: StackFit.expand, children: [ Container( decoration: BoxDecoration( color: Colors.black, - backgroundBlendMode: BlendMode.dstOut), // This one will handle background + difference out + backgroundBlendMode: BlendMode + .dstOut), // This one will handle background + difference out ), - MovingHole(controller: _controller) + MovingHole(controller: _controller), ], ), ), + Container( + alignment: Alignment.bottomCenter, + child: Text( + "$param - $tm", + style: + TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + )) ], ), )); @@ -79,66 +99,16 @@ class AppState extends State with SingleTickerProviderStateMixin { } class MovingHole extends StatelessWidget { - // MovingHole({Key key, this.controller}) - // : width = TweenSequence( - // >[ - // TweenSequenceItem( - // tween: Tween(begin: 100, end: 150) - // .chain(CurveTween(curve: Curves.ease)), - // weight: 33.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: 150, end: 200), - // weight: 33.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: 200, end: 300) - // .chain(CurveTween(curve: Curves.ease)), - // weight: 33.0, - // ), - // ], - // ).animate(CurvedAnimation( - // parent: controller, curve: Interval(0.0, 1, curve: Curves.linear))), - // height = TweenSequence( - // >[ - // TweenSequenceItem( - // tween: Tween(begin: 100, end: 150) - // .chain(CurveTween(curve: Curves.ease)), - // weight: 40.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: 150, end: 200), - // weight: 20.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: 200, end: 300) - // .chain(CurveTween(curve: Curves.ease)), - // weight: 40.0, - // ), - // ], - // ).animate(CurvedAnimation( - // parent: controller, - // curve: Interval(0.0, 1, curve: Curves.fastOutSlowIn))), - // radius = BorderRadiusTween( - // begin: BorderRadius.circular(0.0), - // end: BorderRadius.circular(100.0)) - // .animate(CurvedAnimation( - // parent: controller, - // curve: Interval( - // 0.0, - // 1, - // curve: Curves.ease, - // ))), - // alignment = AlignmentTween( - // begin: Alignment.bottomCenter, end: Alignment.topCenter) - // .animate(CurvedAnimation( - // parent: controller, - // curve: Interval(0.0, 1, curve: Curves.ease))), + double timeM(double scene) { + int time = 10; + return scene / time; + } + MovingHole({Key key, this.controller}) : scale1 = Tween(begin: 1.0, end: 0.5).animate( CurvedAnimation( parent: controller, - curve: const Interval(0.05, 0.075, curve: Curves.easeOut), + curve: Interval(0.05, 0.075, curve: Curves.easeOut), ), ), scale2 = Tween(begin: 0.5, end: 1.2).animate( @@ -151,7 +121,8 @@ class MovingHole extends StatelessWidget { ), ), ), - move1 = Tween(begin: Offset(0, 20), end: Offset(-20, 100)).animate(CurvedAnimation( + move1 = Tween(begin: Offset(0, 20), end: Offset(-20, 100)) + .animate(CurvedAnimation( parent: controller, curve: const Interval( 0.0, @@ -159,7 +130,8 @@ class MovingHole extends StatelessWidget { curve: Curves.ease, ), )), - move2 = Tween(begin: Offset(50, 100), end: Offset(30, 20)).animate(CurvedAnimation( + move2 = Tween(begin: Offset(50, 100), end: Offset(30, 20)) + .animate(CurvedAnimation( parent: controller, curve: const Interval( 0.9, @@ -204,25 +176,14 @@ class MovingHole extends StatelessWidget { decoration: BoxDecoration( shape: BoxShape.circle, color: color, - border: Border.all(color: color, style: BorderStyle.solid, width: 4.0 - (2 * controller.value))), + border: Border.all( + color: color, + style: BorderStyle.solid, + width: 4.0 - (2 * controller.value))), )), - // ), ); }); } - - // Widget build(BuildContext context) { - // return AnimatedBuilder( - // animation: controller, - // builder: (BuildContext context, Widget child) { - // return Container( - // // alignment: alignment.value, - // child: Container( - // width: size.value.width, - // height: size.value.height, - // decoration: BoxDecoration( - // color: Colors.red, borderRadius: BorderRadius.all(Radius.circular(20))), - // )); - // }); - // } } +// создать переменную, листенером слить текущее значение, на поляне в стеке вывести. +// сколько составляет 0.05 от 10 секунд