Commit 36431969 authored by NirmalaSudhir's avatar NirmalaSudhir
Browse files

added login UI along with working firebase

parent 7dde6e07
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
......@@ -17,6 +19,10 @@ class _LoginState extends State<Login> {
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
FirebaseAuth auth = FirebaseAuth.instance;
final _formKey = GlobalKey<FormState>();
TextEditingController _emailTextController = TextEditingController();
TextEditingController _passwordTextController = TextEditingController();
SharedPreferences preferences;
bool loading = false;
bool isLoggedin = false;
......@@ -100,27 +106,125 @@ class _LoginState extends State<Login> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
elevation: 0.0,
backgroundColor: Colors.red,
title: Text('Login'),
actions: <Widget>[
new IconButton(
icon: Icon(
Icons.search,color: Colors.white),
onPressed: (){
}),
],
),
body: new Stack(
children: <Widget>[
Center(
child: FlatButton(
Image.asset(
'images/login_background/redDress.jpg',
fit: BoxFit.cover,
width: double.infinity,
height: double.infinity,
),
Container(
color: Colors.white.withOpacity(0.2),
width: double.infinity,
height: double.infinity,
),
Padding(
padding: const EdgeInsets.only(top:200.0),
child: Center(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
borderRadius: BorderRadius.circular(20.0),
color: Colors.white.withOpacity(0.5),
elevation:0.0,
child: Padding(
padding: const EdgeInsets.only(left:12.0),
child: TextFormField(
controller: _emailTextController,
decoration: InputDecoration(
hintText: "Email",
icon: Icon(Icons.email)
),
validator: (value){
if(value.isEmpty){
Pattern pattern =
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
RegExp regex = new RegExp(pattern);
if(!regex.hasMatch(value))
return 'Please make sure your email address is valid';
else
return null;
}
},
),
),
),
),
Padding(
// padding: const EdgeInsets.fromLTRB(14.0, 8.0, 14.0, 8.0),
padding: const EdgeInsets.all(8.0),
child: Material(
borderRadius: BorderRadius.circular(20.0),
color: Colors.white.withOpacity(0.5),
elevation:0.0,
child: Padding(
padding: const EdgeInsets.only(left: 12.0),
child: TextFormField(
controller: _passwordTextController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Password",
icon: Icon(Icons.lock_outline),
),
validator: (value) {
if (value.isEmpty) {
return "The password field cannot be empty";
} else if (value.length < 6) {
return "the password has to be at least 6 characters long";
}
return null;
},
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
borderRadius: BorderRadius.circular(20.0),
color: Colors.blueAccent,
elevation: 0.0,
child: MaterialButton(onPressed: (){},
minWidth: MediaQuery.of(context).size.width,
child: Text("Login",textAlign: TextAlign.center,
style: TextStyle(color:Colors.white,fontWeight: FontWeight.bold),
),
),
),
),
Expanded(child: Container(),),
Divider(color:Colors.white),
Text("Other Login Options",style: TextStyle(color:Colors.white,fontWeight: FontWeight.bold)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
borderRadius: BorderRadius.circular(20.0),
color: Colors.red,
onPressed: (){
elevation: 0.0,
child: MaterialButton(onPressed: (){
handleSignIn();
},child: Text("Sign In / Sign Up with Google",style: TextStyle(color: Colors.white70),)),
},
minWidth: MediaQuery.of(context).size.width,
child: Text("Sign In with Google",textAlign: TextAlign.center,
style: TextStyle(color:Colors.white,fontWeight: FontWeight.bold),
),
),
),
),
],
)
),
),
),
Visibility(
visible: loading ?? true,
child: Center(
......@@ -136,6 +240,16 @@ class _LoginState extends State<Login> {
],
),
/*bottomNavigationBar: Container(
child : Padding(
padding: const EdgeInsets.only(left:12.0, right:12.0,top:8.0, bottom: 8.0),
child: FlatButton(
color: Colors.red,
onPressed: (){
handleSignIn();
},child: Text("Sign In / Sign Up with Google",style: TextStyle(color: Colors.white70),)),
),
),*/
);
}
......
......@@ -66,6 +66,11 @@ flutter:
- images/products/Girls_lehenga.JPG
- images/products/little_boys_shirt_and_dhothi.JPG
- images/products/Men's_shirt_dhothi.JPG
- images/login_background/login_background.jpg
- images/login_background/login_background1.jpg
- images/login_background/redDress.jpg
- images/login_background/red_outfit.jpg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment