Update: 2026-08-08 16:55:39
This commit is contained in:
@@ -1,119 +1,90 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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 CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text(
|
||||
"Rate Our App".tr,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Center(
|
||||
child: Obx(() {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 30),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// App logo or visual
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Image.asset(
|
||||
'assets/images/logo.gif',
|
||||
height: 120,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Rating Prompt
|
||||
Text(
|
||||
"How would you rate our app?".tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: CupertinoTheme.of(context)
|
||||
.textTheme
|
||||
.navTitleTextStyle
|
||||
.copyWith(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Comment Box
|
||||
CupertinoTextField(
|
||||
controller: ratingController.comment,
|
||||
placeholder: 'Write your comment here'.tr,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: CupertinoColors.systemGrey4),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: CupertinoColors.white,
|
||||
),
|
||||
prefix: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Icon(CupertinoIcons.pencil_ellipsis_rectangle,
|
||||
color: CupertinoColors.systemGrey),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Star Rating Section
|
||||
_buildRatingStars(),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Submit Button
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24, vertical: 14),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: CupertinoColors.activeGreen,
|
||||
onPressed: () {
|
||||
if (ratingController.userRating.value > 0) {
|
||||
ratingController
|
||||
.submitRating(ratingController.userRating.value);
|
||||
Get.snackbar(
|
||||
"Thank You!".tr,
|
||||
"Your rating has been submitted.".tr,
|
||||
backgroundColor: CupertinoColors.systemGrey6,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
margin: const EdgeInsets.all(16),
|
||||
borderRadius: 12,
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"Error".tr,
|
||||
"Please select a rating before submitting.".tr,
|
||||
backgroundColor: CupertinoColors.systemRed,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
margin: const EdgeInsets.all(16),
|
||||
borderRadius: 12,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
"Submit Rating".tr,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
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),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,19 +93,19 @@ class RatingScreen extends StatelessWidget {
|
||||
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: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Icon(
|
||||
CupertinoIcons.star_fill,
|
||||
size: 40,
|
||||
color: index < ratingController.userRating.value
|
||||
? CupertinoColors.systemYellow
|
||||
: CupertinoColors.systemGrey3,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/style.dart';
|
||||
import '../../controller/rate/rate_conroller.dart';
|
||||
import '../widgets/ui/siro_ui.dart';
|
||||
|
||||
class RatePassenger extends StatelessWidget {
|
||||
final RateController controller = Get.put(RateController());
|
||||
@@ -21,19 +22,14 @@ class RatePassenger extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text('Trip Completed'.tr),
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
elevation: 0,
|
||||
),
|
||||
return SiroPage(
|
||||
title: 'Trip Completed'.tr,
|
||||
showBack: false,
|
||||
body: GetBuilder<RateController>(
|
||||
builder: (controller) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
padding: SiroUi.pageInsets,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -159,20 +155,13 @@ class RatePassenger extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildWalletSection(BuildContext context, RateController controller) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Theme.of(context).dividerColor),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: controller.ispassengerWantWalletFromDriver
|
||||
? _buildAmountInput(context, controller)
|
||||
: _buildWalletQuery(context, controller),
|
||||
),
|
||||
return SiroCard(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: controller.ispassengerWantWalletFromDriver
|
||||
? _buildAmountInput(context, controller)
|
||||
: _buildWalletQuery(context, controller),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user