2024-09-04 10:53:32 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mobile/base/sidemenu.dart';
|
2024-09-11 11:46:49 +01:00
|
|
|
import 'models.dart' as models;
|
2024-09-13 08:59:21 +01:00
|
|
|
import 'services/api.dart' as api;
|
2024-09-04 10:53:32 +01:00
|
|
|
|
|
|
|
class ReviewListPage extends StatefulWidget {
|
|
|
|
const ReviewListPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<ReviewListPage> createState() => _ReviewListState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ReviewListState extends State<ReviewListPage> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-09-11 11:46:49 +01:00
|
|
|
final arg = ModalRoute.of(context)!.settings.arguments as models.ReviewList;
|
2024-09-05 13:55:34 +01:00
|
|
|
final reviews = arg.reviews;
|
|
|
|
final place = arg.place;
|
2024-09-04 10:53:32 +01:00
|
|
|
|
|
|
|
return SideMenu(
|
|
|
|
selectedIndex: -1,
|
2024-09-05 17:39:43 +01:00
|
|
|
body: Scaffold(
|
2024-09-11 11:46:49 +01:00
|
|
|
backgroundColor: const Color(0xFFF9F9F9),
|
2024-09-05 17:39:43 +01:00
|
|
|
body: SingleChildScrollView(child: Container(
|
|
|
|
decoration: const BoxDecoration(color: Color(0xFFF9F9F9)),
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
child: Column(children:
|
|
|
|
reviews.map((review) => Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
margin: const EdgeInsets.only(bottom: 10),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color(0x20000000),
|
|
|
|
offset: Offset(0,1),
|
|
|
|
blurRadius: 4,
|
2024-09-04 10:53:32 +01:00
|
|
|
),
|
2024-09-05 17:39:43 +01:00
|
|
|
],
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 3),
|
2024-09-11 11:46:49 +01:00
|
|
|
child: Icon(Icons.rate_review, color: Colors.purple, size: 36),
|
2024-09-05 17:39:43 +01:00
|
|
|
),
|
|
|
|
const SizedBox(width: 20),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(review.title, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 24)),
|
|
|
|
Text(review.content),
|
|
|
|
const SizedBox(height: 10),
|
2024-09-11 11:46:49 +01:00
|
|
|
if (review.image != null) Image.network(review.image!.imageUrl, height: 200,),
|
|
|
|
if (review.image != null) const SizedBox(height: 15),
|
2024-09-05 17:39:43 +01:00
|
|
|
Row(children: [
|
|
|
|
for (var i = 0; i < review.rating; i++) const Icon(Icons.star, color: Colors.yellow),
|
|
|
|
for (var i = review.rating; i < 5; i++) const Icon(Icons.star_border),
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)).toList(),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
onPressed: () async {
|
2024-09-09 15:45:16 +01:00
|
|
|
if (!await api.isLoggedIn(context)) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("You must be logged in to do that")));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-09-11 11:46:49 +01:00
|
|
|
final review = await Navigator.pushNamed(context, '/create-review', arguments: place) as models.Review?;
|
2024-09-05 17:39:43 +01:00
|
|
|
if (review != null) reviews.add(review);
|
|
|
|
},
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
focusColor: Colors.blueGrey,
|
|
|
|
tooltip: "Write a Review",
|
|
|
|
child: const Icon(CupertinoIcons.plus),
|
2024-09-04 10:53:32 +01:00
|
|
|
),
|
2024-09-04 11:27:17 +01:00
|
|
|
),
|
2024-09-05 17:39:43 +01:00
|
|
|
);
|
2024-09-04 10:53:32 +01:00
|
|
|
}
|
|
|
|
}
|