26-1-20/1

This commit is contained in:
Hamza-Ayed
2026-01-20 10:11:10 +03:00
parent 374f9e9bf3
commit 3c0ae4cf2f
53 changed files with 89652 additions and 6861 deletions

View File

@@ -3,58 +3,65 @@ import 'package:sefer_driver/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart'; // Import this for formatting
import 'package:sefer_driver/constant/colors.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
import '../../constant/style.dart';
import '../../controller/rate/rate_conroller.dart';
// Changed: تم إعادة بناء الصفحة بالكامل لتحسين التصميم وتجربة المستخدم
class RatePassenger extends StatelessWidget {
final RateController controller = Get.put(RateController());
// Format: 1,234.5
final NumberFormat currencyFormatter = NumberFormat("#,##0.0", "en_US");
RatePassenger({super.key});
@override
Widget build(BuildContext context) {
// New: استخدام Scaffold القياسي لهيكل أكثر قوة ومرونة
return Scaffold(
backgroundColor: Colors.grey[50],
appBar: AppBar(
title: Text('Rate Passenger'.tr),
title: Text('Trip Completed'.tr,
style: const TextStyle(color: Colors.black)),
centerTitle: true,
automaticallyImplyLeading: false, // New: إزالة سهم الرجوع
automaticallyImplyLeading: false,
backgroundColor: Colors.white,
elevation: 1,
elevation: 0,
),
// New: استخدام GetBuilder على مستوى الجسم لضمان تحديث الواجهة
body: GetBuilder<RateController>(
builder: (controller) {
// New: استخدام SingleChildScrollView لتجنب مشاكل الـ overflow عند ظهور لوحة المفاتيح
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// New: استدعاء ودجت منفصلة لكل قسم لزيادة التنظيم
_buildPriceSummaryCard(context, controller),
const SizedBox(height: 16),
// New: قسم المحفظة يظهر فقط إذا لم يتم التحقق منه
if (controller.walletChecked != 'true')
_buildWalletSection(context, controller),
const SizedBox(height: 16),
_buildRatingSection(context, controller),
// 1. The HERO Section: Big Price Display
_buildHeroPriceDisplay(context),
const SizedBox(height: 24),
MyElevatedButton(
title: 'Submit rating'.tr,
onPressed: () => controller.addRateToPassenger(),
// New: جعل الزر يأخذ العرض الكامل لمزيد من الوضوح
// isFullWidth: true,
// 2. Wallet Section (Conditional)
if (controller.walletChecked != 'true')
_buildWalletSection(context, controller),
const SizedBox(height: 24),
// 3. Rating Section
_buildRatingSection(context, controller),
const SizedBox(height: 30),
// 4. Submit Button
SizedBox(
height: 55,
child: MyElevatedButton(
title: 'Finish & Submit'.tr,
onPressed: () => controller.addRateToPassenger(),
// isFullWidth: true,
),
),
],
),
@@ -65,85 +72,96 @@ class RatePassenger extends StatelessWidget {
);
}
// New: ودجت منفصلة لعرض بطاقة ملخص السعر
Widget _buildPriceSummaryCard(
BuildContext context, RateController controller) {
final MapDriverController mapController = Get.find<MapDriverController>();
final double originalPrice =
double.tryParse(controller.price.toString()) ?? 0.0;
final double priceAfterDiscount = originalPrice - (originalPrice * 0.12);
// --- WIDGETS ---
return Card(
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Text(
'${'Trip Summary with'.tr} ${mapController.passengerName}',
style: AppStyle.title
.copyWith(fontSize: 18, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
Widget _buildHeroPriceDisplay(BuildContext context) {
final MapDriverController mapController = Get.find<MapDriverController>();
// Parse the string to double to format it correctly
double amount =
double.tryParse(mapController.paymentAmount.toString()) ?? 0.0;
String formattedAmount = currencyFormatter.format(amount);
return Container(
padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
decoration: BoxDecoration(
color: AppColor.primaryColor, // Use your brand color or a dark color
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.3),
blurRadius: 15,
offset: const Offset(0, 10),
),
],
),
child: Column(
children: [
Text(
'Collect Cash'.tr.toUpperCase(),
style: const TextStyle(
color: Colors.white70,
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: 1.2,
),
const Divider(height: 24, thickness: 1),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Original Fare'.tr, style: AppStyle.title),
Text(
priceAfterDiscount.toStringAsFixed(2),
style: AppStyle.number.copyWith(
fontSize: 16,
color: AppColor.redColor,
decoration: TextDecoration.lineThrough,
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Currency Symbol (Small)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'SYP'.tr, // Replace with your local currency symbol if needed
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Your Earnings'.tr,
style:
AppStyle.title.copyWith(fontWeight: FontWeight.bold)),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: AppColor.greenColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.greenColor),
),
child: Text(
mapController.paymentAmount,
style: AppStyle.number
.copyWith(color: AppColor.greenColor, fontSize: 20),
),
),
const SizedBox(width: 4),
// The Price (Huge)
Text(
formattedAmount,
style: const TextStyle(
color: Colors.white,
fontSize: 56, // Very Large Font
fontWeight: FontWeight.w900,
height: 1.0,
),
],
),
],
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
),
const SizedBox(height: 12),
Text(
'Exclusive offers and discounts always with the Sefer app'.tr,
textAlign: TextAlign.center,
style: AppStyle.title
.copyWith(color: AppColor.redColor, fontSize: 13),
)
],
),
child: Text(
'Passenger: ${mapController.passengerName}',
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
],
),
);
}
// New: ودجت منفصلة لقسم الدفع عبر المحفظة
Widget _buildWalletSection(BuildContext context, RateController controller) {
return Card(
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.grey.shade200),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(20.0),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: controller.ispassengerWantWalletFromDriver
@@ -154,37 +172,61 @@ class RatePassenger extends StatelessWidget {
);
}
// New: واجهة سؤال استخدام المحفظة
Widget _buildWalletQuery(RateController controller) {
return Column(
key: const ValueKey('walletQuery'),
children: [
Text(
"Would the passenger like to settle the remaining fare using their wallet?"
.tr,
style: AppStyle.title,
textAlign: TextAlign.center,
Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.orange.withOpacity(0.1),
shape: BoxShape.circle,
),
child: const Icon(Icons.account_balance_wallet,
color: Colors.orange),
),
const SizedBox(width: 15),
Expanded(
child: Text(
"Pay remaining to Wallet?".tr,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
],
),
const SizedBox(height: 16),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: MyElevatedButton(
title: 'No'.tr,
onPressed: () {
// يمكنك هنا تحديد ما يحدث عند الضغط على "لا"
// حاليًا، ستبقى الواجهة كما هي أو يمكنك إخفاؤها
},
kolor: AppColor.redColor,
child: OutlinedButton(
onPressed: () {}, // Optional logic
style: OutlinedButton.styleFrom(
foregroundColor: Colors.grey,
side: BorderSide(color: Colors.grey.shade300),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
child: Text('No'.tr),
),
),
const SizedBox(width: 10),
const SizedBox(width: 12),
Expanded(
child: MyElevatedButton(
title: 'Yes, Pay'.tr,
onPressed: () {
controller.passengerWantPay();
},
child: ElevatedButton(
onPressed: () => controller.passengerWantPay(),
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
child: Text('Yes, Pay'.tr,
style: const TextStyle(color: Colors.white)),
),
),
],
@@ -193,137 +235,94 @@ class RatePassenger extends StatelessWidget {
);
}
// New: واجهة إدخال المبلغ المدفوع
Widget _buildAmountInput(RateController controller) {
return Column(
key: const ValueKey('amountInput'),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"How much Passenger pay?".tr,
style: AppStyle.title,
"Enter Amount Paid".tr,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
Form(
key: controller.formKey,
child: MyTextForm(
controller: controller.passengerPayAmount,
label: "Passenger paid amount".tr,
label: "Amount".tr,
hint: "0.00",
type: const TextInputType.numberWithOptions(decimal: true),
// Suggestion: Add a suffix icon for currency if available in your widget
),
),
const SizedBox(height: 12),
MyElevatedButton(
title: "Add to Passenger Wallet".tr,
// isFullWidth: true,
onPressed: () {
controller.addPassengerWallet();
},
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () => controller.addPassengerWallet(),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
child: Text("Confirm Payment".tr,
style: const TextStyle(color: Colors.white)),
),
)
],
);
}
// New: ودجت منفصلة لقسم التقييم وكتابة الملاحظات
Widget _buildRatingSection(BuildContext context, RateController controller) {
return Card(
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Text('How was the passenger?'.tr,
style: AppStyle.title
.copyWith(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 20),
RatingBar.builder(
initialRating: 0,
itemCount: 5,
itemSize: 40,
itemPadding: const EdgeInsets.symmetric(horizontal: 4),
itemBuilder: (context, index) {
switch (index) {
case 0:
return const Icon(Icons.sentiment_very_dissatisfied,
color: Colors.red);
case 1:
return const Icon(Icons.sentiment_dissatisfied,
color: Colors.redAccent);
case 2:
return const Icon(Icons.sentiment_neutral,
color: Colors.amber);
case 3:
return const Icon(Icons.sentiment_satisfied,
color: Colors.lightGreen);
case 4:
return const Icon(Icons.sentiment_very_satisfied,
color: Colors.green);
default:
return const Icon(Icons.sentiment_neutral,
color: Colors.amber);
}
},
onRatingUpdate: (rating) {
controller.selectRateItem(rating);
},
),
const SizedBox(height: 24),
TextFormField(
maxLines: 4,
minLines: 2,
keyboardType: TextInputType.multiline,
controller: controller.comment,
decoration: InputDecoration(
labelText: 'Add a comment (optional)'.tr,
hintText: 'Type something...'.tr,
prefixIcon: const Icon(Icons.rate_review_outlined),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
),
),
],
),
),
);
}
}
// New: إضافة isFullWidth إلى MyElevatedButton لتسهيل التحكم في العرض
// تأكد من تحديث ملف elevated_btn.dart بهذا التغيير
/*
class MyElevatedButton extends StatelessWidget {
final String title;
final VoidCallback onPressed;
final Color? kolor;
final bool isFullWidth; // New property
const MyElevatedButton({
Key? key,
required this.title,
required this.onPressed,
this.kolor,
this.isFullWidth = false, // Default value
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
width: isFullWidth ? double.infinity : null, // Apply width
height: 50, // Standard height
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: kolor ?? AppColor.primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
return Column(
children: [
Text(
'Rate Passenger'.tr,
style: TextStyle(
color: Colors.grey[600],
fontSize: 14,
fontWeight: FontWeight.w500,
),
textStyle: AppStyle.title.copyWith(color: Colors.white),
),
child: Text(title, style: const TextStyle(color: Colors.white)),
),
const SizedBox(height: 12),
RatingBar.builder(
initialRating: 0,
minRating: 1,
direction: Axis.horizontal,
allowHalfRating: false,
itemCount: 5,
itemSize: 45, // Large stars
itemPadding: const EdgeInsets.symmetric(horizontal: 2.0),
itemBuilder: (context, _) => const Icon(
Icons.star_rounded,
color: Colors.amber,
),
onRatingUpdate: (rating) {
controller.selectRateItem(rating);
},
),
const SizedBox(height: 20),
// Simplified comment box
TextField(
controller: controller.comment,
maxLines: 2,
decoration: InputDecoration(
hintText: 'Any comments about the passenger?'.tr,
filled: true,
fillColor: Colors.white,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade200),
),
),
),
],
);
}
}
*/