Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Charunirathnayake committed Dec 21, 2019
1 parent 2641d8f commit 561f9a7
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 70 deletions.
28 changes: 27 additions & 1 deletion miniproject/lib/app_screen/Login.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import 'package:flutter/material.dart';
import 'package:miniproject/app_screen/auth_guide.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});
final authbase auth;


Future <void> _signInWithGoogle()async{
try{
await auth.signInWithGoogle();
}
catch(e){
print(e.toString());
}
}



@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -27,6 +45,10 @@ class Loginpage extends StatefulWidget {
}

class Loginpage_state extends State<Loginpage> {


TextEditingController emailcontroler=TextEditingController();
TextEditingController passcontroller=TextEditingController();
@override
Widget build(BuildContext context) {
return Container(
Expand Down Expand Up @@ -56,6 +78,7 @@ class Loginpage_state extends State<Loginpage> {
height:40.0 ,
width:280.0 ,
child: TextField(
controller: emailcontroler,
decoration: InputDecoration(
prefixIcon:
Icon(Icons.email),
Expand All @@ -80,6 +103,7 @@ class Loginpage_state extends State<Loginpage> {
height: 40.0,
width: 280.0,
child: TextField(
controller: passcontroller,
obscureText: true,
decoration: InputDecoration(
prefixIcon:
Expand Down Expand Up @@ -197,7 +221,7 @@ class Loginpage_state extends State<Loginpage> {
Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0),
child: OutlineButton(
onPressed: () {},
onPressed:_signInWithGoogle(),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0),
side: BorderSide(color: Colors.white),
Expand All @@ -219,6 +243,8 @@ class Loginpage_state extends State<Loginpage> {
),
),
SizedBox(height: 20,),

//facebook login
Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0),
child: OutlineButton(
Expand Down
78 changes: 78 additions & 0 deletions miniproject/lib/app_screen/auth_guide.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:google_sign_in/google_sign_in.dart';

class User{
User({@required this.uid});
final String uid;
}



abstract class authbase {
Future<User> currentUser();
Future<void> signOut();
Future<User> signInWithGoogle();

}


class auth implements authbase{
final _firebaseAuth=FirebaseAuth.instance;

User userFromFirebase(FirebaseUser user){
if(user==null){
return null;
}
return User(uid: user.uid);
}

@override
Future<User> currentUser() async{
final user= await _firebaseAuth.currentUser();
return userFromFirebase(user);
}
@override
Future<void> signOut() async{
await _firebaseAuth.signOut();
}

//Google signin
@override
Future<User> signInWithGoogle() async{
GoogleSignIn googleSignIn=GoogleSignIn();
GoogleSignInAccount googleAccount=await googleSignIn.signIn();
if(googleAccount!=null){
GoogleSignInAuthentication googleAuth=await googleAccount.authentication;

if(googleAuth.accessToken!=null&&googleAuth.idToken!=null){
final authResult= await _firebaseAuth.signInWithCredential(
GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken

)
);
return userFromFirebase(authResult.user);}
else{
throw PlatformException(code: 'ERROR_MISSING_GOOGLE_AUTH_TAKEN',
message: 'Missing google auth taken'

);
}
}
else{
throw PlatformException(code: 'ERROR_ABORTED_BY_USER',
message: 'Sign in aborted by user'

);
}
}


}



197 changes: 197 additions & 0 deletions miniproject/lib/app_screen/mainSearch.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import 'package:flutter/material.dart';
import 'package:loader_search_bar/loader_search_bar.dart';


class MainSearchbox extends StatelessWidget{
@override
Widget build(BuildContext context) {

return Scaffold(
body: MainContentOfThePage(),
appBar:AppBar(
backgroundColor: Color(0xffBA680B),
title: Text('Search for your guide'),
actions: <Widget>[
IconButton(icon:Icon(Icons.search),onPressed: (){
showSearch(context: context, delegate:MainDatasearchbox() );
},

),
IconButton(icon: Icon(Icons.filter_list),onPressed: (){

},)
],
)
);
}

}
class MainDatasearchbox extends SearchDelegate<String>{
final distric=['Rathhnapura','Kegalle','Galle','Mathara'];
final recent=['kegalle','Galle'];

@override
List<Widget> buildActions(BuildContext context) {

return[
IconButton(icon: Icon(Icons.clear),onPressed: (){
query="";

},)
];

}

@override
Widget buildLeading(BuildContext context) {
return IconButton(
icon:AnimatedIcon(icon:AnimatedIcons.menu_arrow,
progress:transitionAnimation,

),onPressed: (){
close(context,null);
},);
}

@override
Widget buildResults(BuildContext context) {
// TODO: implement buildResults
return null;
}

@override
Widget buildSuggestions(BuildContext context) {
//TODO:REMOVE UNNESSARY CODES
final suggesionsList=query.isEmpty?recent:distric;
return ListView.builder(itemBuilder: (context,index){
ListTile(
leading: Icon(Icons.location_city),
title: Text(suggesionsList[index]),
);

},itemCount: suggesionsList.length,);
}

}

class MainContentOfThePage extends StatefulWidget{
@override
State<StatefulWidget> createState() {

return MainContentOfThePage_state();
}

}

class MainContentOfThePage_state extends State<MainContentOfThePage>{
@override
Widget build(BuildContext context) {

return ListView(
children: <Widget>[
Column(
children: <Widget>[
Stack(
children: <Widget>[
//call for the itemcard widget

],
)
],
)
],
)

;
}

}

Widget itemcard (String titlename,String profilepicpath,bool isfavorite){
return Padding(padding: EdgeInsets.only(top: 15.0,left: 15.0,right: 15.0),
child: Container(
height: 150.0,
width: double.infinity,
color: Colors.brown,
child: Row(
children: <Widget>[
//define the profile pic
Container(
height:150.0 ,
width: 140.0,
decoration: BoxDecoration(
image: DecorationImage(image:AssetImage(profilepicpath),
fit: BoxFit.cover
)
),
),

SizedBox(
width: 4.0,
),

//desciption of the guide
Column(
children: <Widget>[
Row(
children: <Widget>[
//define the guide name
Text(titlename,style: TextStyle(color: Colors.black,fontSize: 17.0,fontWeight: FontWeight.bold),),
SizedBox(width: 45.0,),

//favorite icon
Material(
elevation: isfavorite ? 0.0:2.0,
borderRadius: BorderRadius.circular(20),
child: Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: isfavorite? Colors.grey.withOpacity(0.25):Colors.white
),
child: Center(
child: isfavorite? Icon(Icons.favorite_border):
Icon(Icons.favorite,color:Colors.red),
),
),
)

],
),
SizedBox(height: 5.0,),

//Description provided by the guide
Container(
width: 175.0,
child: Text('Description that get by the database'),
),


//contact button

ButtonTheme(
height: 25.0,
minWidth: 75.0,
child: RaisedButton(
color: Color(0xffBA680B),
hoverColor: Color(0xffF5CA99),
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0),
side: BorderSide(color: Color(0xffBA680B)),
),
child: Text('Contact me',style:TextStyle(color: Colors.white,fontSize: 15.0),)
),
)


],
)

],
),
),

);
}
Loading

0 comments on commit 561f9a7

Please sign in to comment.