Show newly submitted reviews on reviews list

Co-authored-by: Reimar <mail@reim.ar>
This commit is contained in:
Alexandertp 2024-09-05 18:23:02 +02:00
parent e03131a8aa
commit 0dcfb2ea1e
2 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mobile/base/sidemenu.dart'; import 'package:mobile/base/sidemenu.dart';
import 'models.dart'; import 'models.dart';
@ -91,5 +93,13 @@ class _CreateReviewState extends State<CreateReviewPage> {
'lat': place!.point.latitude, 'lat': place!.point.latitude,
'lng': place!.point.longitude, 'lng': place!.point.longitude,
}); });
if (response == null || !mounted) return;
final review = Review.fromJson(jsonDecode(response));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Review submitted')));
Navigator.pop(context, review);
} }
} }

View File

@ -61,7 +61,10 @@ class _ReviewListState extends State<ReviewListPage> {
), ),
)), )),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.pushNamed(context, '/create-review', arguments: place), onPressed: () async {
final review = await Navigator.pushNamed(context, '/create-review', arguments: place) as Review?;
if (review != null) reviews.add(review);
},
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
focusColor: Colors.blueGrey, focusColor: Colors.blueGrey,
tooltip: "Write a Review", tooltip: "Write a Review",