11import 'package:flash_chat_flutter_firebase/screens/login_screen.dart' ;
22import 'package:flutter/material.dart' ;
33import 'registration_screen.dart' ;
4-
4+ import 'package:flash_chat_flutter_firebase/components/rounded_button.dart' ;
55class WelcomeScreen extends StatefulWidget {
66 static const String id = 'welcome_screen' ;
77 @override
88 _WelcomeScreenState createState () => _WelcomeScreenState ();
99}
1010
11- class _WelcomeScreenState extends State <WelcomeScreen > with SingleTickerProviderStateMixin {
11+ class _WelcomeScreenState extends State <WelcomeScreen >
12+ with TickerProviderStateMixin {
1213 AnimationController ? controller;
14+ AnimationController ? controller1;
15+ Animation ? animation;
16+ Animation ? animation2;
1317
14- @override
15- void initState () {
16- super .initState ();
17- controller = AnimationController (
18+ // void update() {
19+ // controller = AnimationController(
20+ // duration: const Duration(seconds: 1),
21+ // vsync: this,
22+ // );
23+ // controller?.forward();
24+ // controller?.addListener(
25+ // () {
26+ // setState(() {});
27+ // print(controller?.value);
28+ // },
29+ // );
30+ // }
31+
32+ void update () {
33+ controller = AnimationController (
1834 duration: const Duration (seconds: 1 ),
19- vsync: this ,
35+ vsync: this ,
2036 );
37+
2138 controller? .forward ();
22- controller? .addListener (()
23- {
24- setState (() {
39+ animation =
40+ ColorTween (begin: Colors .blueGrey, end: Colors .white).animate (controller! );
41+
42+ animation2 = CurvedAnimation (parent: controller! , curve: Curves .easeInCirc);
2543
26- });
27- print (controller? .value);
28- },
44+ controller? .addListener (
45+ () {
46+ setState (() {});
47+ print (animation? .value);
48+ print (animation2? .value);
49+ },
2950 );
51+ }
3052
31- // AnimationController controller = AnimationController(
32- // duration: const Duration(seconds: 1),
33- // vsync: this,
34- // );
35- // controller.forward();
36- // controller.addListener(()
37- // {
38- // print(controller.value);
39- // },
40- // );
53+ void update1 () {
54+ controller1 = AnimationController (
55+ duration: const Duration (seconds: 1 ),
56+ vsync: this ,
57+ upperBound: 100 ,
58+ );
59+ controller1? .forward ();
60+ controller1? .addListener (
61+ () {
62+ setState (() {});
63+ print (controller1? .value);
64+ },
65+ );
4166 }
67+
68+ @override
69+ void dispose () {
70+ controller? .dispose ();
71+ controller1? .dispose ();
72+ super .dispose ();
73+ }
74+
75+ @override
76+ void initState () {
77+ super .initState ();
78+ update ();
79+ update1 ();
80+ }
81+ // AnimationController controller = AnimationController(
82+ // duration: const Duration(seconds: 1),
83+ // vsync: this,
84+ // );
85+ // controller.forward();
86+ // controller.addListener(()
87+ // {
88+ // print(controller.value);
89+ // },
90+ // );
91+
4292 @override
4393 Widget build (BuildContext context) {
4494 return Scaffold (
45- backgroundColor: Colors .red. withOpacity (controller ! . value) ,
95+ backgroundColor: animation ? . value,
4696 body: Padding (
4797 padding: EdgeInsets .symmetric (horizontal: 24.0 ),
4898 child: Column (
@@ -55,7 +105,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> with SingleTickerProvider
55105 tag: 'logo' ,
56106 child: Container (
57107 child: Image .asset ('images/logo.png' ),
58- height: 60.0 ,
108+ height: animation2 ! .value * 100 ,
59109 ),
60110 ),
61111 Text (
@@ -70,38 +120,22 @@ class _WelcomeScreenState extends State<WelcomeScreen> with SingleTickerProvider
70120 SizedBox (
71121 height: 48.0 ,
72122 ),
73- Padding (
74- padding: EdgeInsets .symmetric (vertical: 16.0 ),
75- child: Material (
76- elevation: 5.0 ,
77- color: Colors .lightBlueAccent,
78- borderRadius: BorderRadius .circular (30.0 ),
79- child: MaterialButton (
80- onPressed: () {
81- Navigator .pushNamed (context, LoginScreen .id);
82- },
83- minWidth: 200.0 ,
84- height: 42.0 ,
85- child: Text (
86- 'Log In' ,
87- ),
88- ),
89- ),
123+ RoundButton (color: Colors .blueAccent,title: 'log in' ,onPressed: (){
124+ Navigator .pushNamed (context, LoginScreen .id);
125+ }),
126+ RoundButton (color: Colors .blueAccent,title: 'Registration' ,onPressed: (){
127+ Navigator .pushNamed (context, RegistrationScreen .id);
128+ }),
129+ SizedBox (
130+ height: 48.0 ,
90131 ),
91- Padding (
92- padding: EdgeInsets .symmetric (vertical: 16.0 ),
93- child: Material (
94- color: Colors .blueAccent,
95- borderRadius: BorderRadius .circular (30.0 ),
96- elevation: 5.0 ,
97- child: MaterialButton (
98- onPressed: () {
99- Navigator .pushNamed (context, RegistrationScreen .id);
100- },
101- minWidth: 200.0 ,
102- height: 42.0 ,
103- child: Text (
104- 'Register' ,
132+ Container (
133+ child: Center (
134+ child: Text (
135+ 'Loading : ${controller1 !.value .toInt ()}%' ,
136+ style: TextStyle (
137+ fontSize: 20.0 ,
138+ fontWeight: FontWeight .w900,
105139 ),
106140 ),
107141 ),
0 commit comments