From d767e0bb85387665801d06d0cbdb8c1c36cf982a Mon Sep 17 00:00:00 2001 From: Alexandertp Date: Thu, 5 Sep 2024 18:39:43 +0200 Subject: [PATCH] Add stars to review list Co-authored-by: Reimar --- Mobile/lib/reviewlist.dart | 106 ++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/Mobile/lib/reviewlist.dart b/Mobile/lib/reviewlist.dart index bd0313b..6c21f05 100644 --- a/Mobile/lib/reviewlist.dart +++ b/Mobile/lib/reviewlist.dart @@ -19,57 +19,65 @@ class _ReviewListState extends State { return SideMenu( selectedIndex: -1, - body: Scaffold(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), - ], + body: Scaffold( + backgroundColor: Color(0xFFF9F9F9), + 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, ), - ), - ], - ) - )).toList(), + ], + 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), + const SizedBox(height: 10), + 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 { + final review = await Navigator.pushNamed(context, '/create-review', arguments: place) as Review?; + if (review != null) reviews.add(review); + }, + backgroundColor: Colors.blue, + focusColor: Colors.blueGrey, + tooltip: "Write a Review", + child: const Icon(CupertinoIcons.plus), ), - )), - floatingActionButton: FloatingActionButton( - onPressed: () async { - final review = await Navigator.pushNamed(context, '/create-review', arguments: place) as Review?; - if (review != null) reviews.add(review); - }, - backgroundColor: Colors.blue, - focusColor: Colors.blueGrey, - tooltip: "Write a Review", - child: const Icon(CupertinoIcons.plus), ), - )); + ); } } \ No newline at end of file