352 lines
11 KiB
Dart
352 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:siro_service/constant/colors.dart';
|
|
import 'package:siro_service/controller/mainController/main_controller.dart';
|
|
import 'package:siro_service/views/widgets/my_scafold.dart';
|
|
|
|
class PassengersPage extends StatelessWidget {
|
|
PassengersPage({super.key});
|
|
final MainController mainController = Get.find<MainController>();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MainController>(
|
|
builder: (controller) {
|
|
final data = _extractPassengerData(controller);
|
|
|
|
return MyScaffold(
|
|
title: data != null
|
|
? '${data['first_name'] ?? ''} ${data['last_name'] ?? ''}'
|
|
: 'Passenger Not Found'.tr,
|
|
isleading: true,
|
|
body: [
|
|
if (data != null)
|
|
Container(
|
|
color: AppColor.surfaceColor,
|
|
child: ListView(
|
|
physics: const BouncingScrollPhysics(),
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
children: [
|
|
_buildPersonalInfoCard(data),
|
|
_buildCommunicationCard(data),
|
|
_buildLatestRideCard(data),
|
|
_buildWalletInfoCard(data),
|
|
const SizedBox(height: 40),
|
|
],
|
|
),
|
|
)
|
|
else
|
|
Container(
|
|
color: AppColor.surfaceColor,
|
|
child: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.person_off_rounded,
|
|
size: 64,
|
|
color: AppColor.greyColor.withOpacity(0.5),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
'No passenger data available.'.tr,
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColor.writeColor,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
/// Helper method to extract the passenger data safely.
|
|
Map? _extractPassengerData(MainController controller) {
|
|
final passengerData = controller.passengerData;
|
|
if (passengerData == null ||
|
|
passengerData['message'] == null ||
|
|
passengerData['message'].isEmpty) {
|
|
return null;
|
|
}
|
|
return passengerData['message'][0];
|
|
}
|
|
|
|
Widget _buildPersonalInfoCard(Map data) {
|
|
return _buildCard(
|
|
title: 'Personal Information'.tr,
|
|
icon: Icons.person_outline_rounded,
|
|
iconColor: AppColor.primaryColor,
|
|
children: [
|
|
_buildInfoRow('Phone'.tr, data['phone']),
|
|
_buildInfoRow('Email'.tr, data['email']),
|
|
_buildInfoRow('Gender'.tr, data['gender']),
|
|
_buildInfoRow('Birthdate'.tr, data['birthdate']),
|
|
_buildInfoRow('Employment'.tr, data['employmentType']),
|
|
_buildInfoRow('Marital Status'.tr, data['maritalStatus'], isLast: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildCommunicationCard(Map data) {
|
|
String phone = data['phone'] ?? '';
|
|
String name = data['first_name'] ?? '';
|
|
return _buildCard(
|
|
title: 'Quick Communication'.tr,
|
|
icon: Icons.chat_bubble_outline_rounded,
|
|
iconColor: Colors.teal,
|
|
children: [
|
|
_buildCommunicationRow(
|
|
title: 'Call Passenger'.tr,
|
|
subtitle: phone,
|
|
icon: Icons.phone_rounded,
|
|
color: Colors.green,
|
|
onTap: () => mainController.makePhoneCall(phone),
|
|
),
|
|
_buildCommunicationRow(
|
|
title: 'WhatsApp: Support'.tr,
|
|
subtitle: 'Send technical support message'.tr,
|
|
icon: Icons.send_rounded,
|
|
color: Colors.blue,
|
|
onTap: () => mainController.launchCommunication(
|
|
'whatsapp',
|
|
phone,
|
|
'مرحباً $name، معك الدعم الفني من شركة سيرو. كيف يمكنني مساعدتك اليوم؟',
|
|
),
|
|
isLast: true,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildLatestRideCard(Map data) {
|
|
return _buildCard(
|
|
title: 'Latest Ride'.tr,
|
|
icon: Icons.directions_car_outlined,
|
|
iconColor: Colors.orange,
|
|
children: [
|
|
_buildInfoRow('Ride ID'.tr, data['ride_id']),
|
|
_buildInfoRow('Date'.tr, data['ride_date']),
|
|
_buildInfoRow('Start Time'.tr, data['ride_time']),
|
|
_buildInfoRow('End Time'.tr, data['ride_endtime']),
|
|
_buildInfoRow(
|
|
'Price'.tr, data['price'] != null ? '\$${data['price']}' : null),
|
|
_buildInfoRow('Status'.tr, data['ride_status']),
|
|
_buildInfoRow('Payment Method'.tr, data['ride_payment_method']),
|
|
_buildInfoRow('Car Type'.tr, data['car_type']),
|
|
_buildInfoRow(
|
|
'Distance'.tr,
|
|
data['distance'] != null
|
|
? '${(data['distance'] as num).toStringAsFixed(2)} km'
|
|
: null,
|
|
isLast: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildWalletInfoCard(Map data) {
|
|
return _buildCard(
|
|
title: 'Wallet Information'.tr,
|
|
icon: Icons.account_balance_wallet_outlined,
|
|
iconColor: Colors.green,
|
|
children: [
|
|
_buildInfoRow(
|
|
'Wallet Balance'.tr,
|
|
data['passenger_wallet_balance'] != null
|
|
? '\$${data['passenger_wallet_balance']}'
|
|
: null),
|
|
_buildInfoRow(
|
|
'Last Payment Amount'.tr,
|
|
data['passenger_payment_amount'] != null
|
|
? '\$${data['passenger_payment_amount']}'
|
|
: null),
|
|
_buildInfoRow(
|
|
'Last Payment Method'.tr, data['passenger_payment_method'],
|
|
isLast: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildCard({
|
|
required String title,
|
|
required IconData icon,
|
|
required Color iconColor,
|
|
required List<Widget> children,
|
|
}) {
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.03),
|
|
blurRadius: 16,
|
|
offset: const Offset(0, 6),
|
|
),
|
|
],
|
|
border: Border.all(
|
|
color: Colors.grey.shade100,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: iconColor.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Icon(
|
|
icon,
|
|
color: iconColor,
|
|
size: 20,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w700,
|
|
color: AppColor.writeColor,
|
|
letterSpacing: 0.2,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
...children,
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoRow(String label, dynamic value, {bool isLast = false}) {
|
|
final displayValue = value?.toString() ?? 'N/A';
|
|
return Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: const TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w500,
|
|
color: AppColor.accentColor,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Flexible(
|
|
child: Text(
|
|
displayValue,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColor.writeColor,
|
|
),
|
|
textAlign: TextAlign.end,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (!isLast)
|
|
Divider(
|
|
height: 1,
|
|
thickness: 1,
|
|
color: Colors.grey.shade50,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildCommunicationRow({
|
|
required String title,
|
|
required String subtitle,
|
|
required IconData icon,
|
|
required Color color,
|
|
required VoidCallback onTap,
|
|
bool isLast = false,
|
|
}) {
|
|
return Column(
|
|
children: [
|
|
InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 4),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: color.withOpacity(0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(icon, color: color, size: 20),
|
|
),
|
|
const SizedBox(width: 14),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColor.writeColor,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
subtitle,
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
color: AppColor.accentColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
color: Colors.grey.shade300,
|
|
size: 16,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (!isLast)
|
|
Divider(
|
|
height: 1,
|
|
thickness: 1,
|
|
color: Colors.grey.shade50,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|