Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Charunirathnayake committed Feb 4, 2020
1 parent 4d5cbc9 commit 2e7e342
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 58 deletions.
10 changes: 10 additions & 0 deletions miniproject/lib/app_screen/Posts.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:cloud_firestore/cloud_firestore.dart';

class CrudMethods{
/*String image,city,email,phonenumber,name,passion;
Posts(this.image,this.city,this.email,this.name,this.passion,this.phonenumber);*/
getData() async{
return await Firestore.instance.collection('profiledata').getDocuments();

}
}
22 changes: 21 additions & 1 deletion miniproject/lib/app_screen/guideprofile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,23 @@ print('New data added.');
});
}
void saveToDatabase(url){

DocumentReference ds=Firestore.instance.collection('profiledata').document(email);
Map<String,dynamic> tasks={
"name":name,
"address":address,
"city":city,
"passion":passion,
"phonenumber":phonenumber,
"email":email,
"gendervalue":gendervalue,
"Image":url,

};
ds.setData(tasks).whenComplete((){
print('New data added.');
});


}


Expand Down Expand Up @@ -600,6 +616,9 @@ print('New data added.');
onPressed: () {
uploadpic(context);
createData();
Navigator.pop(context);
Navigator.push(context, MaterialPageRoute(builder: (context) => Profile()));

},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0),
Expand Down Expand Up @@ -648,4 +667,5 @@ print('New data added.');
],
);
}

}
6 changes: 6 additions & 0 deletions miniproject/lib/app_screen/mainSearch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class MainContentOfThePage extends StatefulWidget{
}

class MainContentOfThePage_state extends State<MainContentOfThePage>{
@override
void initState() {

super.initState();
}

@override
Widget build(BuildContext context) {

Expand Down
261 changes: 205 additions & 56 deletions miniproject/lib/app_screen/search.dart
Original file line number Diff line number Diff line change
@@ -1,96 +1,112 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:loader_search_bar/loader_search_bar.dart';
import 'package:miniproject/app_screen/interface.dart';
import 'Posts.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';


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

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

),
IconButton(icon: Icon(Icons.person_add),onPressed: (){
Navigator.pop(context);
Navigator.push(context, MaterialPageRoute(builder: (context) => Content()));

},)
],
)
);
appBar: AppBar(
backgroundColor: Color(0xffBA680B),
title: Text('Search for your guide'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {
showSearch(context: context, delegate: Datasearchbox());
},
),
IconButton(
icon: Icon(Icons.person_add),
onPressed: () {
Navigator.pop(context);
Navigator.push(context,
MaterialPageRoute(builder: (context) => Content()));
},
)
],
));
}

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

class Datasearchbox 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="";

},)
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);
},);
}
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){
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,);
},
itemCount: suggesionsList.length,
);
}

}

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

return ContentOfThePage_state();
}

}

class ContentOfThePage_state extends State<ContentOfThePage>{
class ContentOfThePage_state extends State<ContentOfThePage> {
QuerySnapshot profiledata;
CrudMethods crudobj = CrudMethods();

@override
void initState() {
crudobj.getData().then((results) {
setState(() {
profiledata = results;
});
});
super.initState();
}

@override
Widget build(BuildContext context) {

return ListView(
return _profileList();
/*ListView(
children: <Widget>[
Column(
children: <Widget>[
Expand All @@ -103,14 +119,147 @@ class ContentOfThePage_state extends State<ContentOfThePage>{
],
)
],
)

;
)*/
}

Widget _profileList() {
String titlename;
bool isfavorite;
if (profiledata != null) {
return ListView.builder(
itemCount: profiledata.documents.length,
padding: EdgeInsets.all(5.0),
itemBuilder: (context, i) {
return new Card(
elevation: 10.0,
child: Column(children: <Widget>[
Container(
height: 250.0,
width: 280.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: NetworkImage(
profiledata.documents[i].data['Image']),
fit: BoxFit.cover)),
),
SizedBox(
width: 8.0,
),
//desciption of the guide
Column(
children: <Widget>[
Row(
children: <Widget>[
//define the guide name
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
profiledata.documents[i].data['name'],
style: TextStyle(
color: Colors.black,
fontSize: 20.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(profiledata.documents[i].data['passion']),
),
SizedBox(
height: 5.0,
),
Row(
children: <Widget>[
Icon(Icons.location_on),
SizedBox(
width: 10.0,
),
Text(profiledata.documents[i].data['city'])
],
),
SizedBox(
height: 5.0,
),
Row(
children: <Widget>[
Icon(Icons.phone),
SizedBox(
width: 10.0,
),
Text(profiledata.documents[i].data['phonenumber'])
],
),
SizedBox(
height: 5.0,
),
Row(
children: <Widget>[
Icon(Icons.mail_outline),
SizedBox(
width: 10.0,
),
Text(profiledata.documents[i].data['email'])
],
),
//button for contact
ButtonTheme(
height: 40.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),)
),
) ,
SizedBox(height: 10.0,)


],
),
]));
},
);
} else {
return Text('Loading, Please wait..');
}
}
}

Widget itemcard (String titlename,String profilepicpath,bool isfavorite){
/*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,
Expand Down Expand Up @@ -197,4 +346,4 @@ Widget itemcard (String titlename,String profilepicpath,bool isfavorite){
),
);
}
}*/
2 changes: 1 addition & 1 deletion miniproject/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main(){
theme: ThemeData(
primarySwatch: Colors.brown
),
home:PostHome(),
home:Searchbox(),
debugShowCheckedModeBanner: false,
)
);
Expand Down

0 comments on commit 2e7e342

Please sign in to comment.