12/3/1
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../functions/crud.dart';
|
||||
|
||||
class NotificationCaptainController extends GetxController {
|
||||
bool isloading = false;
|
||||
Map notificationData = {};
|
||||
|
||||
getNotifications() async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getNotificationCaptain,
|
||||
payload: {'driverID': box.read(BoxName.driverID)});
|
||||
if (res == "failure") {
|
||||
// print(res);
|
||||
Get.defaultDialog(
|
||||
title: 'There is no notification yet'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
notificationData = jsonDecode(res);
|
||||
// sql.insertData(notificationData['message'], TableName.captainNotification);
|
||||
|
||||
// print(notificationData);
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
updateNotification(String id) async {
|
||||
await CRUD().post(
|
||||
link: AppLink.updateNotificationCaptain,
|
||||
payload: {'isShown': true, 'id': id},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getNotifications();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import 'package:ride/views/auth/captin/login_captin.dart';
|
||||
import 'package:ride/views/auth/captin/verify_email_captain.dart';
|
||||
|
||||
import '../../../views/auth/captin/ai_page.dart';
|
||||
import '../../../views/auth/captin/car_license_page.dart';
|
||||
import '../../../views/auth/verify_email_page.dart';
|
||||
|
||||
class RegisterCaptainController extends GetxController {
|
||||
@@ -76,7 +77,7 @@ class RegisterCaptainController extends GetxController {
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
Get.offAll(() => LoginCaptin());
|
||||
Get.to(() => CarLicensePage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ class RegisterCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void addLisence() async {
|
||||
Future addLisence() async {
|
||||
getFromController();
|
||||
var res = await CRUD().post(link: AppLink.addLicense, payload: {
|
||||
'name': name,
|
||||
@@ -114,7 +115,7 @@ class RegisterCaptainController extends GetxController {
|
||||
'address': address,
|
||||
'height': height,
|
||||
'postalCode': postalCode,
|
||||
'sex': sex == 'M' ? 'Male' : 'Female',
|
||||
'sex': sex,
|
||||
'stateCode': stateCode,
|
||||
'expireDate': expireDate,
|
||||
'dateOfBirth': dob,
|
||||
@@ -152,11 +153,11 @@ class RegisterCaptainController extends GetxController {
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
// Get.to(() => AiPage()); //todo replace this
|
||||
Get.offAll(() => LoginCaptin()); //todo replace this
|
||||
}
|
||||
}
|
||||
|
||||
void register() async {
|
||||
Future register() async {
|
||||
getFromController();
|
||||
if (formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
@@ -171,11 +172,11 @@ class RegisterCaptainController extends GetxController {
|
||||
'site': address,
|
||||
'birthdate': dob,
|
||||
});
|
||||
print(jsonDecode(res));
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
print('sdfffffffffff');
|
||||
box.write(BoxName.driverID, jsonDecode(res)['message']);
|
||||
box.write(BoxName.dobDriver, dob);
|
||||
box.write(BoxName.sexDriver, sex);
|
||||
box.write(BoxName.phoneDriver, phoneController.text);
|
||||
|
||||
@@ -108,7 +108,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
print('driverToken==============' + driverToken.toString());
|
||||
print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
@@ -191,12 +191,13 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
|
||||
// mapController.driverArrivePassenger();
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('isRideFinished')) {
|
||||
MapPassengerController mapController =
|
||||
Get.find<MapPassengerController>();
|
||||
} else if (message.notification!.title!
|
||||
.contains('Captain Finish Trip')) {
|
||||
// MapPassengerController mapController =
|
||||
// Get.find<MapPassengerController>();
|
||||
Get.snackbar('Ride Finished'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
mapController.isRideFinished = true;
|
||||
// mapController.isRideFinished = true;//todo fix that for dfinish ride in passenger app
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -311,8 +312,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.find<MapPassengerController>();
|
||||
mapController.rideConfirm = false;
|
||||
update();
|
||||
print('-----------------------------rideConfirm===' +
|
||||
mapController.rideConfirm.toString());
|
||||
print(
|
||||
'-----------------------------rideConfirm===${mapController.rideConfirm}');
|
||||
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
driverID = myList[2].toString();
|
||||
|
||||
@@ -26,13 +26,13 @@ class CRUD {
|
||||
// 'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
// print("-----request----" + response.request.toString());
|
||||
print("-----request----" + response.request.toString());
|
||||
// print("-----headers-----" + response.headers.toString());
|
||||
// print("-----payload-----" + payload.toString());
|
||||
print("-----payload-----" + payload.toString());
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
// print(jsonData);
|
||||
print(jsonData);
|
||||
|
||||
return response.body;
|
||||
}
|
||||
@@ -148,17 +148,17 @@ class CRUD {
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
//print(response.request);
|
||||
print(response.request);
|
||||
//print(payload);
|
||||
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
if (jsonData['status'] == 'success') {
|
||||
Get.snackbar(
|
||||
jsonData['status'],
|
||||
jsonData['message'],
|
||||
);
|
||||
//print(response.body);
|
||||
// Get.snackbar(
|
||||
// jsonData['status'],
|
||||
// jsonData['message'],
|
||||
// );
|
||||
// print(response.body);
|
||||
return response.body;
|
||||
}
|
||||
}
|
||||
@@ -192,10 +192,10 @@ class CRUD {
|
||||
if (response.statusCode == 200) {
|
||||
if (jsonData['status'] == 'success') {
|
||||
Get.back();
|
||||
Get.snackbar(
|
||||
jsonData['status'],
|
||||
jsonData['message'],
|
||||
);
|
||||
// Get.snackbar(
|
||||
// jsonData['status'],
|
||||
// jsonData['message'],
|
||||
// );
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import 'package:ride/constant/api_key.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/info.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../views/auth/captin/car_license_page.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../auth/captin/register_captin_controller.dart';
|
||||
import 'launch.dart';
|
||||
|
||||
//
|
||||
@@ -227,6 +227,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
late Uint8List imageSignature;
|
||||
late Uint8List imageDocumentFrontSide;
|
||||
XFile? image;
|
||||
XFile? imagePortraitFile;
|
||||
XFile? imageFace;
|
||||
late File tempFile;
|
||||
late String imagePath;
|
||||
@@ -327,6 +328,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
await tempFile.writeAsBytes(imagePortrait);
|
||||
|
||||
imagePath = tempFile.path;
|
||||
// imagePortraitFile=File(imagePath) ;
|
||||
update();
|
||||
} else {
|
||||
// Handle error or provide a default value
|
||||
@@ -446,7 +448,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
},
|
||||
)) //
|
||||
: Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
// barrierDismissible: false,
|
||||
title: 'Image detecting result is '.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
@@ -478,47 +480,59 @@ class ScanDocumentsByApi extends GetxController {
|
||||
: MyElevatedButton(
|
||||
title: 'Next'.tr,
|
||||
onPressed: () async {
|
||||
await uploadImage(
|
||||
tempFile, AppLink.uploadImagePortrate);
|
||||
Get.to(() => CarLicensePage());
|
||||
RegisterCaptainController registerCaptainController =
|
||||
Get.put(RegisterCaptainController());
|
||||
|
||||
await registerCaptainController.register();
|
||||
await registerCaptainController.addLisence();
|
||||
await uploadImagePortrate();
|
||||
// Get.to(() => CarLicensePage());
|
||||
},
|
||||
// {
|
||||
// await uploadImage(
|
||||
// tempFile, AppLink.uploadImagePortrate);
|
||||
// Get.to(() => CarLicensePage());
|
||||
// },
|
||||
kolor: AppColor.greenColor,
|
||||
));
|
||||
} else {
|
||||
print(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
// Todo upload images and fields
|
||||
|
||||
Future<String> uploadImage(File imageFile, String link) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
// Todo upload images and fields
|
||||
Future<String> uploadImagePortrate() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(link), //AppLink.uploadImage
|
||||
Uri.parse(AppLink.uploadImagePortrate),
|
||||
);
|
||||
|
||||
// Attach the image file to the request
|
||||
request.files.add(
|
||||
await http.MultipartFile.fromPath('image', imageFile.path),
|
||||
); // Add the headers to the request
|
||||
request.headers.addAll({
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
});
|
||||
http.MultipartFile.fromBytes('image', imagePortrait),
|
||||
);
|
||||
|
||||
request.headers.addAll({
|
||||
"Content-Type": "multipart/form-data",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
});
|
||||
request.fields['driverID'] =
|
||||
'bnbn'; // box.read(BoxName.driverID).toString();
|
||||
|
||||
// Add the driverID to the request
|
||||
request.fields['driverID'] = box.read(BoxName.driverID);
|
||||
// Send the request
|
||||
var response = await request.send();
|
||||
|
||||
// Read the response
|
||||
var responseData = await response.stream.toBytes();
|
||||
var responseString = String.fromCharCodes(responseData);
|
||||
// scannedText = responseString;
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
// Return the link received from the server
|
||||
|
||||
// Print the response string
|
||||
print(responseString);
|
||||
|
||||
return responseString;
|
||||
}
|
||||
|
||||
|
||||
93
lib/controller/home/captin/help/help_controller.dart
Normal file
93
lib/controller/home/captin/help/help_controller.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../constant/box_name.dart';
|
||||
import '../../../../constant/links.dart';
|
||||
import '../../../../constant/style.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
import '../../../functions/crud.dart';
|
||||
|
||||
class HelpController extends GetxController {
|
||||
bool isLoading = false;
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final helpQuestionController = TextEditingController();
|
||||
Map helpQuestionDate = {};
|
||||
Map helpQuestionRepleyDate = {};
|
||||
String status = '';
|
||||
String qustion = '';
|
||||
late int indexQuestion = 0;
|
||||
getindex(int i, String qustion1) async {
|
||||
indexQuestion = i;
|
||||
qustion = qustion1;
|
||||
update();
|
||||
}
|
||||
|
||||
void addHelpQuestion() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.addhelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'helpQuestion': helpQuestionController.text
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
// print(d);
|
||||
isLoading = false;
|
||||
update();
|
||||
if (d['status'].toString() == 'success') {
|
||||
getHelpQuestion();
|
||||
// Get.snackbar('Feedback data saved successfully'.tr, '',
|
||||
// backgroundColor: AppColor.greenColor,
|
||||
// snackPosition: SnackPosition.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
void getHelpQuestion() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.gethelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
if (res == "failure") {
|
||||
// print(res);
|
||||
Get.defaultDialog(
|
||||
title: 'There is no help Question here'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
helpQuestionDate = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getHelpRepley(String id) async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getByIdhelpCenter, payload: {
|
||||
'id': id,
|
||||
});
|
||||
print(res);
|
||||
if (res == "failure") {
|
||||
status = 'not yet';
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
helpQuestionRepleyDate = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getHelpQuestion();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class HomeCaptainController extends GetxController {
|
||||
|
||||
getAllPayment() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getAllPayment,
|
||||
link: AppLink.getAllPaymentFromRide,
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
|
||||
|
||||
@@ -198,12 +198,26 @@ class MapDriverController extends GetxController {
|
||||
'passengerID': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin'
|
||||
});
|
||||
rideIsBeginPassengerTimer();
|
||||
double pointsSubstraction = 0;
|
||||
pointsSubstraction = double.parse(paymentAmount) * -100;
|
||||
var res = await CRUD().post(link: AppLink.addDriversWallet, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (pointsSubstraction).toString(),
|
||||
'paymentMethod': paymentMethod,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
print('...................');
|
||||
print(d);
|
||||
print('...................');
|
||||
|
||||
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
||||
}
|
||||
@@ -225,8 +239,10 @@ class MapDriverController extends GetxController {
|
||||
'passengerId': passengerId,
|
||||
'driverId': driverId
|
||||
});
|
||||
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
// 'isRideFinished', box.read(BoxName.name).toString(), tokenPassenger);
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'Captain Finish Trip',
|
||||
box.read(BoxName.name).toString(),
|
||||
tokenPassenger);
|
||||
}
|
||||
|
||||
String canelString = '';
|
||||
|
||||
@@ -347,7 +347,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
void delayAndFetchRideStatus(String rideId) {
|
||||
Timer(const Duration(seconds: 1), () async {
|
||||
Timer(const Duration(milliseconds: 200), () async {
|
||||
if (shouldFetch) {
|
||||
// print('shouldFetch is =$shouldFetch');
|
||||
var res = await CRUD()
|
||||
@@ -357,13 +357,18 @@ class MapPassengerController extends GetxController {
|
||||
print(decod['data']);
|
||||
if (decod['data'].toString() == 'Apply') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
// rideConfirm = false;
|
||||
rideConfirm = false;
|
||||
update();
|
||||
startTimer();
|
||||
} else if (decod['data'].toString() == 'Refused') {
|
||||
if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||
carsOrder++;
|
||||
update();
|
||||
carsOrder = carsOrder + 1;
|
||||
update();
|
||||
print(dataCarsLocationByPassenger['message'].length);
|
||||
print(dataCarsLocationByPassenger['message']);
|
||||
print(carsOrder);
|
||||
|
||||
if (carsOrder < dataCarsLocationByPassenger['message'].length) {
|
||||
print('55555555555555555555');
|
||||
changeConfirmRide();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
@@ -374,7 +379,7 @@ class MapPassengerController extends GetxController {
|
||||
onPressed: () => Get.offAll(const MapPagePassenger()),
|
||||
));
|
||||
|
||||
// cancelRide();
|
||||
cancelRideAfterRejectFromAll();
|
||||
}
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
@@ -548,6 +553,26 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> cancelRideAfterRejectFromAll() async {
|
||||
clearPlaces();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isPassengerChosen = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
changeCancelRidePageShow();
|
||||
remainingTime = 0;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
print("rideConfirm=$rideConfirm");
|
||||
|
||||
@@ -558,8 +583,9 @@ class MapPassengerController extends GetxController {
|
||||
changeCancelRidePageShow();
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
update();
|
||||
} else {
|
||||
@@ -573,6 +599,7 @@ class MapPassengerController extends GetxController {
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isPassengerChosen = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
changeCancelRidePageShow();
|
||||
|
||||
73
lib/controller/home/payment/captain_wallet_controller.dart
Normal file
73
lib/controller/home/payment/captain_wallet_controller.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/main.dart';
|
||||
|
||||
class CaptainWalletController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map walletDate = {};
|
||||
Map walletDriverPointsDate = {};
|
||||
final formKey = GlobalKey<FormState>();
|
||||
String totalAmount = '0';
|
||||
String totalPoints = '0';
|
||||
Future getCaptainWalletFromRide() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getAllPaymentFromRide,
|
||||
payload: {'driverID': box.read(BoxName.driverID)},
|
||||
);
|
||||
walletDate = jsonDecode(res);
|
||||
totalAmount = walletDate['message'][0]['total_amount'].toString() == null
|
||||
? '0'
|
||||
: walletDate['message'][0]['total_amount'];
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getCaptainWalletFromBuyPoints() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverPaymentPoints,
|
||||
payload: {'driverID': box.read(BoxName.driverID)},
|
||||
);
|
||||
walletDriverPointsDate = jsonDecode(res);
|
||||
totalPoints =
|
||||
walletDriverPointsDate['message'][0]['total_amount'].toString();
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
late String paymentID;
|
||||
Future addDriverPayment(String paymentMethod, amount) async {
|
||||
var res = await CRUD().post(link: AppLink.addDriverPaymentPoints, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'amount': amount.toString(),
|
||||
'payment_method': paymentMethod.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
paymentID = d['message'].toString();
|
||||
// print(paymentID);
|
||||
}
|
||||
|
||||
Future addDriverWallet(String paymentMethod, point) async {
|
||||
await CRUD().post(link: AppLink.addDriversWallet, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'paymentID': paymentID.toString(),
|
||||
'amount': point,
|
||||
'paymentMethod': paymentMethod.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getCaptainWalletFromRide();
|
||||
getCaptainWalletFromBuyPoints();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,6 @@ class CreditCardController extends GetxController {
|
||||
String? expiryDate = await SecureStorage().readData(BoxName.expiryDate);
|
||||
String? cvvCode = await SecureStorage().readData(BoxName.cvvCode);
|
||||
|
||||
print('cardNumber: $cardNumber');
|
||||
print('cardHolderName: $cardHolderName');
|
||||
print('expiryDate: $expiryDate');
|
||||
print('cvvCode: $cvvCode');
|
||||
|
||||
if (cvvCode != null && cvvCode.isNotEmpty) {
|
||||
final maskedCardNumber = DigitObscuringFormatter()
|
||||
.formatEditUpdate(
|
||||
@@ -32,8 +27,6 @@ class CreditCardController extends GetxController {
|
||||
)
|
||||
.text;
|
||||
|
||||
print('maskedCardNumber: $maskedCardNumber');
|
||||
|
||||
cardNumberController.text = maskedCardNumber;
|
||||
cardHolderNameController.text = cardHolderName ?? '';
|
||||
expiryDateController.text = expiryDate ?? '';
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:flutter_paypal/flutter_paypal.dart';
|
||||
import 'package:flutter_stripe/flutter_stripe.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/controller/home/map_passenger_controller.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
@@ -53,16 +52,51 @@ class PaymentController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void onChangedPaymentMethodWallet(bool? value) {
|
||||
isWalletChecked = !isWalletChecked;
|
||||
isWalletChecked ? isCashChecked = false : isCashChecked = true;
|
||||
addPassengerWallet() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
// double sallaryAccountNowBeforeAdding =
|
||||
// double.parse(box.read(BoxName.passengerWalletTotal).toString());
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': selectedAmount.toString()
|
||||
}).then((value) {
|
||||
getPassengerWallet();
|
||||
// sallaryAccountNowBeforeAdding = sallaryAccountNowBeforeAdding +
|
||||
// double.parse(selectedAmount.toString());
|
||||
// box.write(BoxName.passengerWalletTotal, sallaryAccountNowBeforeAdding);
|
||||
});
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
void onChangedPaymentMethodWallet(bool? value) {
|
||||
if (box.read(BoxName.passengerWalletTotal) == null ||
|
||||
double.parse(box.read(BoxName.passengerWalletTotal).toString()) <
|
||||
totalPassenger) {
|
||||
isWalletChecked = false;
|
||||
isWalletChecked ? isCashChecked = true : isCashChecked = true;
|
||||
update();
|
||||
} else {
|
||||
isWalletChecked = !isWalletChecked;
|
||||
isWalletChecked ? isCashChecked = false : isCashChecked = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void onChangedPaymentMethodCash(bool? value) {
|
||||
isCashChecked = !isCashChecked;
|
||||
isCashChecked ? isWalletChecked = false : isWalletChecked = true;
|
||||
update();
|
||||
if (box.read(BoxName.passengerWalletTotal) == null ||
|
||||
double.parse(box.read(BoxName.passengerWalletTotal)) < totalPassenger) {
|
||||
isWalletChecked = false;
|
||||
isCashChecked = !isCashChecked;
|
||||
isCashChecked ? isWalletChecked = false : isWalletChecked = false;
|
||||
update();
|
||||
} else {
|
||||
isCashChecked = !isCashChecked;
|
||||
isCashChecked ? isWalletChecked = false : isWalletChecked = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void applyPromoCodeToPassenger() async {
|
||||
@@ -120,6 +154,72 @@ class PaymentController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initializePaymentSheet(String clientSecret) async {
|
||||
await Stripe.instance.initPaymentSheet(
|
||||
paymentSheetParameters: SetupPaymentSheetParameters(
|
||||
// intentConfiguration: IntentConfiguration.fromJson({}),
|
||||
// applePay: const PaymentSheetApplePay(merchantCountryCode: 'US'),
|
||||
// googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US'),
|
||||
paymentIntentClientSecret: clientSecret,
|
||||
merchantDisplayName: 'Sefer',
|
||||
billingDetails: BillingDetails(
|
||||
name: box.read(BoxName.nameDriver) == null
|
||||
? box.read(BoxName.name).toString()
|
||||
: box.read(BoxName.nameDriver).toString(),
|
||||
email: box.read(BoxName.emailDriver) == null
|
||||
? box.read(BoxName.email).toString()
|
||||
: box.read(BoxName.emailDriver).toString(),
|
||||
phone: box.read(BoxName.phoneDriver) == null
|
||||
? box.read(BoxName.phone).toString()
|
||||
: box.read(BoxName.phoneDriver).toString(),
|
||||
address: const Address(
|
||||
city: 'city',
|
||||
country: 'United States',
|
||||
line1: '',
|
||||
line2: '',
|
||||
postalCode: '12345',
|
||||
state: 'Boston')),
|
||||
allowsDelayedPaymentMethods: true,
|
||||
customerEphemeralKeySecret: Stripe.merchantIdentifier,
|
||||
appearance: const PaymentSheetAppearance(
|
||||
shapes: PaymentSheetShape(borderRadius: 12),
|
||||
colors: PaymentSheetAppearanceColors(
|
||||
background: AppColor.secondaryColor,
|
||||
),
|
||||
),
|
||||
billingDetailsCollectionConfiguration:
|
||||
const BillingDetailsCollectionConfiguration(
|
||||
name: CollectionMode.always,
|
||||
phone: CollectionMode.always,
|
||||
email: CollectionMode.always,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> getClientSecret(String amount, currency) async {
|
||||
var res = await CRUD().postStripe(
|
||||
link: 'https://api.stripe.com/v1/payment_intents',
|
||||
payload: {'amount': amount, 'currency': currency},
|
||||
);
|
||||
|
||||
// Convert the res object to a JSON object
|
||||
final jsonResponse = jsonDecode(res);
|
||||
print(jsonResponse);
|
||||
// Check if the client_secret property exists and is not null
|
||||
if (jsonResponse.containsKey('client_secret') &&
|
||||
jsonResponse['client_secret'] != null) {
|
||||
// Return the client_secret property
|
||||
return jsonResponse['client_secret'] as String;
|
||||
} else {
|
||||
throw Exception('Failed to fetch client secret');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> configure3dSecureFuture() async {
|
||||
await Stripe.instance.openApplePaySetup();
|
||||
}
|
||||
|
||||
Future<void> makePaymentPayPal(BuildContext context) async {
|
||||
try {
|
||||
// Check if local authentication is available
|
||||
@@ -189,12 +289,7 @@ class PaymentController extends GetxController {
|
||||
note: "Contact us for any questions on your order.",
|
||||
onSuccess: (Map params) async {
|
||||
print("onSuccess: $params");
|
||||
await CRUD()
|
||||
.post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id':
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
'balance': selectedAmount.toString()
|
||||
});
|
||||
addPassengerWallet();
|
||||
changePromoSheetDialogue();
|
||||
await getPassengerWallet();
|
||||
},
|
||||
@@ -223,44 +318,6 @@ class PaymentController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initializePaymentSheet(String clientSecret) async {
|
||||
await Stripe.instance.initPaymentSheet(
|
||||
paymentSheetParameters: SetupPaymentSheetParameters(
|
||||
paymentIntentClientSecret: clientSecret,
|
||||
merchantDisplayName: 'Sefer',
|
||||
billingDetails: BillingDetails(
|
||||
name: box.read(BoxName.nameDriver).toString(),
|
||||
email: box.read(BoxName.emailDriver).toString(),
|
||||
phone: box.read(BoxName.phoneDriver).toString(),
|
||||
),
|
||||
billingDetailsCollectionConfiguration:
|
||||
const BillingDetailsCollectionConfiguration(
|
||||
name: CollectionMode.always,
|
||||
phone: CollectionMode.always,
|
||||
email: CollectionMode.always,
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> getClientSecret(String amount, currency) async {
|
||||
var res = await CRUD().postStripe(
|
||||
link: 'https://api.stripe.com/v1/payment_intents',
|
||||
payload: {'amount': amount, 'currency': currency},
|
||||
);
|
||||
|
||||
// Convert the res object to a JSON object
|
||||
final jsonResponse = jsonDecode(res);
|
||||
print(jsonResponse);
|
||||
// Check if the client_secret property exists and is not null
|
||||
if (jsonResponse.containsKey('client_secret') &&
|
||||
jsonResponse['client_secret'] != null) {
|
||||
// Return the client_secret property
|
||||
return jsonResponse['client_secret'] as String;
|
||||
} else {
|
||||
throw Exception('Failed to fetch client secret');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getPassengerWallet();
|
||||
|
||||
41
lib/controller/profile/captain_profile_controller.dart
Normal file
41
lib/controller/profile/captain_profile_controller.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/main.dart';
|
||||
|
||||
class CaptainProfileController extends GetxController {
|
||||
bool isLoading = false;
|
||||
TextEditingController vin = TextEditingController();
|
||||
TextEditingController color = TextEditingController();
|
||||
TextEditingController make = TextEditingController();
|
||||
TextEditingController model = TextEditingController();
|
||||
TextEditingController year = TextEditingController();
|
||||
TextEditingController expirationDate = TextEditingController();
|
||||
|
||||
Future updateFields() async {
|
||||
var res = await CRUD().post(link: AppLink.updateRegisrationCar, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': vin.text,
|
||||
'color': color.text,
|
||||
'model': model.text,
|
||||
'make': make.text,
|
||||
'year': year.text,
|
||||
'expirationDate': expirationDate.text,
|
||||
});
|
||||
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
box.write(BoxName.vin, vin.text);
|
||||
box.write(BoxName.color, color.text);
|
||||
box.write(BoxName.model, model.text);
|
||||
box.write(BoxName.make, make.text);
|
||||
box.write(BoxName.year, year.text);
|
||||
box.write(BoxName.expirationDate, expirationDate.text);
|
||||
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user