Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Jeon-jisu/winproj into se…
Browse files Browse the repository at this point in the history
…arch_page
  • Loading branch information
Pjunn committed Sep 23, 2022
2 parents fb24c22 + 22f1e5f commit 88abb68
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 138 deletions.
1 change: 0 additions & 1 deletion android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ gradle-wrapper.jar
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
Expand Down
6 changes: 6 additions & 0 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sdk.dir=/Users/jisu/Library/Android/sdk
flutter.sdk=/Users/jisu/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
google.maps.apiKey=AIzaSyDpOHTRh0dkxHuR1HH3X979oizAwQXp-Ts
5 changes: 5 additions & 0 deletions lib/models/myuser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ class MyUser{
Future<List<dynamic>> fUser = DataBaseService().userFavorite(uid);
fUser.then((value) => {favorite = value});
}
List<dynamic>? getUpdatedList() {
Future<List<dynamic>> fUser = DataBaseService().userFavorite(uid);
fUser.then((value) => {favorite = value});
return favorite;
}
}
110 changes: 55 additions & 55 deletions lib/page/favorites_page/favorite_cafe_item.dart
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
import 'package:cafegation/page/detail_page/detailPage.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:cafegation/models/cafe.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:transparent_image/transparent_image.dart';

class FavoriteCafeItem extends StatelessWidget {
class FavoriteCafeItem extends StatefulWidget {
final Cafe cafe;
final int index;
final bool hideFavorite;
final int index;
const FavoriteCafeItem({Key? key, required this.hideFavorite, required this.cafe, required this.index}) : super(key: key);

const FavoriteCafeItem({required this.cafe, required this.index, required this.hideFavorite, Key? key}) : super(key: key);
@override
State<FavoriteCafeItem> createState() => _FavoriteCafeItemState();
}

//TODO : There is actually no 'favorite' function here, which is a problem.
class _FavoriteCafeItemState extends State<FavoriteCafeItem> {
@override
bool state = true;
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
color: Colors.grey[200 + index % 4 * 100],
height: 100,
child: Row(
children: <Widget>[
hideFavorite
? Container()
: SizedBox(
width: 60,
child: ImageIcon(
const AssetImage('assets/heart.png'),
color: Colors.red[500],
),
),
Padding(padding: const EdgeInsets.all(8.0), child: FadeInImage.memoryNetwork(placeholder: kTransparentImage, image: cafe.images)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
cafe.name,
style: const TextStyle(
fontSize: 20,
),
),
Text(
cafe.location,
style: TextStyle(fontSize: 15, color: Colors.grey[500]),
),
Row(
children: [
Text(cafe.rating),
RatingBarIndicator(
rating: double.parse(cafe.rating),
direction: Axis.horizontal,
itemCount: 5,
itemSize: 20.0,
itemPadding: const EdgeInsets.symmetric(horizontal: 1.0),
itemBuilder: (context, _) => const Icon(
Icons.star,
color: Colors.amber,
),
)
],
)
],
),
)
],
return ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => detailPage(
cafeName: widget.cafe.id,
likedStatus: true,
)),
);
},
leading: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.network(
widget.cafe.images,
width: 80,
height: 100,
)),
title: Text(widget.cafe.name),
subtitle: Text(widget.cafe.location),
trailing: IconButton(
icon: Icon(state ? Icons.favorite : Icons.favorite_border),
color: Colors.red,
iconSize: 25.0,
onPressed: () {
setState(() {
var list = [
{"id": widget.cafe.id, "tag": widget.cafe.tags}
];
if (state == true) {
state = false;
FirebaseFirestore.instance
.collection('user_data')
.doc(FirebaseAuth.instance.currentUser!.uid)
.set({"favorites": FieldValue.arrayRemove(list)}, SetOptions(merge: true));
} else {
state = true;
FirebaseFirestore.instance
.collection('user_data')
.doc(FirebaseAuth.instance.currentUser!.uid)
.set({"favorites": FieldValue.arrayUnion(list)}, SetOptions(merge: true));
}
});
},
),
);
}
Expand Down
15 changes: 6 additions & 9 deletions lib/page/favorites_page/favoritesPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import 'package:cafegation/services/database.dart';
import 'package:cafegation/models/cafe.dart';
import 'package:cafegation/page/favorites_page/favorite_cafe_list.dart';


class favoritesPage extends StatefulWidget {
const favoritesPage({ Key? key }) : super(key: key);
const favoritesPage({Key? key}) : super(key: key);

@override
_FavoritesPageState createState() => _FavoritesPageState();
Expand All @@ -25,14 +24,12 @@ class _FavoritesPageState extends State<favoritesPage> {
initialData: const [],
value: DataBaseService().favoriteCafes(AuthService().user!),
child: Scaffold(
appBar: AppBar(
backgroundColor: kMainColor,
shadowColor: kGreyColor,
title: const Text('Favorites Page'),
appBar: AppBar(
backgroundColor: Colors.blue[200],
shadowColor: kGreyColor,
title: const Text('Favorites Page'),
),
body: FavoriteCafeList()
),
body: FavoriteCafeList()),
);
}
}

2 changes: 0 additions & 2 deletions lib/page/list_page/CafeItem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ class _CafeItemState extends State<CafeItem> {
.collection('user_data')
.doc(FirebaseAuth.instance.currentUser!.uid)
.set({"favorites": FieldValue.arrayRemove(list)}, SetOptions(merge: true));
Icon(Icons.favorite_border);
} else {
state = true;
FirebaseFirestore.instance
.collection('user_data')
.doc(FirebaseAuth.instance.currentUser!.uid)
.set({"favorites": FieldValue.arrayUnion(list)}, SetOptions(merge: true));
Icon(Icons.favorite);
}
stateBool(AuthService().user!, state);
});
Expand Down
7 changes: 4 additions & 3 deletions lib/page/list_page/listPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import 'package:cafegation/services/auth.dart';
import 'package:cafegation/services/database.dart';

class listPage extends StatefulWidget {
const listPage({Key? key}) : super(key: key);
final tagCode;
const listPage({Key? key, required this.tagCode}) : super(key: key);

@override
_listPageState createState() => _listPageState();
Expand All @@ -18,8 +19,8 @@ class listPage extends StatefulWidget {
class _listPageState extends State<listPage> {
@override
Widget build(BuildContext context) {
return StreamProvider<List<Cafe>>.value(
value: DataBaseService().cafes,
return FutureProvider<List<Cafe>>.value(
value: DataBaseService().cafeListFromSnapShot(widget.tagCode),
initialData: [],
child: Scaffold(
appBar: AppBar(
Expand Down
3 changes: 2 additions & 1 deletion lib/page/map_page/mapPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class KakaoMapTest extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
primarySwatch: Colors.lightBlue,
),
home: MapSample(),
);
Expand Down
76 changes: 18 additions & 58 deletions lib/page/tag_page/tagPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ class _tagPageState extends State<tagPage> {
primary: Color(0xFF2C2E43),
onPrimary: Colors.black),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 1)));
},
child: Text(
'#분위기 있는',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#디저트',
style: TextStyle(color: Colors.white, fontSize: 20.0, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand All @@ -66,18 +59,11 @@ class _tagPageState extends State<tagPage> {
primary: Color(0xFFB2B1B9),
onPrimary: Colors.black),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 2)));
},
child: Text(
'#조용한',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#브런치',
style: TextStyle(color: Colors.white, fontSize: 20.0, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand All @@ -94,17 +80,11 @@ class _tagPageState extends State<tagPage> {
onPrimary: Colors.white,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 3)));
},
child: Text(
'#디저트 맛집인',
style: TextStyle(
fontSize: 18.0,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#힐링되는',
style: TextStyle(fontSize: 18.0, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand Down Expand Up @@ -132,18 +112,11 @@ class _tagPageState extends State<tagPage> {
primary: Color(0xFF2C2E43),
onPrimary: Colors.black),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 4)));
},
child: Text(
'#이야기하기 좋은',
style: TextStyle(
color: Colors.white,
fontSize: 16.5,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#인스타 갬성,,',
style: TextStyle(color: Colors.white, fontSize: 16.5, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand All @@ -159,18 +132,11 @@ class _tagPageState extends State<tagPage> {
primary: Color(0xFFB2B1B9),
onPrimary: Colors.black),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 5)));
},
child: Text(
'#콘센트 많은',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#새로 생긴',
style: TextStyle(color: Colors.white, fontSize: 20.0, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand All @@ -187,17 +153,11 @@ class _tagPageState extends State<tagPage> {
onPrimary: Colors.white,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => listPage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => listPage(tagCode: 6)));
},
child: Text(
'#커피 맛집인',
style: TextStyle(
fontSize: 18.0,
letterSpacing: 1.0,
fontWeight: FontWeight.normal),
'#뷰가 좋은',
style: TextStyle(fontSize: 18.0, letterSpacing: 1.0, fontWeight: FontWeight.normal),
),
),
),
Expand Down
Loading

0 comments on commit 88abb68

Please sign in to comment.