Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Charunirathnayake committed Dec 24, 2019
1 parent fa9acb0 commit e93dc70
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
35 changes: 30 additions & 5 deletions miniproject/lib/app_screen/Login.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:miniproject/app_screen/auth_guide.dart';
import 'package:miniproject/app_screen/search.dart';
import 'signup.dart';
import 'recover.dart';
import 'package:firebase_auth/firebase_auth.dart';



//sketch of the login page
class LoginInterface extends StatelessWidget {
/*LoginInterface({@required this.auth});
Expand Down Expand Up @@ -141,10 +143,8 @@ class Loginpage_state extends State<Loginpage> {
Icon(Icons.lock),
suffixIcon:
IconButton(
onPressed: () {

},
icon: Icon(Icons.visibility_off),
onPressed:_visiblePw,
icon: _isHiddenPw?Icon(Icons.visibility_off):Icon(Icons.visibility),
),
labelText: 'Password',
hintText: 'Password',
Expand Down Expand Up @@ -197,7 +197,32 @@ class Loginpage_state extends State<Loginpage> {
child: RaisedButton(
color: Color(0xffBA680B),
hoverColor: Color(0xffF5CA99),
onPressed: () {},
onPressed: () async{
if(emailcontroler.text.isEmpty||passcontroller.text.isEmpty){
setState(() {
_formkey.currentState.reset();
});
return;
}else{
bool res=await Auth().signInWithEmail(
emailcontroler.text,passcontroller.text
);
if(res==true){
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>Searchbox(),
));

}
else{
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>LoginInterface(),
));

}
}
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0),
side: BorderSide(color: Color(0xffBA680B)),
Expand Down
18 changes: 17 additions & 1 deletion miniproject/lib/app_screen/auth_guide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:google_sign_in/google_sign_in.dart';

class User{
/*class User{
User({@required this.uid});
final String uid;
}
Expand Down Expand Up @@ -72,6 +72,22 @@ class auth implements authbase{
}
}*/
class Auth{
Future<bool> signInWithEmail(String email, String password) async {
try {
AuthResult result = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email, password: password);
FirebaseUser user = result.user;
if (user != null) {
return true;
} else {
return false;
}
} catch (e) {
return false;
}
}
}


Expand Down

0 comments on commit e93dc70

Please sign in to comment.