25-10-5/1
This commit is contained in:
@@ -15,16 +15,6 @@ import '../../../print.dart';
|
||||
// Assuming you have an AppColor class defined in your project.
|
||||
// import 'path/to/your/app_color.dart';
|
||||
|
||||
// --- Placeholder AppColor Class ---
|
||||
// This is used to make the code runnable.
|
||||
// You should use the one from your project.
|
||||
// class AppColor {
|
||||
// static const Color primaryColor = Color(0xFF1DA1F2);
|
||||
// static const Color greenColor = Color(0xFF34A853); // Google Green
|
||||
// static const Color secondaryColor = Colors.white;
|
||||
// }
|
||||
// --- End of Placeholder ---
|
||||
|
||||
/// A visually revamped authentication screen with a light, glassy effect,
|
||||
/// themed for the driver application using a green primary color.
|
||||
class AuthScreen extends StatelessWidget {
|
||||
|
||||
@@ -47,7 +47,7 @@ class PassengerLocationMapPage extends StatelessWidget {
|
||||
|
||||
// 4. نافذة معلومات الراكب في الأسفل (تظهر قبل بدء الرحلة)
|
||||
|
||||
const PassengerInfoWindow(),
|
||||
PassengerInfoWindow(),
|
||||
// 3. زر إلغاء الرحلة في الأعلى يسارًا
|
||||
|
||||
CancelWidget(mapDriverController: mapDriverController),
|
||||
@@ -56,7 +56,7 @@ class PassengerLocationMapPage extends StatelessWidget {
|
||||
driverEndRideBar(),
|
||||
|
||||
// 6. أزرار الطوارئ والاتصال
|
||||
const SosConnect(),
|
||||
SosConnect(),
|
||||
|
||||
// 7. دائرة عرض السرعة
|
||||
speedCircle(),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:bubble_head/bubble.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -8,6 +10,7 @@ import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/home_captain/drawer_captain.dart';
|
||||
import 'package:sefer_driver/views/widgets/mycircular.dart';
|
||||
|
||||
import '../../../../constant/box_name.dart';
|
||||
import '../../../../constant/colors.dart';
|
||||
import '../../../../constant/info.dart';
|
||||
import '../../../../constant/style.dart';
|
||||
@@ -15,7 +18,11 @@ import '../../../../controller/functions/location_controller.dart';
|
||||
import '../../../../controller/functions/overlay_permisssion.dart';
|
||||
import '../../../../controller/functions/package_info.dart';
|
||||
import '../../../../controller/home/captin/home_captain_controller.dart';
|
||||
import '../../../../controller/home/captin/map_driver_controller.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../notification/available_rides_page.dart';
|
||||
import '../../../widgets/circle_container.dart';
|
||||
import '../driver_map_page.dart';
|
||||
import 'widget/connect.dart';
|
||||
import 'widget/left_menu_map_captain.dart';
|
||||
|
||||
@@ -51,7 +58,7 @@ class HomeCaptain extends StatelessWidget {
|
||||
|
||||
// 2. The new floating "Status Pod" at the bottom.
|
||||
const _StatusPodOverlay(),
|
||||
|
||||
FloatingActionButtons(),
|
||||
// This widget from the original code remains.
|
||||
leftMainMenuCaptainIcons(),
|
||||
],
|
||||
@@ -465,44 +472,112 @@ class _MapControlButton extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// NOTE: The _FloatingActionButtons and _MapControlButton widgets have been removed
|
||||
/// as their functionality is now integrated into the _HomeAppBar.
|
||||
///
|
||||
/// You will still need to modify your existing `ConnectWidget`
|
||||
/// to accept an `isCompact` boolean flag as mentioned in the previous design.
|
||||
/*
|
||||
class ConnectWidget extends StatelessWidget {
|
||||
final bool isCompact;
|
||||
const ConnectWidget({super.key, this.isCompact = false});
|
||||
class FloatingActionButtons extends StatelessWidget {
|
||||
const FloatingActionButtons();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// ... your existing controller logic
|
||||
|
||||
if (isCompact) {
|
||||
// Return a smaller version for the pod
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: controller.isConnect ? AppColor.greenColor : AppColor.accentColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
// نفس الكود الأصلي للأزرار
|
||||
return Positioned(
|
||||
bottom: Get.height * .2,
|
||||
right: 6,
|
||||
child:
|
||||
GetBuilder<HomeCaptainController>(builder: (homeCaptainController) {
|
||||
return Column(
|
||||
children: [
|
||||
Icon(controller.isConnect ? Icons.wifi_tethering_rounded : Icons.wifi_tethering_off_rounded, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
controller.isConnect ? 'Online'.tr : 'Offline'.tr,
|
||||
style: AppStyle.title.copyWith(color: Colors.white, fontSize: 14),
|
||||
Platform.isAndroid
|
||||
? AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: homeCaptainController.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.blueColor),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () async {
|
||||
Bubble().startBubbleHead(sendAppToBackground: true);
|
||||
},
|
||||
icon: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
fit: BoxFit.cover,
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: homeCaptainController.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.blueColor),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Get.to(() => const AvailableRidesPage());
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.train_sharp,
|
||||
size: 29,
|
||||
color: AppColor.blueColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
box.read(BoxName.rideStatus) == 'Applied' ||
|
||||
box.read(BoxName.rideStatus) == 'Begin'
|
||||
? Positioned(
|
||||
bottom: Get.height * .2,
|
||||
right: 6,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: homeCaptainController.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.blueColor),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: GestureDetector(
|
||||
onLongPress: () {
|
||||
box.write(BoxName.rideStatus, 'delete');
|
||||
homeCaptainController.update();
|
||||
},
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
box.read(BoxName.rideStatus) == 'Applied'
|
||||
? {
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments:
|
||||
box.read(BoxName.rideArguments)),
|
||||
Get.put(MapDriverController())
|
||||
.changeRideToBeginToPassenger()
|
||||
}
|
||||
: {
|
||||
Get.to(() => PassengerLocationMapPage(),
|
||||
arguments:
|
||||
box.read(BoxName.rideArguments)),
|
||||
Get.put(MapDriverController())
|
||||
.startRideFromStartApp()
|
||||
};
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.directions_rounded,
|
||||
size: 29,
|
||||
color: AppColor.blueColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Return the original, larger button
|
||||
return ElevatedButton.icon(...)
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/controller/firebase/local_notification.dart';
|
||||
import 'package:sefer_driver/controller/functions/network/net_guard.dart';
|
||||
import 'package:sefer_driver/controller/functions/sms_egypt_controller.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/auth/captin/login_captin.dart';
|
||||
import 'package:sefer_driver/views/auth/captin/otp_page.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/driver_map_page.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/orderCaptin/vip_order_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -16,13 +15,10 @@ import '../../../../../constant/colors.dart';
|
||||
import '../../../../../constant/links.dart';
|
||||
import '../../../../../controller/firebase/firbase_messge.dart';
|
||||
import '../../../../../controller/functions/crud.dart';
|
||||
import '../../../../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../../../../controller/home/captin/order_request_controller.dart';
|
||||
import '../../../../../controller/home/navigation/navigation_view.dart';
|
||||
import '../../../../../print.dart';
|
||||
import '../../../../Rate/ride_calculate_driver.dart';
|
||||
import '../../../../auth/captin/otp_page.dart';
|
||||
import '../../../../auth/syria/registration_view.dart';
|
||||
import '../../../../widgets/error_snakbar.dart';
|
||||
|
||||
GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
final firebaseMessagesController =
|
||||
@@ -186,7 +182,8 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
// child: Builder(builder: (context) {
|
||||
// return IconButton(
|
||||
// onPressed: () async {
|
||||
// Get.to(PhoneNumberScreen());
|
||||
// Get.to(() => const PhoneNumberScreen());
|
||||
// // box.write(BoxName.statusDriverLocation, 'off');
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// FontAwesome5.grin_tears,
|
||||
|
||||
@@ -13,8 +13,10 @@ import '../../../../main.dart';
|
||||
|
||||
// Changed: إعادة تصميم كاملة لتصبح شريط معلومات علوي مدمج
|
||||
class PassengerInfoWindow extends StatelessWidget {
|
||||
const PassengerInfoWindow({super.key});
|
||||
|
||||
PassengerInfoWindow({super.key});
|
||||
final fcm = Get.isRegistered<FirebaseMessagesController>()
|
||||
? Get.find<FirebaseMessagesController>()
|
||||
: Get.put(FirebaseMessagesController());
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MapDriverController>(
|
||||
@@ -152,8 +154,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
if (await controller
|
||||
.calculateDistanceBetweenDriverAndPassengerLocation() <
|
||||
140) {
|
||||
Get.find<FirebaseMessagesController>()
|
||||
.sendNotificationToDriverMAP(
|
||||
fcm.sendNotificationToDriverMAP(
|
||||
'Hi ,I Arrive your site',
|
||||
'I Arrive at your site'.tr,
|
||||
controller.tokenPassenger,
|
||||
@@ -238,7 +239,7 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
kolor: AppColor.deepPurpleAccent,
|
||||
onPressed: () {
|
||||
MyDialog().getDialog('Are you sure to cancel?'.tr, '', () async {
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
fcm.sendNotificationToDriverMAP(
|
||||
'Driver Cancelled Your Trip',
|
||||
'You will need to pay the cost to the driver, or it will be deducted from your next trip'
|
||||
.tr,
|
||||
|
||||
@@ -207,8 +207,10 @@ import '../../../../main.dart';
|
||||
|
||||
// Changed: إعادة تصميم وتغيير موضع أزرار التواصل والطوارئ
|
||||
class SosConnect extends StatelessWidget {
|
||||
const SosConnect({super.key});
|
||||
|
||||
SosConnect({super.key});
|
||||
final fcm = Get.isRegistered<FirebaseMessagesController>()
|
||||
? Get.find<FirebaseMessagesController>()
|
||||
: Get.put(FirebaseMessagesController());
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MapDriverController>(
|
||||
@@ -337,25 +339,23 @@ class SosConnect extends StatelessWidget {
|
||||
_buildMessageTile(
|
||||
text: "Where are you, sir?".tr,
|
||||
onTap: () {
|
||||
Get.find<FirebaseMessagesController>()
|
||||
.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
"Where are you, sir?".tr,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
fcm.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
"Where are you, sir?".tr,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
Get.back();
|
||||
}),
|
||||
_buildMessageTile(
|
||||
text: "I've been trying to reach you but your phone is off.".tr,
|
||||
onTap: () {
|
||||
Get.find<FirebaseMessagesController>()
|
||||
.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
"I've been trying to reach you but your phone is off.".tr,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
fcm.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
"I've been trying to reach you but your phone is off.".tr,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
Get.back();
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
@@ -374,13 +374,12 @@ class SosConnect extends StatelessWidget {
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Get.find<FirebaseMessagesController>()
|
||||
.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
controller.messageToPassenger.text,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
fcm.sendNotificationToDriverMAP(
|
||||
'message From Driver',
|
||||
controller.messageToPassenger.text,
|
||||
controller.tokenPassenger,
|
||||
[],
|
||||
'ding.wav');
|
||||
controller.messageToPassenger.clear();
|
||||
Get.back();
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:webview_flutter/webview_flutter.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../controller/functions/crud.dart';
|
||||
import '../../../controller/payment/mtn_new/mtn_payment_new_screen.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
@@ -65,48 +66,49 @@ class PointsCaptain extends StatelessWidget {
|
||||
color: AppColor.blueColor, size: 70),
|
||||
],
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Insert Wallet phone number'.tr,
|
||||
content: Form(
|
||||
key: paymentController.formKey,
|
||||
child: MyTextForm(
|
||||
controller:
|
||||
paymentController.walletphoneController,
|
||||
label: 'Insert Wallet phone number'.tr,
|
||||
hint: '963941234567',
|
||||
type: TextInputType.phone)),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'OK'.tr,
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
if (paymentController.formKey.currentState!
|
||||
.validate()) {
|
||||
box.write(
|
||||
BoxName.phoneWallet,
|
||||
paymentController
|
||||
.walletphoneController.text);
|
||||
await payWithMTNWallet(
|
||||
context, pricePoint.toString(), 'SYP');
|
||||
}
|
||||
}));
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Pay by MTN Wallet'.tr),
|
||||
const SizedBox(width: 10),
|
||||
Image.asset(
|
||||
'assets/images/cashMTN.png',
|
||||
width: 70,
|
||||
height: 70,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
],
|
||||
)),
|
||||
// GestureDetector(
|
||||
// onTap: () async {
|
||||
// Get.back();
|
||||
// Get.defaultDialog(
|
||||
// barrierDismissible: false,
|
||||
// title: 'Insert Wallet phone number'.tr,
|
||||
// content: Form(
|
||||
// key: paymentController.formKey,
|
||||
// child: MyTextForm(
|
||||
// controller:
|
||||
// paymentController.walletphoneController,
|
||||
// label: 'Insert Wallet phone number'.tr,
|
||||
// hint: '963941234567',
|
||||
// type: TextInputType.phone)),
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'OK'.tr,
|
||||
// onPressed: () async {
|
||||
// Get.back();
|
||||
// if (paymentController.formKey.currentState!
|
||||
// .validate()) {
|
||||
// box.write(
|
||||
// BoxName.phoneWallet,
|
||||
// paymentController
|
||||
// .walletphoneController.text);
|
||||
// await payWithMTNWallet(
|
||||
// context, pricePoint.toString(), 'SYP');
|
||||
// }
|
||||
// }));
|
||||
// },
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text('Pay by MTN Wallet'.tr),
|
||||
// const SizedBox(width: 10),
|
||||
// Image.asset(
|
||||
// 'assets/images/cashMTN.png',
|
||||
// width: 70,
|
||||
// height: 70,
|
||||
// fit: BoxFit.fill,
|
||||
// ),
|
||||
// ],
|
||||
// )),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
@@ -210,6 +212,69 @@ class PointsCaptain extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Insert Wallet phone number'.tr,
|
||||
content: Form(
|
||||
key: paymentController.formKey,
|
||||
child: MyTextForm(
|
||||
controller:
|
||||
paymentController.walletphoneController,
|
||||
label: 'Insert Wallet phone number'.tr,
|
||||
hint: '963941234567',
|
||||
type: TextInputType.phone)),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'OK'.tr,
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
if (paymentController.formKey.currentState!
|
||||
.validate()) {
|
||||
box.write(
|
||||
BoxName.phoneWallet,
|
||||
paymentController
|
||||
.walletphoneController.text);
|
||||
// await payWithSyriaTelWallet(
|
||||
// context, pricePoint.toString(), 'SYP');
|
||||
bool isAuthSupported =
|
||||
await LocalAuthentication()
|
||||
.isDeviceSupported();
|
||||
if (isAuthSupported) {
|
||||
bool didAuthenticate =
|
||||
await LocalAuthentication()
|
||||
.authenticate(
|
||||
localizedReason:
|
||||
'استخدم بصمة الإصبع أو الوجه لتأكيد الدفع',
|
||||
);
|
||||
if (!didAuthenticate) {
|
||||
if (Get.isDialogOpen ?? false) Get.back();
|
||||
print(
|
||||
"❌ User did not authenticate with biometrics");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Get.to(() => PaymentScreenMtn(
|
||||
amount: pricePoint,
|
||||
userType: 'Driver',
|
||||
));
|
||||
}
|
||||
}));
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Pay by MTN Wallet'.tr),
|
||||
const SizedBox(width: 10),
|
||||
Image.asset(
|
||||
'assets/images/cashMTN.png',
|
||||
width: 70,
|
||||
height: 70,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
));
|
||||
},
|
||||
|
||||
@@ -1,104 +1,49 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:sefer_driver/constant/colors.dart';
|
||||
import 'package:sefer_driver/constant/style.dart';
|
||||
import 'package:sefer_driver/controller/notification/ride_available_controller.dart';
|
||||
import 'package:sefer_driver/views/widgets/my_scafold.dart';
|
||||
import 'package:sefer_driver/views/widgets/mycircular.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../controller/firebase/firbase_messge.dart';
|
||||
import '../../controller/functions/crud.dart';
|
||||
import '../../controller/home/captin/home_captain_controller.dart';
|
||||
import '../../controller/notification/ride_available_controller.dart';
|
||||
import '../../main.dart';
|
||||
import '../home/Captin/driver_map_page.dart';
|
||||
import '../widgets/my_scafold.dart';
|
||||
import '../widgets/mycircular.dart';
|
||||
import '../widgets/mydialoug.dart';
|
||||
|
||||
// --- Placeholder Classes and Variables (for demonstration) ---
|
||||
// These are dummy implementations to make the code runnable.
|
||||
// You should use your actual project files.
|
||||
|
||||
// --- End of Placeholder Classes ---
|
||||
|
||||
class AvailableRidesPage extends StatelessWidget {
|
||||
const AvailableRidesPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(RideAvailableController());
|
||||
// Use findOrPut to avoid re-creating the controller on rebuilds
|
||||
Get.lazyPut(() => RideAvailableController());
|
||||
Get.lazyPut(() => HomeCaptainController());
|
||||
|
||||
return GetBuilder<RideAvailableController>(
|
||||
builder: (rideAvailableController) {
|
||||
// rideAvailableController.sortRidesByDistance();
|
||||
// rideAvailableController.sortRidesByDistance(); // Original logic
|
||||
return MyScafolld(
|
||||
title: 'Available for rides'.tr,
|
||||
body: [
|
||||
rideAvailableController.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
:
|
||||
// : ListView.builder(
|
||||
// itemCount: rideAvailableController
|
||||
// .rideAvailableMap['message']
|
||||
// .where((rideInfo) {
|
||||
// var driverType =
|
||||
// box.read(BoxName.carTypeOfDriver).toString();
|
||||
// return (driverType == 'Comfort' &&
|
||||
// ['Speed', 'Comfort']
|
||||
// .contains(rideInfo['carType'])) ||
|
||||
// (driverType == 'Speed' &&
|
||||
// rideInfo['carType'] == 'Speed') ||
|
||||
// (driverType == 'Scooter' &&
|
||||
// rideInfo['carType'] == 'Scooter') ||
|
||||
// (driverType == 'Awfar Car' &&
|
||||
// rideInfo['carType'] == 'Awfar Car') ||
|
||||
// (driverType == 'Lady' &&
|
||||
// ['Comfort', 'Speed', 'Lady']
|
||||
// .contains(rideInfo['carType']));
|
||||
// }).length,
|
||||
// itemBuilder: (context, index) {
|
||||
// var filteredRides = rideAvailableController
|
||||
// .rideAvailableMap['message']
|
||||
// .where((rideInfo) {
|
||||
// var driverType =
|
||||
// box.read(BoxName.carTypeOfDriver).toString();
|
||||
// return (driverType == 'Comfort' &&
|
||||
// ['Speed', 'Comfort']
|
||||
// .contains(rideInfo['carType'])) ||
|
||||
// (driverType == 'Speed' &&
|
||||
// rideInfo['carType'] == 'Speed') ||
|
||||
// (driverType == 'Awfar Car' &&
|
||||
// rideInfo['carType'] == 'Awfar Car') ||
|
||||
// (driverType == 'Scooter' &&
|
||||
// rideInfo['carType'] == 'Scooter') ||
|
||||
// (driverType == 'Lady' &&
|
||||
// ['Comfort', 'Speed', 'Lady']
|
||||
// .contains(rideInfo['carType']));
|
||||
// }).toList();
|
||||
|
||||
// return RideAvailableCard(
|
||||
// rideInfo: filteredRides[index],
|
||||
// );
|
||||
// },
|
||||
// )
|
||||
ListView.builder(
|
||||
itemCount: rideAvailableController
|
||||
.rideAvailableMap['message']
|
||||
.where((rideInfo) {
|
||||
var driverType =
|
||||
box.read(BoxName.carTypeOfDriver).toString();
|
||||
switch (driverType) {
|
||||
case 'Comfort':
|
||||
return ['Speed', 'Comfort']
|
||||
.contains(rideInfo['carType']);
|
||||
case 'Speed':
|
||||
case 'Scooter':
|
||||
case 'Awfar Car':
|
||||
return rideInfo['carType'] == driverType;
|
||||
case 'Lady':
|
||||
return ['Comfort', 'Speed', 'Lady']
|
||||
.contains(rideInfo['carType']);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}).length,
|
||||
itemBuilder: (context, index) {
|
||||
var filteredRides = rideAvailableController
|
||||
: Builder(
|
||||
builder: (context) {
|
||||
// Filtering logic remains the same
|
||||
final filteredRides = rideAvailableController
|
||||
.rideAvailableMap['message']
|
||||
.where((rideInfo) {
|
||||
var driverType =
|
||||
@@ -119,21 +64,27 @@ class AvailableRidesPage extends StatelessWidget {
|
||||
}
|
||||
}).toList();
|
||||
|
||||
return RideAvailableCard(
|
||||
rideInfo: filteredRides[index],
|
||||
if (filteredRides.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
"No rides available for your vehicle type.".tr,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 16),
|
||||
itemCount: filteredRides.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RideAvailableCard(
|
||||
rideInfo: filteredRides[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
// rideAvailableController.isLoading
|
||||
// ? const MyCircularProgressIndicator()
|
||||
// : ListView.builder(
|
||||
// itemCount: rideAvailableController
|
||||
// .rideAvailableMap['message'].length,
|
||||
// itemBuilder: (context, index) => RideAvailableCard(
|
||||
// rideInfo: rideAvailableController
|
||||
// .rideAvailableMap['message'][index],
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
isleading: true);
|
||||
});
|
||||
@@ -147,90 +98,189 @@ class RideAvailableCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// The main card with improved styling
|
||||
return Card(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
elevation: 4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildLocationRow('↑', rideInfo['startName'], AppColor.greenColor),
|
||||
const SizedBox(height: 8),
|
||||
_buildLocationRow('↓', rideInfo['endName'], Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
_buildInfoRow(),
|
||||
const SizedBox(height: 16),
|
||||
_buildActionRow(),
|
||||
],
|
||||
margin: const EdgeInsets.only(bottom: 16.0),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
elevation: 5,
|
||||
shadowColor: Colors.black.withOpacity(0.1),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () {
|
||||
// You can add an action here, e.g., show ride details on a map
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
const SizedBox(height: 16),
|
||||
_buildRouteInfo(),
|
||||
const Divider(height: 32),
|
||||
_buildRideDetails(),
|
||||
const SizedBox(height: 20),
|
||||
_buildAcceptButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLocationRow(String icon, String location, Color iconColor) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
icon,
|
||||
style: TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold, color: iconColor),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
location,
|
||||
style: AppStyle.subtitle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('${'Price:'.tr} ${rideInfo['price']} \$', style: AppStyle.title),
|
||||
Text(
|
||||
rideInfo['carType'],
|
||||
style: AppStyle.title.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionRow() {
|
||||
// Header section with Price and Car Type
|
||||
Widget _buildHeader() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('📈 ${rideInfo['passengerRate']}', style: AppStyle.title),
|
||||
Text('Fare'.tr, style: AppStyle.subtitle.copyWith(fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'📍 ${rideInfo['distance']} ${'KM'.tr}',
|
||||
style: AppStyle.title.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
Text('${rideInfo['price']} \$',
|
||||
style: AppStyle.title
|
||||
.copyWith(fontSize: 24, color: AppColor.primaryColor)),
|
||||
],
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => _acceptRide(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.greenColor,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.greenColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
rideInfo['carType'],
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor, fontSize: 12),
|
||||
),
|
||||
child: Text('Accept'.tr),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Visual representation of the pickup and dropoff route
|
||||
Widget _buildRouteInfo() {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Dotted line and icons column
|
||||
Column(
|
||||
children: [
|
||||
const Icon(CupertinoIcons.circle_fill,
|
||||
color: AppColor.greenColor, size: 20),
|
||||
...List.generate(
|
||||
4,
|
||||
(index) => Container(
|
||||
height: 4,
|
||||
width: 2,
|
||||
color: AppColor.writeColor,
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
)),
|
||||
const Icon(CupertinoIcons.location_solid,
|
||||
color: Colors.red, size: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Location text column
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildLocationText(rideInfo['startName'], 'Pickup'.tr),
|
||||
const SizedBox(height: 20),
|
||||
_buildLocationText(rideInfo['endName'], 'Dropoff'.tr),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Helper for location text
|
||||
Widget _buildLocationText(String location, String label) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label, style: AppStyle.subtitle.copyWith(fontSize: 12)),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
location,
|
||||
style: AppStyle.title.copyWith(fontWeight: FontWeight.normal),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Ride details section with Distance and Passenger Rating
|
||||
Widget _buildRideDetails() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildInfoChip(
|
||||
icon: CupertinoIcons.map_pin_ellipse,
|
||||
value: '${rideInfo['distance']} ${'KM'.tr}',
|
||||
label: 'Distance'.tr,
|
||||
color: AppColor.primaryColor,
|
||||
),
|
||||
_buildInfoChip(
|
||||
icon: CupertinoIcons.star_fill,
|
||||
value: '${rideInfo['passengerRate']}',
|
||||
label: 'Rating'.tr,
|
||||
color: Colors.amber,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// A reusable chip for displaying info with an icon
|
||||
Widget _buildInfoChip(
|
||||
{required IconData icon,
|
||||
required String value,
|
||||
required String label,
|
||||
required Color color}) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(icon, color: color, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
Text(value, style: AppStyle.title),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: AppStyle.subtitle.copyWith(fontSize: 12)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// The accept button with improved styling
|
||||
Widget _buildAcceptButton() {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check_circle_outline, color: Colors.white),
|
||||
label: Text('Accept'.tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
onPressed: _acceptRide,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.greenColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
elevation: 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- Ride Acceptance Logic ---
|
||||
// This logic is copied exactly from your original code.
|
||||
void _acceptRide() async {
|
||||
var res = await CRUD().post(link: AppLink.updateStausFromSpeed, payload: {
|
||||
'id': rideInfo['id'],
|
||||
@@ -249,8 +299,6 @@ class RideAvailableCard extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
|
||||
// .then((value) {
|
||||
// var json = jsonDecode(res);
|
||||
if (res != "failure") {
|
||||
List<String> bodyToPassenger = [
|
||||
box.read(BoxName.driverID).toString(),
|
||||
@@ -276,7 +324,6 @@ class RideAvailableCard extends StatelessWidget {
|
||||
link: '${AppLink.endPoint}/driver_order/add.php',
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideInfo['id'],
|
||||
'status': 'Apply'
|
||||
});
|
||||
@@ -294,9 +341,7 @@ class RideAvailableCard extends StatelessWidget {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
"Accepted Ride".tr,
|
||||
'your ride is Accepted'.tr,
|
||||
// arguments['DriverList'][9].toString(),
|
||||
rideInfo['passengerToken'].toString(),
|
||||
// box.read(BoxName.tokenDriver).toString(),
|
||||
bodyToPassenger,
|
||||
'start.wav');
|
||||
Get.back();
|
||||
@@ -319,10 +364,7 @@ class RideAvailableCard extends StatelessWidget {
|
||||
'driverId': box.read(BoxName.driverID).toString(),
|
||||
'durationOfRideValue': rideInfo['duration'].toString(),
|
||||
'paymentAmount': rideInfo['price'].toString(),
|
||||
'paymentMethod': 'cash'.toString() == //todo fix payment method
|
||||
'true'
|
||||
? 'visa'
|
||||
: 'cash',
|
||||
'paymentMethod': 'cash'.toString() == 'true' ? 'visa' : 'cash',
|
||||
'isHaveSteps': 'startEnd'.toString(),
|
||||
'step0': ''.toString(),
|
||||
'step1': ''.toString(),
|
||||
|
||||
Reference in New Issue
Block a user