8/27/1
This commit is contained in:
78
lib/controller/home/captin/contact_us_controller.dart
Normal file
78
lib/controller/home/captin/contact_us_controller.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../functions/launch.dart';
|
||||
|
||||
class ContactUsController extends GetxController {
|
||||
final String phone1 = '+201018805430';
|
||||
final String phone2 = '+201080182934';
|
||||
final TimeOfDay workStartTime = const TimeOfDay(hour: 12, minute: 0);
|
||||
final TimeOfDay workEndTime = const TimeOfDay(hour: 19, minute: 0);
|
||||
|
||||
bool _isWithinWorkTime(TimeOfDay now) {
|
||||
return (now.hour > workStartTime.hour ||
|
||||
(now.hour == workStartTime.hour &&
|
||||
now.minute >= workStartTime.minute)) &&
|
||||
(now.hour < workEndTime.hour ||
|
||||
(now.hour == workEndTime.hour && now.minute <= workEndTime.minute));
|
||||
}
|
||||
|
||||
void showContactDialog(BuildContext context) {
|
||||
TimeOfDay now = TimeOfDay.now();
|
||||
|
||||
showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: Text('Contact Us'.tr),
|
||||
message: Text('Choose a contact option'.tr),
|
||||
actions: <Widget>[
|
||||
if (_isWithinWorkTime(now))
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(phone1),
|
||||
onPressed: () => makePhoneCall(
|
||||
phone1,
|
||||
),
|
||||
),
|
||||
if (_isWithinWorkTime(now))
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(phone2),
|
||||
onPressed: () => makePhoneCall(phone2),
|
||||
),
|
||||
if (!_isWithinWorkTime(now))
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.'
|
||||
.tr),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const Icon(
|
||||
FontAwesome.whatsapp,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
Text('Send WhatsApp Message'.tr),
|
||||
],
|
||||
),
|
||||
onPressed: () =>
|
||||
launchCommunication('whatsapp', phone1, 'Hello'.tr),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
child: Text('Send Email'.tr),
|
||||
onPressed: () =>
|
||||
launchCommunication('email', 'support@sefer.live', 'Hello'.tr),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: Text('Cancel'.tr),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MaintainCenterController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map tripCount = {};
|
||||
|
||||
Future getTripCountByCaptain() async {
|
||||
var res = await CRUD().get(link: AppLink.getTripCountByCaptain, payload: {
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
tripCount = jsonDecode(res)['message'];
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,12 +219,12 @@ class HomeCaptainController extends GetxController {
|
||||
void onInit() async {
|
||||
// await locationBackController.requestLocationPermission();
|
||||
|
||||
await addToken();
|
||||
addToken();
|
||||
await getlocation();
|
||||
onButtonSelected();
|
||||
await getDriverRate();
|
||||
await getKazanPercent();
|
||||
await getPaymentToday();
|
||||
getDriverRate();
|
||||
getKazanPercent();
|
||||
getPaymentToday();
|
||||
getCountRideToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:SEFER/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:SEFER/views/widgets/mydialoug.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
@@ -15,6 +16,7 @@ import '../../../constant/api_key.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/Rate/rate_passenger.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
@@ -169,15 +171,15 @@ class MapDriverController extends GetxController {
|
||||
|
||||
cancelTripFromDriverAfterApplied() async {
|
||||
if (formKeyCancel.currentState!.validate()) {
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
CRUD().post(link: AppLink.updateRides, payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
await CRUD().post(link: AppLink.addCancelRideFromPassenger, payload: {
|
||||
"rideID": rideId.toString(),
|
||||
"driverID": box.read(BoxName.driverID).toString(),
|
||||
"passengerID": passengerId.toString(),
|
||||
"note": cancelTripCotroller.text.toString()
|
||||
CRUD().post(link: AppLink.addCancelTripFromDriverAfterApplied, payload: {
|
||||
"order_id": rideId.toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": cancelTripCotroller.text.toString()
|
||||
});
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
"Cancel Trip from driver".tr,
|
||||
@@ -187,6 +189,12 @@ class MapDriverController extends GetxController {
|
||||
[],
|
||||
'cancel.wav',
|
||||
);
|
||||
sql.insertData({
|
||||
'order_id': rideId,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
Get.put(OrderRequestController()).getRefusedOrderByCaptain();
|
||||
Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
@@ -407,15 +415,29 @@ class MapDriverController extends GetxController {
|
||||
updateLocation();
|
||||
}
|
||||
|
||||
calculateDistanceBetweenDriverAndPassengerLocation() {
|
||||
calculateDistanceBetweenDriverAndPassengerLocation() async {
|
||||
Get.put(LocationController());
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
latLngPassengerLocation.latitude,
|
||||
latLngPassengerLocation.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
return distance2;
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getLatestLocationPassenger, payload: {'rideId': rideId});
|
||||
if (res != 'failure') {
|
||||
var passengerLatestLocationString = jsonDecode(res)['message'];
|
||||
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
double.parse(passengerLatestLocationString[0]['lat'].toString()),
|
||||
double.parse(passengerLatestLocationString[0]['lng'].toString()),
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
return distance2;
|
||||
} else {
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
latLngPassengerLocation.latitude,
|
||||
latLngPassengerLocation.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
return distance2;
|
||||
}
|
||||
}
|
||||
|
||||
addWaitingTimeCostFromPassengerToDriverWallet() async {
|
||||
|
||||
@@ -186,14 +186,14 @@ class OrderRequestController extends GetxController {
|
||||
});
|
||||
|
||||
// applied = true;
|
||||
if (box.read(BoxName.gender).toString() != 'Female') {
|
||||
sql.insertData({
|
||||
'order_id': orderID,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
getRefusedOrderByCaptain();
|
||||
}
|
||||
// if (box.read(BoxName.gender).toString() != 'Female') {
|
||||
// sql.insertData({
|
||||
// 'order_id': orderID,
|
||||
// 'created_at': DateTime.now().toString(),
|
||||
// 'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// }, TableName.driverOrdersRefuse);
|
||||
// getRefusedOrderByCaptain();
|
||||
// }
|
||||
update();
|
||||
// Get.back();
|
||||
// Get.offAll(HomeCaptain());
|
||||
|
||||
@@ -111,7 +111,7 @@ class CaptainWalletController extends GetxController {
|
||||
// isLoading = false;
|
||||
if (res != 'failure') {
|
||||
walletDate = jsonDecode(res);
|
||||
totalAmount = walletDate['message'][0]['total_amount'].toString();
|
||||
totalAmount = walletDate['message'][0]['total_amount'] ?? '0';
|
||||
update();
|
||||
var res1 = await CRUD().get(
|
||||
link: AppLink.getAllPaymentVisa,
|
||||
|
||||
Reference in New Issue
Block a user