Add ReviewListPage and show list of reviews
Co-authored-by: Reimar <mail@reim.ar>
This commit is contained in:
parent
f7d9cc0fa0
commit
6fd77b3330
@ -6,6 +6,7 @@ import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:mobile/favorites.dart';
|
||||
import 'package:mobile/register.dart';
|
||||
import 'package:mobile/reviewList.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'login.dart';
|
||||
import 'base/sidemenu.dart';
|
||||
@ -45,6 +46,7 @@ class MyApp extends StatelessWidget {
|
||||
'/favorites': (context) => const FavoritesPage(),
|
||||
'/login': (context) => const LoginPage(),
|
||||
'/register': (context) => const RegisterPage(),
|
||||
'/reviews': (context) => const ReviewListPage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -128,6 +130,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
setState(() => _selectedPoint = null);
|
||||
}
|
||||
|
||||
// Open location bottom menu
|
||||
Future<void> _showLocation(LatLng point, String name, String description) async {
|
||||
await showModalBottomSheet(
|
||||
barrierColor: Colors.black.withOpacity(0.3),
|
||||
@ -140,6 +143,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
padding: const EdgeInsets.all(20),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Row(children: [
|
||||
// Location information
|
||||
Expanded(child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -148,14 +152,27 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Text(description),
|
||||
],
|
||||
)),
|
||||
|
||||
Column(children: [
|
||||
// Toggle favorite button
|
||||
IconButton(
|
||||
icon: const Icon(Icons.star),
|
||||
iconSize: 32,
|
||||
color: _favorites.where((fav) => fav.lat == point.latitude && fav.lng == point.longitude).isEmpty ? Colors.grey : Colors.yellow,
|
||||
onPressed: () => _toggleFavorite(point, name, description, setModalState, context)
|
||||
),
|
||||
const IconButton(icon: Icon(Icons.rate_review), iconSize: 32, onPressed: null),
|
||||
|
||||
// View reviews button
|
||||
IconButton(
|
||||
icon: const Icon(Icons.rate_review),
|
||||
iconSize: 32,
|
||||
onPressed: () =>
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
'/reviews',
|
||||
arguments: _reviews.where((review) => review.lat == point.latitude && review.lng == point.longitude).toList()
|
||||
),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
|
@ -30,9 +30,10 @@ class Review {
|
||||
String place_name;
|
||||
String place_description;
|
||||
String title;
|
||||
String content;
|
||||
int rating;
|
||||
|
||||
Review(this.id, this.userId, this.lat, this.lng, this.place_name, this.place_description, this.title, this.rating);
|
||||
Review(this.id, this.userId, this.lat, this.lng, this.place_name, this.place_description, this.title, this.content, this.rating);
|
||||
|
||||
factory Review.fromJson(Map<String, dynamic> json) {
|
||||
return Review(
|
||||
@ -43,7 +44,8 @@ class Review {
|
||||
json['place_name'],
|
||||
json['place_description'],
|
||||
json['title'],
|
||||
json['rating']
|
||||
json['content'],
|
||||
json['rating'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
64
Mobile/lib/reviewList.dart
Normal file
64
Mobile/lib/reviewList.dart
Normal file
@ -0,0 +1,64 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mobile/base/sidemenu.dart';
|
||||
import 'models.dart';
|
||||
|
||||
class ReviewListPage extends StatefulWidget {
|
||||
const ReviewListPage({super.key});
|
||||
|
||||
@override
|
||||
State<ReviewListPage> createState() => _ReviewListState();
|
||||
}
|
||||
|
||||
class _ReviewListState extends State<ReviewListPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
final reviews = ModalRoute.of(context)!.settings.arguments as List<Review>;
|
||||
|
||||
return SideMenu(
|
||||
selectedIndex: -1,
|
||||
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,
|
||||
),
|
||||
],
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 3),
|
||||
child: Icon(Icons.radio, color: Colors.purple, size: 36),
|
||||
),
|
||||
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),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
)).toList(),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user