4/4/1
This commit is contained in:
@@ -150,6 +150,7 @@ class OrderRequestController extends GetxController {
|
||||
String passengerRate,
|
||||
String priceForPassenger,
|
||||
String distance,
|
||||
String duration,
|
||||
) async {
|
||||
await CRUD().post(link: AppLink.addWaitingRide, payload: {
|
||||
'id': orderID,
|
||||
@@ -164,6 +165,7 @@ class OrderRequestController extends GetxController {
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,8 @@ class OrderRequestPage extends StatelessWidget {
|
||||
myList[31].toString(),
|
||||
myList[33].toString(),
|
||||
myList[2].toString(),
|
||||
myList[5].toString());
|
||||
myList[5].toString(),
|
||||
myList[4].toString());
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:SEFER/controller/notification/ride_available_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:SEFER/views/widgets/mycircular.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../controller/firebase/firbase_messge.dart';
|
||||
import '../../controller/functions/crud.dart';
|
||||
import '../../main.dart';
|
||||
import '../home/Captin/driver_map_page.dart';
|
||||
|
||||
class AvailableRidesPage extends StatelessWidget {
|
||||
const AvailableRidesPage({super.key});
|
||||
|
||||
@@ -19,55 +30,198 @@ class AvailableRidesPage extends StatelessWidget {
|
||||
body: [
|
||||
rideAvailableController.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: ListView.builder(
|
||||
itemCount:
|
||||
rideAvailableController.rideAvalibleMap['data'].length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var list = rideAvailableController.rideAvalibleMap['data']
|
||||
[index];
|
||||
return Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
'Price: ${list['start_location']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Price: ${list['end_location']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.builder(
|
||||
itemCount: rideAvailableController
|
||||
.rideAvalibleMap['message'].length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var list = rideAvailableController
|
||||
.rideAvalibleMap['message'][index];
|
||||
return Container(
|
||||
width: Get.width * .9,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('${'Price:'.tr}${list['price']} \$'),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${list['carType']}',
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor),
|
||||
' ${list['start_location']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'${list['end_location']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('${'Price: '.tr}${list['price']} \$'),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${list['carType']}',
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('📈 ${list['passengerRate']}',
|
||||
style: AppStyle.title),
|
||||
MyElevatedButton(
|
||||
title: 'Accept'.tr,
|
||||
onPressed: () async {
|
||||
box.write(
|
||||
BoxName.statusDriverLocation, 'on');
|
||||
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.updateStausFromSpeed,
|
||||
payload: {
|
||||
'id': list['id'],
|
||||
'rideTimeStart':
|
||||
DateTime.now().toString(),
|
||||
'status': 'Apply',
|
||||
'driver_id':
|
||||
box.read(BoxName.driverID),
|
||||
});
|
||||
// .then((value) {
|
||||
// var json = jsonDecode(res);
|
||||
print('res $res');
|
||||
if (res == "failure") {
|
||||
Get.defaultDialog(
|
||||
title:
|
||||
"This ride is already taken by another driver."
|
||||
.tr,
|
||||
middleText: '',
|
||||
titleStyle: AppStyle.title,
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
} else if (jsonDecode(res)['status'] ==
|
||||
"success") {
|
||||
List<String> bodyToPassenger = [
|
||||
box
|
||||
.read(BoxName.driverID)
|
||||
.toString(),
|
||||
box
|
||||
.read(BoxName.nameDriver)
|
||||
.toString(),
|
||||
box
|
||||
.read(BoxName.tokenDriver)
|
||||
.toString(),
|
||||
];
|
||||
await CRUD().postFromDialogue(
|
||||
link: AppLink.addDriverOrder,
|
||||
payload: {
|
||||
'driver_id':
|
||||
box.read(BoxName.driverID),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': list['id'],
|
||||
'status': 'Apply'
|
||||
});
|
||||
// print(bodyToPassenger);
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToPassengerToken(
|
||||
'Apply Ride',
|
||||
'your ride is applied'.tr,
|
||||
// arguments['DriverList'][9].toString(),
|
||||
list['passengerToken'].toString(),
|
||||
// box.read(BoxName.tokenDriver).toString(),
|
||||
bodyToPassenger,
|
||||
);
|
||||
Get.back();
|
||||
Get.to(
|
||||
() => PassengerLocationMapPage(),
|
||||
arguments: {
|
||||
'passengerLocation':
|
||||
list['start_location']
|
||||
.toString(),
|
||||
'passengerDestination':
|
||||
list['end_location']
|
||||
.toString(),
|
||||
'Duration':
|
||||
list['duration'].toString(),
|
||||
'totalCost':
|
||||
list['price'].toString(),
|
||||
'Distance':
|
||||
list['distance'].toString(),
|
||||
'name': list['first_name']
|
||||
.toString(),
|
||||
'phone':
|
||||
list['phone'].toString(),
|
||||
'email':
|
||||
list['email'].toString(),
|
||||
'WalletChecked':
|
||||
list['payment_method']
|
||||
.toString(),
|
||||
'tokenPassenger':
|
||||
list['passengerToken']
|
||||
.toString(),
|
||||
'direction':
|
||||
'https://www.google.com/maps/dir/${list['start_location']}/${list['end_location']}/',
|
||||
'DurationToPassenger':
|
||||
list['duration'].toString(),
|
||||
'rideId': list['id'].toString(),
|
||||
'passengerId':
|
||||
list['passenger_id']
|
||||
.toString(),
|
||||
'driverId': box
|
||||
.read(BoxName.driverID)
|
||||
.toString(),
|
||||
'durationOfRideValue':
|
||||
list['duration'].toString(),
|
||||
'paymentAmount':
|
||||
list['price'].toString(),
|
||||
'paymentMethod':
|
||||
'cash'.toString() == //todo fix payment method
|
||||
'true'
|
||||
? 'visa'
|
||||
: 'cash',
|
||||
'isHaveSteps':
|
||||
'startEnd'.toString(),
|
||||
'step0': ''.toString(),
|
||||
'step1': ''.toString(),
|
||||
'step2': ''.toString(),
|
||||
'step3': ''.toString(),
|
||||
'step4': ''.toString(),
|
||||
'passengerWalletBurc':
|
||||
list['bruc'].toString(),
|
||||
'timeOfOrder':
|
||||
DateTime.now().toString(),
|
||||
'totalPassenger':
|
||||
list['price'].toString(),
|
||||
'carType':
|
||||
list['carType'].toString(),
|
||||
'kazan': Get.find<
|
||||
HomeCaptainController>()
|
||||
.kazan
|
||||
.toString(),
|
||||
});
|
||||
}
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
Text(
|
||||
'📍 ${list['distance']} ${'KM'.tr}',
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('📈 ${list['passengerRate']}',
|
||||
style: AppStyle.title),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'📍 ${list['distance']}${'KM'.tr}',
|
||||
style: AppStyle.title
|
||||
.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
})
|
||||
);
|
||||
}),
|
||||
)
|
||||
],
|
||||
isleading: true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user