service 2-5-26-2
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:service/constant/box_name.dart';
|
||||
import 'package:service/constant/colors.dart';
|
||||
import 'package:service/constant/links.dart';
|
||||
import 'package:service/controller/functions/crud.dart';
|
||||
@@ -49,10 +46,41 @@ class MainController extends GetxController {
|
||||
var color = ''.obs;
|
||||
var colorHex = ''.obs;
|
||||
|
||||
searchPassengerByPhone() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// refreshDashboardStats(); // Removed to save data consumption at start
|
||||
}
|
||||
|
||||
Future<void> refreshDashboardStats() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
try {
|
||||
await Future.wait<void>([
|
||||
getDriverWantCompleteRegistration(),
|
||||
getDriverNotCompleteRegistration(),
|
||||
getNewDriverRegister(),
|
||||
]);
|
||||
} catch (e) {
|
||||
Log.print('Error refreshing stats: $e');
|
||||
}
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> searchPassengerByPhone() async {
|
||||
if (formKey.currentState == null || formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
await getPassengersByPhone();
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.back();
|
||||
if (passengerData.isEmpty) {
|
||||
Get.snackbar('Error'.tr, 'Passenger not found'.tr,
|
||||
backgroundColor: Colors.red, colorText: Colors.white);
|
||||
return;
|
||||
}
|
||||
Get.to(() => PassengersPage());
|
||||
}
|
||||
}
|
||||
@@ -165,18 +193,16 @@ class MainController extends GetxController {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uri != null) {
|
||||
final ok = await canLaunchUrl(uri);
|
||||
if (ok) {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else {
|
||||
// ممكن تضيف Snackbar/Toast هنا
|
||||
}
|
||||
final ok = await canLaunchUrl(uri);
|
||||
if (ok) {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else {
|
||||
// ممكن تضيف Snackbar/Toast هنا
|
||||
}
|
||||
}
|
||||
|
||||
List driverNotCompleteRegistration = [];
|
||||
getDriverNotCompleteRegistration() async {
|
||||
Future<void> getDriverNotCompleteRegistration() async {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getDriverNotCompleteRegistration, payload: {});
|
||||
if (res != 'failure') {
|
||||
@@ -185,11 +211,12 @@ class MainController extends GetxController {
|
||||
filteredDrivers = driverNotCompleteRegistration;
|
||||
update();
|
||||
} else {
|
||||
Get.snackbar(res, '');
|
||||
driverNotCompleteRegistration = [];
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
deleteDriverNotCompleteRegistration(String phone) async {
|
||||
Future<void> deleteDriverNotCompleteRegistration(String phone) async {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.deleteDriverNotCompleteRegistration, payload: {
|
||||
'phone': phone,
|
||||
@@ -204,7 +231,7 @@ class MainController extends GetxController {
|
||||
}
|
||||
|
||||
List driverWantCompleteRegistration = [];
|
||||
getDriverWantCompleteRegistration() async {
|
||||
Future<void> getDriverWantCompleteRegistration() async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getDriversWaitingActive, payload: {});
|
||||
if (res != 'failure') {
|
||||
@@ -213,12 +240,13 @@ class MainController extends GetxController {
|
||||
filteredDrivers = driverWantCompleteRegistration;
|
||||
update();
|
||||
} else {
|
||||
Get.snackbar(res, '');
|
||||
driverWantCompleteRegistration = [];
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
List driversPhoneNotComplete = [];
|
||||
getDriversPhoneNotComplete() async {
|
||||
Future<void> getDriversPhoneNotComplete() async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getDriversPhoneNotComplete, payload: {});
|
||||
if (res != 'failure') {
|
||||
@@ -232,18 +260,19 @@ class MainController extends GetxController {
|
||||
}
|
||||
|
||||
List newDriverRegister = [];
|
||||
getNewDriverRegister() async {
|
||||
Future<void> getNewDriverRegister() async {
|
||||
var res = await CRUD().get(link: AppLink.getNewDriverRegister, payload: {});
|
||||
if (res != 'failure') {
|
||||
var d = res['message'];
|
||||
newDriverRegister = d;
|
||||
update();
|
||||
} else {
|
||||
Get.snackbar(res, '');
|
||||
newDriverRegister = [];
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
addWelcomeCall(String driveId) async {
|
||||
Future<void> addWelcomeCall(String driveId) async {
|
||||
var res = await CRUD().post(link: AppLink.addWelcomeDriverNote, payload: {
|
||||
"driverId": driveId,
|
||||
"notes": notesController.text,
|
||||
@@ -255,7 +284,7 @@ class MainController extends GetxController {
|
||||
|
||||
String selectedStatus = "I'm not ready yet".tr;
|
||||
List passengerNotCompleteRegistration = [];
|
||||
getPassengerNotCompleteRegistration() async {
|
||||
Future<void> getPassengerNotCompleteRegistration() async {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getPassengersNotCompleteRegistration, payload: {});
|
||||
if (res != 'failure') {
|
||||
@@ -463,11 +492,16 @@ class MainController extends GetxController {
|
||||
}
|
||||
|
||||
searchDriverByPhone() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
if (formKey.currentState == null || formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
await getDriverByPhone();
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.back();
|
||||
if (driverData.isEmpty) {
|
||||
Get.snackbar('Error', 'Driver not found', backgroundColor: Colors.red);
|
||||
Get.snackbar('Error'.tr, 'Driver not found'.tr,
|
||||
backgroundColor: Colors.red, colorText: Colors.white);
|
||||
return;
|
||||
}
|
||||
Get.to(() => DriverPage());
|
||||
@@ -475,11 +509,16 @@ class MainController extends GetxController {
|
||||
}
|
||||
|
||||
searchDriverByNational() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
if (formKey.currentState == null || formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
await getDriverByNational();
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.back();
|
||||
if (driverData.isEmpty) {
|
||||
Get.snackbar('Error', 'Driver not found', backgroundColor: Colors.red);
|
||||
Get.snackbar('Error'.tr, 'Driver not found'.tr,
|
||||
backgroundColor: Colors.red, colorText: Colors.white);
|
||||
return;
|
||||
}
|
||||
Get.to(() => DriverPage());
|
||||
|
||||
@@ -24,10 +24,12 @@ class DriverPage extends StatelessWidget {
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildDriverInfoSection(data),
|
||||
_buildCommunicationSection(data, context),
|
||||
_buildStatisticsSection(data),
|
||||
_buildCarInfoSection(data),
|
||||
_buildLicenseInfoSection(data),
|
||||
_buildBankInfoSection(data),
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -175,4 +177,50 @@ class DriverPage extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCommunicationSection(Map data, BuildContext context) {
|
||||
String phone = data['phone'] ?? '';
|
||||
String name = data['first_name'] ?? '';
|
||||
|
||||
return CupertinoListSection.insetGrouped(
|
||||
header: Text('Quick Communication'.tr),
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
title: Text('Call Driver'.tr),
|
||||
leading: const Icon(CupertinoIcons.phone_fill, color: Colors.green),
|
||||
onTap: () => mainController.makePhoneCall(phone),
|
||||
),
|
||||
CupertinoListTile(
|
||||
title: Text('WhatsApp: Activation'.tr),
|
||||
leading: const Icon(Icons.send, color: Colors.green),
|
||||
onTap: () => mainController.launchCommunication(
|
||||
'whatsapp',
|
||||
phone,
|
||||
'أهلاً بك يا كابتن $name في انطلق! تم تفعيل حسابك بنجاح وأصبحت مستعداً لاستقبال الرحلات.',
|
||||
),
|
||||
),
|
||||
CupertinoListTile(
|
||||
title: Text('WhatsApp: Missing Docs'.tr),
|
||||
leading: const Icon(Icons.send, color: Colors.orange),
|
||||
onTap: () => mainController.launchCommunication(
|
||||
'whatsapp',
|
||||
phone,
|
||||
'مرحباً كابتن $name، يرجى تزويدنا بالأوراق الناقصة أو غير الواضحة عبر الواتساب لإكمال تفعيل حسابك.',
|
||||
),
|
||||
),
|
||||
CupertinoListTile(
|
||||
title: Text('WhatsApp: Support'.tr),
|
||||
leading: const Icon(Icons.send, color: Colors.blue),
|
||||
onTap: () => mainController.launchCommunication(
|
||||
'whatsapp',
|
||||
phone,
|
||||
'مرحباً كابتن $name، معك الدعم الفني من شركة انطلق. كيف يمكنني مساعدتك اليوم؟',
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user