-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathHomePage.dart
109 lines (104 loc) · 3.38 KB
/
HomePage.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_google_authentication/Screens/InfoPage.dart';
import 'package:firebase_google_authentication/Screens/SignUpPage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_fonts/google_fonts.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if(snapshot.connectionState ==ConnectionState.waiting){
return Center(child: CircularProgressIndicator(),);
}
else if(snapshot.hasError){
return Center(child: Text('An error Occured!!'),);
}else if(snapshot.hasData){
return InfoPage();
}else {
return home(size, context);
}
}
),
);
}
Column home(Size size, BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Welcome!',
style: GoogleFonts.lora(
fontSize: 36,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 30,),
SvgPicture.asset(
'assets/login.svg',
width: size.width*0.8,
height: size.height*0.3,
),
SizedBox(height: 60,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: size.width*0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton(
padding: EdgeInsets.symmetric(vertical: 15,horizontal: 40),
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>SignUpPage(true)));
},
child: Text('Login',
style: GoogleFonts.alice(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20
),
),
color: Color(0xFF6F35A5),
),
),
),
],
),
SizedBox(height: 15,),
Container(
width: size.width*0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton(
padding: EdgeInsets.symmetric(vertical: 15,horizontal: 40),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(builder: (context)=> SignUpPage(false))
);
},
child: Text('SignUp',
style: GoogleFonts.alice(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20
),
),
color: Color(0xFFF1E6FF),
),
),
),
],
);
}
}