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 24, 2022
2 parents d3bbb90 + 4e0f915 commit ca9cec1
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 40 deletions.
2 changes: 1 addition & 1 deletion android/local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ flutter.sdk=C:\\flutter\\flutter_windows_2.10.2-stable\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
google.maps.apiKey=AIzaSyDpOHTRh0dkxHuR1HH3X979oizAwQXp-Ts
google.maps.apiKey=메롱
100 changes: 64 additions & 36 deletions lib/page/detail_page/detailPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cafegation/models/cafe.dart';

class detailPage extends StatefulWidget {
const detailPage({Key? key, required this.cafeName, required this.likedStatus}) : super(key: key);
const detailPage(
{Key? key, required this.cafeName, required this.likedStatus})
: super(key: key);

final String cafeName;
final bool likedStatus;
Expand All @@ -17,10 +19,6 @@ class detailPage extends StatefulWidget {
class _detailPageState extends State<detailPage> {
bool _favoriteButtonPressed = false;

String _images = "대표 사진";
String _name = "카페 이름";
String _location = "장소";
List<dynamic> _tags = ['태그1', '태그2', '태그3'];
// List<double> _allcoordinate = [0.0001,0.0001];
double _xcoordinate = 0.00000001;
double _ycoordinate = 0.00000001;
Expand Down Expand Up @@ -57,21 +55,48 @@ class _detailPageState extends State<detailPage> {
IconButton(
icon: const Icon(Icons.location_pin),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> detailMapPage(xcoordinate: _xcoordinate,ycoordinate: _ycoordinate,)));
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => detailMapPage(
xcoordinate: _xcoordinate,
ycoordinate: _ycoordinate,
)));
},
),
],
);
}

Widget _tagWidget(String tagName) {
Widget _tagWidget(int tag) {
String tag_string = "태그";

switch (tag) {
case 1:
tag_string = "bakery_cafe";
break;
case 2:
tag_string = "brunch_cafe";
break;
case 3:
tag_string = "healing_cafe";
break;
case 4:
tag_string = "instagram_cafe";
break;
case 5:
tag_string = "new_cafe";
break;
case 6:
tag_string = "view_cafe";
break;
}

return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30), color: kGreyColor),
child: Padding(
padding: const EdgeInsets.all(7.0),
child: Text(
tagName,
tag_string,
style: const TextStyle(fontSize: 11),
),
),
Expand All @@ -95,12 +120,24 @@ class _detailPageState extends State<detailPage> {
return Text("Loading");
}

_images = snapshot.data!['images'];
_name = snapshot.data!['name'];
_location = snapshot.data!['location'];
_tags = snapshot.data!['tags'];
_xcoordinate = snapshot.data!['coordinates'][0];
_ycoordinate = snapshot.data!['coordinates'][1];
_xcoordinate = snapshot.data!['coordinate'][0];
_ycoordinate = snapshot.data!['coordinate'][1];
String _images = snapshot.data!['images'];
String _name = snapshot.data!['name'];
String _location = snapshot.data!['location'];
List<dynamic> _tags = snapshot.data!['tags'];
Map<String, dynamic> _menus = snapshot.data!['menus'];
// var _reviews = snapshot.data!['reviews'];

var menus = _menus.keys;

String getLineBreakStrings(Iterable<String> keys) {
StringBuffer sb = StringBuffer();
for (String key in keys) {
sb.write("- ${key} : ${_menus[key]}\n");
}
return sb.toString();
}

return SingleChildScrollView(
child: Stack(
Expand All @@ -115,7 +152,7 @@ class _detailPageState extends State<detailPage> {
),
),
Container(
margin: EdgeInsets.only(top: size.height * 0.45),
margin: EdgeInsets.only(top: size.height * 0.35),
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
Expand All @@ -139,7 +176,7 @@ class _detailPageState extends State<detailPage> {
),
// 카페 위치
Text(
_location,
" ${_location}",
style: const TextStyle(
fontSize: 11,
),
Expand All @@ -148,17 +185,11 @@ class _detailPageState extends State<detailPage> {
height: 9,
),
// 태그
Row(
Wrap(
spacing: 10,
children: [
_tagWidget(_tags[0]),
const SizedBox(
width: 10,
),
_tagWidget(_tags[1]),
const SizedBox(
width: 10,
),
_tagWidget(_tags[2]),
SizedBox(width: MediaQuery.of(context).size.width),
for (int tag in _tags) _tagWidget(tag)
],
),
const SizedBox(
Expand All @@ -185,13 +216,8 @@ class _detailPageState extends State<detailPage> {
),
borderRadius: BorderRadius.circular(10),
),
child: const Padding(
padding: EdgeInsets.all(7.0),
child: Text(
'- 아메리카노\n- 카페 라떼\n- 바닐라 라뗴\n- 핫초코',
style: TextStyle(fontSize: 13),
),
),
padding: EdgeInsets.all(7.0),
child: Text(getLineBreakStrings(menus)),
),
const SizedBox(
height: 10.0,
Expand Down Expand Up @@ -219,9 +245,11 @@ class _detailPageState extends State<detailPage> {
),
child: const Padding(
padding: EdgeInsets.all(7.0),
child: Text(
'- 여기 불친절해요\n- 커피 맛집',
style: TextStyle(fontSize: 13),
child: TextField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: '리뷰를 작성해주세요.',
),
),
),
),
Expand Down
10 changes: 7 additions & 3 deletions lib/page/list_page/CafeItem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ class _CafeItemState extends State<CafeItem> {
FirebaseFirestore.instance
.collection('user_data')
.doc(FirebaseAuth.instance.currentUser!.uid)
.set({"favorites": FieldValue.arrayRemove(list)}, SetOptions(merge: true));
.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));
.set({"favorites": FieldValue.arrayUnion(list)},
SetOptions(merge: true));
}
stateBool(AuthService().user!, state);
});
Expand All @@ -94,7 +96,9 @@ class _CafeItemState extends State<CafeItem> {
FirebaseAuth user = FirebaseAuth.instance;
var b;

final a = FirebaseFirestore.instance.collection('user_data').doc(user.currentUser!.uid);
final a = FirebaseFirestore.instance
.collection('user_data')
.doc(user.currentUser!.uid);
return a.get().then((value) {
b = value.data();
b = b['favorites'];
Expand Down

0 comments on commit ca9cec1

Please sign in to comment.