Skip to content

Commit

Permalink
✨ FEAT: Show reviews stored in firestore
Browse files Browse the repository at this point in the history
  • Loading branch information
danhandev committed Sep 25, 2022
1 parent 75e4faf commit 40c4443
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions lib/page/detail_page/detailPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@ class detailPage extends StatefulWidget {

class _detailPageState extends State<detailPage> {
// List<double> _allcoordinate = [0.0001,0.0001];
double _xcoordinate = 0.00000001;
double _ycoordinate = 0.00000001;

PreferredSizeWidget _appBarWidget() {
DocumentReference _documentReference =
FirebaseFirestore.instance.collection('cae').doc(widget.cafeName);

// dynamic favorite = StreamBuilder<DocumentSnapshot>(
// stream: _documentReference.snapshots(),
// builder: (context, currentUserDocSnapshot) {
// if (!currentUserDocSnapshot.hasData) {
// return Center(
// child: CircularProgressIndicator(
// backgroundColor: Colors.deepPurple,
// ));
// }
// return Text(currentUserDocSnapshot.data!["username"]);
// },
// );

// print("여기야 ${favorite.data['favorite']}");

bool _favoriteButtonPressed = widget.likedStatus;
double _xcoordinate = 0.00000001;
double _ycoordinate = 0.00000001;

return AppBar(
elevation: 0,
Expand All @@ -46,6 +61,7 @@ class _detailPageState extends State<detailPage> {
onPressed: () {
setState(() {
_favoriteButtonPressed = !_favoriteButtonPressed;
print(_favoriteButtonPressed);
_documentReference.update({'favorite': _favoriteButtonPressed});
});
;
Expand Down Expand Up @@ -104,6 +120,7 @@ class _detailPageState extends State<detailPage> {

Widget _bodyWidget() {
var size = MediaQuery.of(context).size;
String review = '';

DocumentReference _documentReference =
FirebaseFirestore.instance.collection('cae').doc(widget.cafeName);
Expand All @@ -119,14 +136,12 @@ class _detailPageState extends State<detailPage> {
return Text("Loading");
}

_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'];
List<dynamic> _reviews = snapshot.data!['views'];

var menus = _menus.keys;

Expand All @@ -138,6 +153,14 @@ class _detailPageState extends State<detailPage> {
return sb.toString();
}

String getReviewList(List<dynamic> _reviews) {
StringBuffer sb = StringBuffer();
for (String review in _reviews) {
sb.write("- ${review}\n");
}
return sb.toString();
}

return SingleChildScrollView(
child: Stack(
children: <Widget>[
Expand Down Expand Up @@ -242,15 +265,21 @@ class _detailPageState extends State<detailPage> {
),
borderRadius: BorderRadius.circular(10),
),
child: const Padding(
padding: EdgeInsets.all(7.0),
child: TextField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: '리뷰를 작성해주세요.',
child: Padding(
padding: EdgeInsets.all(7.0),
child: Text(getReviewList(_reviews))
// TextField(
// keyboardType: TextInputType.text,
// textAlign: TextAlign.left,
// onChanged: (value) {
// review = value;
// },
// decoration: const InputDecoration(
// border: UnderlineInputBorder(),
// labelText: '리뷰를 작성해주세요.',
// ),
// ),
),
),
),
),
],
),
Expand Down

0 comments on commit 40c4443

Please sign in to comment.