Skip to content

Commit ca3d2b4

Browse files
committed
Update
1 parent 06a2703 commit ca3d2b4

File tree

7 files changed

+161
-163
lines changed

7 files changed

+161
-163
lines changed

lib/components/rounded_button.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'package:flutter/material.dart';
2+
class RoundButton extends StatelessWidget {
3+
final Color? color;
4+
final String? title;
5+
final Function onPressed;
6+
const RoundButton({
7+
Key? key,
8+
this.color,
9+
this.title,
10+
required this.onPressed,
11+
}) : super(key: key);
12+
13+
@override
14+
Widget build(BuildContext context) {
15+
return Padding(
16+
padding: const EdgeInsets.symmetric(vertical: 16.0),
17+
child: Material(
18+
color: color,
19+
borderRadius: const BorderRadius.all(Radius.circular(30.0)),
20+
elevation: 5.0,
21+
child: MaterialButton(
22+
onPressed:(){ onPressed();},
23+
minWidth: 200.0,
24+
height: 42.0,
25+
child: Text(
26+
title!,
27+
style: const TextStyle(
28+
color: Colors.white,
29+
),
30+
),
31+
),
32+
),
33+
) ;
34+
}
35+
}

lib/constants.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,22 @@ const kMessageContainerDecoration = BoxDecoration(
1717
top: BorderSide(color: Colors.lightBlueAccent, width: 2.0),
1818
),
1919
);
20+
21+
const kInputDecoration = InputDecoration(
22+
hintText: 'Enter Details.',
23+
contentPadding:
24+
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
25+
border: OutlineInputBorder(
26+
borderRadius: BorderRadius.all(Radius.circular(32.0)),
27+
),
28+
enabledBorder: OutlineInputBorder(
29+
borderSide:
30+
BorderSide(color: Colors.lightBlueAccent, width: 1.0),
31+
borderRadius: BorderRadius.all(Radius.circular(32.0)),
32+
),
33+
focusedBorder: OutlineInputBorder(
34+
borderSide:
35+
BorderSide(color: Colors.lightBlueAccent, width: 2.0),
36+
borderRadius: BorderRadius.all(Radius.circular(32.0)),
37+
),
38+
);

lib/main.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ class FlashChat extends StatelessWidget {
1010
@override
1111
Widget build(BuildContext context) {
1212
return MaterialApp(
13-
theme: ThemeData.dark().copyWith(
14-
textTheme: const TextTheme(
15-
bodyText2: TextStyle(color: Colors.black54),
16-
),
17-
),
13+
1814
initialRoute: WelcomeScreen.id,
1915
routes: {
2016
WelcomeScreen.id: (context) => WelcomeScreen(),

lib/screens/login_screen.dart

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
2-
2+
import 'package:flash_chat_flutter_firebase/components/rounded_button.dart';
3+
import 'package:flash_chat_flutter_firebase/constants.dart';
34
class LoginScreen extends StatefulWidget {
45
static const String id = 'login_screen';
56
@override
@@ -31,24 +32,7 @@ class _LoginScreenState extends State<LoginScreen> {
3132
onChanged: (value) {
3233
//Do something with the user input.
3334
},
34-
decoration: InputDecoration(
35-
hintText: 'Enter your email',
36-
contentPadding:
37-
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
38-
border: OutlineInputBorder(
39-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
40-
),
41-
enabledBorder: OutlineInputBorder(
42-
borderSide:
43-
BorderSide(color: Colors.lightBlueAccent, width: 1.0),
44-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
45-
),
46-
focusedBorder: OutlineInputBorder(
47-
borderSide:
48-
BorderSide(color: Colors.lightBlueAccent, width: 2.0),
49-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
50-
),
51-
),
35+
decoration: kInputDecoration.copyWith(hintText: 'Enter your email'),
5236
),
5337
SizedBox(
5438
height: 8.0,
@@ -57,46 +41,12 @@ class _LoginScreenState extends State<LoginScreen> {
5741
onChanged: (value) {
5842
//Do something with the user input.
5943
},
60-
decoration: InputDecoration(
61-
hintText: 'Enter your password.',
62-
contentPadding:
63-
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
64-
border: OutlineInputBorder(
65-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
66-
),
67-
enabledBorder: OutlineInputBorder(
68-
borderSide:
69-
BorderSide(color: Colors.lightBlueAccent, width: 1.0),
70-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
71-
),
72-
focusedBorder: OutlineInputBorder(
73-
borderSide:
74-
BorderSide(color: Colors.lightBlueAccent, width: 2.0),
75-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
76-
),
77-
),
44+
decoration: kInputDecoration.copyWith(hintText: 'Enter your password'),
7845
),
7946
SizedBox(
8047
height: 24.0,
8148
),
82-
Padding(
83-
padding: EdgeInsets.symmetric(vertical: 16.0),
84-
child: Material(
85-
color: Colors.lightBlueAccent,
86-
borderRadius: BorderRadius.all(Radius.circular(30.0)),
87-
elevation: 5.0,
88-
child: MaterialButton(
89-
onPressed: () {
90-
//Implement login functionality.
91-
},
92-
minWidth: 200.0,
93-
height: 42.0,
94-
child: Text(
95-
'Log In',
96-
),
97-
),
98-
),
99-
),
49+
RoundButton(title: 'Log In' , color: Colors.blueAccent, onPressed: (){})
10050
],
10151
),
10252
),

lib/screens/registration_screen.dart

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flash_chat_flutter_firebase/constants.dart';
12
import 'package:flutter/material.dart';
23

34
class RegistrationScreen extends StatefulWidget {
@@ -31,22 +32,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
3132
onChanged: (value) {
3233
//Do something with the user input.
3334
},
34-
decoration: InputDecoration(
35-
hintText: 'Enter your email',
36-
contentPadding:
37-
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
38-
border: OutlineInputBorder(
39-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
40-
),
41-
enabledBorder: OutlineInputBorder(
42-
borderSide: BorderSide(color: Colors.blueAccent, width: 1.0),
43-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
44-
),
45-
focusedBorder: OutlineInputBorder(
46-
borderSide: BorderSide(color: Colors.blueAccent, width: 2.0),
47-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
48-
),
49-
),
35+
decoration: kInputDecoration.copyWith(hintText: "Enter your Email"),
5036
),
5137
SizedBox(
5238
height: 8.0,
@@ -55,22 +41,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
5541
onChanged: (value) {
5642
//Do something with the user input.
5743
},
58-
decoration: InputDecoration(
59-
hintText: 'Enter your password',
60-
contentPadding:
61-
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
62-
border: OutlineInputBorder(
63-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
64-
),
65-
enabledBorder: OutlineInputBorder(
66-
borderSide: BorderSide(color: Colors.blueAccent, width: 1.0),
67-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
68-
),
69-
focusedBorder: OutlineInputBorder(
70-
borderSide: BorderSide(color: Colors.blueAccent, width: 2.0),
71-
borderRadius: BorderRadius.all(Radius.circular(32.0)),
72-
),
73-
),
44+
decoration: kInputDecoration.copyWith(hintText: "Enter your password"),
7445
),
7546
SizedBox(
7647
height: 24.0,

lib/screens/welcome_screen.dart

Lines changed: 90 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,98 @@
11
import 'package:flash_chat_flutter_firebase/screens/login_screen.dart';
22
import 'package:flutter/material.dart';
33
import 'registration_screen.dart';
4-
4+
import 'package:flash_chat_flutter_firebase/components/rounded_button.dart';
55
class 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

Comments
 (0)