import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../constant/colors.dart'; import '../../controller/rate/rate_app_controller.dart'; import '../widgets/ui/siro_ui.dart'; class RatingScreen extends StatelessWidget { RatingScreen({super.key}); final RatingController ratingController = Get.put(RatingController()); @override Widget build(BuildContext context) { return SiroPage( title: 'Rate Our App'.tr, padding: SiroUi.pageInsets, body: Obx(() { return ListView( children: [ const SizedBox(height: 8), Center( child: ClipRRect( borderRadius: BorderRadius.circular(16), child: Image.asset('assets/images/logo.gif', height: 120), ), ), const SizedBox(height: 20), Text( 'How would you rate our app?'.tr, textAlign: TextAlign.center, style: Theme.of(context) .textTheme .titleMedium ?.copyWith(fontWeight: FontWeight.bold), ), const SizedBox(height: 18), _buildRatingStars(), const SizedBox(height: 22), SiroCard( padding: const EdgeInsets.all(6), child: TextField( controller: ratingController.comment, maxLines: 4, minLines: 3, decoration: InputDecoration( hintText: 'Write your comment here'.tr, filled: false, border: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, ), ), ), const SizedBox(height: 22), ElevatedButton.icon( onPressed: () { if (ratingController.userRating.value > 0) { ratingController .submitRating(ratingController.userRating.value); Get.snackbar( 'Thank You!'.tr, 'Your rating has been submitted.'.tr, backgroundColor: AppColor.greenColor, colorText: Colors.white, snackPosition: SnackPosition.BOTTOM, margin: const EdgeInsets.all(16), borderRadius: 14, ); } else { Get.snackbar( 'Error'.tr, 'Please select a rating before submitting.'.tr, backgroundColor: AppColor.redColor, colorText: Colors.white, snackPosition: SnackPosition.BOTTOM, margin: const EdgeInsets.all(16), borderRadius: 14, ); } }, icon: const Icon(Icons.send_rounded, size: 18), label: Text('Submit Rating'.tr), ), const SizedBox(height: 20), ], ); }), ); } // Widget for building rating stars with animations Widget _buildRatingStars() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(5, (index) { final selected = index < ratingController.userRating.value; return GestureDetector( onTap: () => ratingController.userRating.value = index + 1, child: AnimatedScale( scale: selected ? 1.0 : 0.88, duration: const Duration(milliseconds: 200), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 5), child: Icon( selected ? Icons.star_rounded : Icons.star_outline_rounded, size: 42, color: selected ? AppColor.gold : Colors.grey, ), ), ), ); }), ); } }