Initial commit for intaleq_admin
This commit is contained in:
@@ -1,223 +1,302 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
// تأكد من استيراد مكتبة الاتصال إذا أردت تفعيل زر الاتصال فعلياً
|
||||
// import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/admin/captain_admin_controller.dart';
|
||||
import '../../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../controller/functions/launch.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
import '../../widgets/mycircular.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/admin/captain_admin_controller.dart';
|
||||
import 'captain_details.dart';
|
||||
import 'form_captain.dart';
|
||||
|
||||
class Captain extends StatelessWidget {
|
||||
Captain({super.key});
|
||||
final CaptainAdminController captainAdminController =
|
||||
class CaptainsPage extends StatelessWidget {
|
||||
CaptainsPage({super.key});
|
||||
|
||||
final CaptainAdminController captainController =
|
||||
Get.put(CaptainAdminController());
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
// 🔴 هام جداً: قم بتغيير هذا المتغير بناءً على حالة تسجيل الدخول الحقيقية في تطبيقك
|
||||
// مثال: bool isAdmin = Get.find<AuthController>().isAdmin;
|
||||
// final bool isAdmin = true; // اجعلها false لتجربة وضع المستخدم العادي
|
||||
String myPhone = box.read(BoxName.adminPhone).toString();
|
||||
|
||||
// 2. تحديد من هو "السوبر أدمن" الذي يرى كل شيء
|
||||
// يمكنك إضافة المزيد من الأرقام هنا باستخدام || أو قائمة
|
||||
bool isSuperAdmin = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
isSuperAdmin = myPhone == '963942542053' || myPhone == '963992952235';
|
||||
|
||||
return MyScafolld(
|
||||
title: 'Captain'.tr,
|
||||
body: [
|
||||
GetBuilder<CaptainAdminController>(
|
||||
builder: (captainAdminController) => Column(
|
||||
children: [
|
||||
captainAdminController.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
captainAdmin(
|
||||
captainAdminController,
|
||||
'Captains Count',
|
||||
'countPassenger',
|
||||
),
|
||||
MyElevatedButton(
|
||||
title: 'Add Prize to Gold Captains',
|
||||
onPressed: () {
|
||||
var date = DateTime.now();
|
||||
var day = date.weekday;
|
||||
|
||||
if (day == 6) {
|
||||
// Saturday is 6
|
||||
Get.defaultDialog(
|
||||
title:
|
||||
'Add Prize to Gold Captains',
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
'Add Points to their wallet as prize'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Form(
|
||||
key: captainAdminController
|
||||
.formCaptainPrizeKey,
|
||||
child: MyTextForm(
|
||||
controller:
|
||||
captainAdminController
|
||||
.captainPrizeController,
|
||||
label:
|
||||
'Count of prize'
|
||||
.tr,
|
||||
hint: 'Count of prize'
|
||||
.tr,
|
||||
type: TextInputType
|
||||
.number))
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add',
|
||||
onPressed: () async {
|
||||
if (captainAdminController
|
||||
.formCaptainPrizeKey
|
||||
.currentState!
|
||||
.validate()) {
|
||||
captainAdminController
|
||||
.addCaptainsPrizeToWalletSecure();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title:
|
||||
'This day is not allowed',
|
||||
titleStyle: AppStyle.title,
|
||||
middleText:
|
||||
'Saturday only Allowed day',
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
//todo search
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Container(
|
||||
width: Get.width,
|
||||
height: 110,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: AppColor.greenColor)),
|
||||
child: formSearchCaptain()
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: Get.height * .5,
|
||||
child: ListView.builder(
|
||||
itemCount: captainAdminController
|
||||
.captainData['message'].length,
|
||||
itemBuilder: (context, index) {
|
||||
final user = captainAdminController
|
||||
.captainData['message'][index];
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Get.to(const CaptainsDetailsPage(),
|
||||
arguments: {
|
||||
'data': user,
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 2)),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Name : ${(user['first_name'])} ${(user['last_name'])}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Rating : ${user['ratingPassenger']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Count Trip : ${user['countPassengerRide']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Count Driver Rate : ${user['countDriverRate']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
))
|
||||
],
|
||||
title: 'Search for Captain'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height, // لضمان أخذ المساحة
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
// --- شريط البحث المحسن ---
|
||||
_buildSearchSection(context),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- قائمة النتائج ---
|
||||
Expanded(
|
||||
child: GetBuilder<CaptainAdminController>(
|
||||
builder: (controller) {
|
||||
if (controller.isLoading) {
|
||||
return const Center(child: MyCircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (controller.captainData['message'] == null ||
|
||||
controller.captainData['message'].isEmpty) {
|
||||
return _buildEmptyState();
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: controller.captainData['message'].length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
final captain =
|
||||
controller.captainData['message'][index];
|
||||
return _buildCaptainCard(context, captain);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// مساحة إضافية في الأسفل لتجنب تداخل المحتوى مع الحواف
|
||||
const SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Container captainAdmin(CaptainAdminController captainAdminController,
|
||||
String title, String jsonField) {
|
||||
// --- ودجت البحث ---
|
||||
Widget _buildSearchSection(BuildContext context) {
|
||||
return Container(
|
||||
height: Get.height * .1,
|
||||
decoration: BoxDecoration(border: Border.all(width: 2)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {},
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
title.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
captainAdminController.captainData['message'][0][jsonField]
|
||||
.toString(),
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: MyTextForm(
|
||||
controller: searchController,
|
||||
label: 'Captain Phone Number'.tr,
|
||||
hint: 'Enter phone number...'.tr,
|
||||
type: TextInputType.phone,
|
||||
// يمكنك إزالة الحواف من الـ TextField الأصلي إذا أردت ليتناسب مع الكونتينر
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.search, size: 28, color: Colors.white),
|
||||
onPressed: () {
|
||||
final phone = searchController.text;
|
||||
if (phone.isNotEmpty) {
|
||||
captainController.find_driver_by_phone(phone);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'Error'.tr,
|
||||
'Please enter a phone number to search.'.tr,
|
||||
backgroundColor: Colors.red.withOpacity(0.8),
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- بطاقة الكابتن المحسنة ---
|
||||
Widget _buildCaptainCard(BuildContext context, dynamic captain) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.08),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () {
|
||||
Get.to(() => const CaptainDetailsPage(),
|
||||
arguments: {'data': captain});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// صورة الكابتن أو أيقونة
|
||||
CircleAvatar(
|
||||
radius: 28,
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor.withOpacity(0.1),
|
||||
child: Icon(
|
||||
Icons.person,
|
||||
color: Theme.of(context).primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
|
||||
// المعلومات النصية
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// الاسم
|
||||
Text(
|
||||
'${captain['first_name']} ${captain['last_name']}',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// رقم الهاتف (مع المنطق)
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.phone_iphone,
|
||||
size: 14, color: Colors.grey[600]),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_formatPhoneNumber(captain['phone'].toString()),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[700],
|
||||
fontFamily:
|
||||
'monospace', // لجعل الأرقام والنجوم متناسقة
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// الإيميل (يظهر فقط للأدمن)
|
||||
if (isSuperAdmin && captain['email'] != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.email_outlined,
|
||||
size: 14, color: Colors.grey[600]),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
captain['email'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// أزرار الإجراءات
|
||||
Column(
|
||||
children: [
|
||||
// زر الاتصال (فقط للأدمن)
|
||||
if (isSuperAdmin)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
// منطق الاتصال
|
||||
makePhoneCall('+' + captain['phone']);
|
||||
// Get.snackbar(
|
||||
// 'Call', 'Calling ${captain['phone']}...');
|
||||
},
|
||||
icon: const Icon(Icons.call, color: Colors.green),
|
||||
tooltip: 'Call Captain',
|
||||
),
|
||||
|
||||
if (!isSuperAdmin)
|
||||
const Icon(Icons.arrow_forward_ios,
|
||||
size: 16, color: Colors.grey),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- دالة تنسيق الرقم (المنطق المطلوب) ---
|
||||
String _formatPhoneNumber(String phone) {
|
||||
if (isSuperAdmin) {
|
||||
return phone; // للأدمن: إظهار الرقم كاملاً
|
||||
} else {
|
||||
// للمستخدم العادي: إظهار آخر 4 أرقام فقط
|
||||
if (phone.length <= 4) return phone;
|
||||
String lastFour = phone.substring(phone.length - 4);
|
||||
String maskedPart = '*' * (phone.length - 4);
|
||||
return '$maskedPart$lastFour'; // النتيجة: *******1234
|
||||
}
|
||||
}
|
||||
|
||||
// --- تصميم الحالة الفارغة ---
|
||||
Widget _buildEmptyState() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.search_off_rounded, size: 80, color: Colors.grey[300]),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'No captains found.'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +1,404 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/admin/captain_admin_controller.dart';
|
||||
import '../../../controller/firebase/firbase_messge.dart';
|
||||
import '../../../main.dart'; // Import main to access myPhone
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
import 'form_captain.dart';
|
||||
|
||||
class CaptainsDetailsPage extends StatelessWidget {
|
||||
const CaptainsDetailsPage({super.key});
|
||||
class CaptainDetailsPage extends StatelessWidget {
|
||||
const CaptainDetailsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final arguments = Get.arguments;
|
||||
final Map<String, dynamic> data = arguments['data'];
|
||||
var key = Get.find<CaptainAdminController>().formCaptainPrizeKey;
|
||||
var titleNotify = Get.find<CaptainAdminController>().titleNotify;
|
||||
var bodyNotify = Get.find<CaptainAdminController>().bodyNotify;
|
||||
final Map<String, dynamic> data = Get.arguments['data'];
|
||||
final controller = Get.find<CaptainAdminController>();
|
||||
String myPhone = box.read(BoxName.adminPhone).toString();
|
||||
|
||||
// Define Super Admin Logic
|
||||
final bool isSuperAdmin =
|
||||
myPhone == '963942542053' || myPhone == '963992952235';
|
||||
|
||||
return MyScafolld(
|
||||
title: data['first_name'] + ' ' + data['last_name'],
|
||||
title: 'Captain Profile'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 40),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Email is ${data['email']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Phone is ${data['phone']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'gender is ${data['gender']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'status is ${data['status']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'birthdate is ${data['birthdate']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'site is ${data['site']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
// Text(
|
||||
// 'sosPhone is ${data['sosPhone']}',
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Count Feedback is ${data['countFeedback']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Count Driver Rate is ${data['countDriverRate']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Count Cancel is ${data['countPassengerCancel']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Count Ride is ${data['countPassengerRide']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Rating Captain Avarage is ${data['passengerAverageRating']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'Rating is ${data['ratingPassenger']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 3, color: AppColor.yellowColor)),
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
Get.defaultDialog(
|
||||
title: 'Send Notification'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Form(
|
||||
key: key,
|
||||
child: Column(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: titleNotify,
|
||||
label: 'title'.tr,
|
||||
hint: 'title notificaton'.tr,
|
||||
type: TextInputType.name),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyTextForm(
|
||||
controller: bodyNotify,
|
||||
label: 'body'.tr,
|
||||
hint: 'body notificaton'.tr,
|
||||
type: TextInputType.name)
|
||||
],
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Send',
|
||||
onPressed: () {
|
||||
if (key.currentState!.validate()) {
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToAnyWithoutData(
|
||||
titleNotify.text,
|
||||
bodyNotify.text,
|
||||
data['passengerToken'],
|
||||
'order.wav');
|
||||
Get.back();
|
||||
}
|
||||
}));
|
||||
},
|
||||
child: Text(
|
||||
"Send Notificaion to Captains ".tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
// --- Header Section (Avatar & Name) ---
|
||||
_buildHeaderSection(context, data),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
// --- Personal Information Card ---
|
||||
_buildInfoCard(
|
||||
title: 'Personal Information',
|
||||
icon: Icons.person,
|
||||
children: [
|
||||
_buildDetailTile(
|
||||
Icons.email_outlined,
|
||||
'Email',
|
||||
isSuperAdmin
|
||||
? data['email']
|
||||
: _maskEmail(
|
||||
data['email']) // Mask email for non-super
|
||||
),
|
||||
_buildDetailTile(
|
||||
Icons.phone_iphone,
|
||||
'Phone',
|
||||
_formatPhoneNumber(
|
||||
data['phone'].toString(), isSuperAdmin)),
|
||||
_buildDetailTile(Icons.transgender, 'Gender',
|
||||
data['gender'] ?? 'Not specified'),
|
||||
_buildDetailTile(Icons.cake_outlined, 'Birthdate',
|
||||
data['birthdate'] ?? 'N/A'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// --- Ride Statistics Card ---
|
||||
_buildInfoCard(
|
||||
title: 'Performance & Stats',
|
||||
icon: Icons.bar_chart_rounded,
|
||||
children: [
|
||||
_buildDetailTile(Icons.star_rate_rounded, 'Rating',
|
||||
'${data['ratingPassenger'] ?? 0.0} / 5.0',
|
||||
valueColor: Colors.amber[700]),
|
||||
_buildDetailTile(Icons.directions_car_filled_outlined,
|
||||
'Total Rides', data['countPassengerRide']),
|
||||
_buildDetailTile(Icons.cancel_outlined,
|
||||
'Canceled Rides', data['countPassengerCancel'],
|
||||
valueColor: Colors.redAccent),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// --- Action Buttons ---
|
||||
_buildActionButtons(
|
||||
context, controller, data, isSuperAdmin),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
isleading: true,
|
||||
);
|
||||
}
|
||||
|
||||
// --- Header with Gradient Background ---
|
||||
Widget _buildHeaderSection(BuildContext context, Map<String, dynamic> data) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 25),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 5),
|
||||
)
|
||||
],
|
||||
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(30)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 45,
|
||||
backgroundColor: AppColor.primaryColor.withOpacity(0.1),
|
||||
child: Text(
|
||||
data['first_name'] != null
|
||||
? data['first_name'][0].toUpperCase()
|
||||
: 'C',
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primaryColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'${data['first_name']} ${data['last_name']}',
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
'Active Captain'.tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoCard(
|
||||
{required String title,
|
||||
required IconData icon,
|
||||
required List<Widget> children}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.05),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 10)
|
||||
],
|
||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(icon, color: AppColor.primaryColor, size: 22),
|
||||
const SizedBox(width: 10),
|
||||
Text(title.tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
Divider(height: 25, color: Colors.grey.withOpacity(0.2)),
|
||||
...children,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailTile(IconData icon, String label, dynamic value,
|
||||
{Color? valueColor}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
child: Icon(icon, color: Colors.grey[600], size: 18),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label.tr,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[500])),
|
||||
Text(
|
||||
value?.toString() ?? 'N/A',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: valueColor ?? Colors.black87),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButtons(
|
||||
BuildContext context,
|
||||
CaptainAdminController controller,
|
||||
Map<String, dynamic> data,
|
||||
bool isSuperAdmin) {
|
||||
return Column(
|
||||
children: [
|
||||
// Notification is available for everyone
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.notifications_active_outlined,
|
||||
color: Colors.white),
|
||||
label: Text("Send Notification".tr,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: () => _showSendNotificationDialog(controller, data),
|
||||
),
|
||||
),
|
||||
|
||||
// Edit and Delete ONLY for Super Admin
|
||||
if (isSuperAdmin) ...[
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.edit_note_rounded, size: 20),
|
||||
label: Text("Edit".tr),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: AppColor.yellowColor,
|
||||
elevation: 0,
|
||||
side: BorderSide(color: AppColor.yellowColor),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: () {
|
||||
Get.to(() => const FormCaptain(), arguments: {
|
||||
'isEditMode': true,
|
||||
'captainData': data,
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.delete_outline_rounded, size: 20),
|
||||
label: Text("Delete".tr),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red[50],
|
||||
foregroundColor: Colors.red,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: () => _showDeleteConfirmation(data),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
] else ...[
|
||||
// Message for normal admins
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Only Super Admins can edit or delete captains.",
|
||||
style: TextStyle(
|
||||
color: Colors.grey[400],
|
||||
fontSize: 12,
|
||||
fontStyle: FontStyle.italic),
|
||||
)
|
||||
]
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// --- Helper Methods ---
|
||||
|
||||
String _formatPhoneNumber(String phone, bool isSuperAdmin) {
|
||||
if (isSuperAdmin) return phone;
|
||||
if (phone.length <= 4) return phone;
|
||||
return '${'*' * (phone.length - 4)}${phone.substring(phone.length - 4)}';
|
||||
}
|
||||
|
||||
String _maskEmail(String? email) {
|
||||
if (email == null || email.isEmpty) return 'N/A';
|
||||
int atIndex = email.indexOf('@');
|
||||
if (atIndex <= 1) return email; // Too short to mask
|
||||
return '${email.substring(0, 2)}****${email.substring(atIndex)}';
|
||||
}
|
||||
|
||||
void _showSendNotificationDialog(
|
||||
CaptainAdminController controller, Map<String, dynamic> data) {
|
||||
Get.defaultDialog(
|
||||
title: 'Send Notification'.tr,
|
||||
titleStyle: const TextStyle(fontWeight: FontWeight.bold),
|
||||
content: Form(
|
||||
key: controller.formCaptainPrizeKey,
|
||||
child: Column(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: controller.titleNotify,
|
||||
label: 'Title'.tr,
|
||||
hint: 'Enter notification title'.tr,
|
||||
type: TextInputType.text,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextForm(
|
||||
controller: controller.bodyNotify,
|
||||
label: 'Body'.tr,
|
||||
hint: 'Enter message body'.tr,
|
||||
type: TextInputType.text,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
confirm: SizedBox(
|
||||
width: 100,
|
||||
child: MyElevatedButton(
|
||||
title: 'Send',
|
||||
onPressed: () {
|
||||
// Check if key is valid (might be recreated)
|
||||
if (controller.formCaptainPrizeKey.currentState?.validate() ??
|
||||
true) {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
controller.titleNotify.text,
|
||||
controller.bodyNotify.text,
|
||||
data['passengerToken'] ?? '', // Safety check
|
||||
'order.wav');
|
||||
Get.back();
|
||||
Get.snackbar("Success", "Notification Sent",
|
||||
backgroundColor: Colors.green.withOpacity(0.2));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
cancel: TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text('Cancel'.tr, style: const TextStyle(color: Colors.grey))),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmation(Map<String, dynamic> user) {
|
||||
Get.defaultDialog(
|
||||
title: 'Confirm Deletion'.tr,
|
||||
titleStyle:
|
||||
const TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold),
|
||||
middleText:
|
||||
'Are you sure you want to delete ${user['first_name']}? This action cannot be undone.'
|
||||
.tr,
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.redAccent),
|
||||
onPressed: () {
|
||||
// Call delete function here
|
||||
// controller.deleteCaptain(user['id']);
|
||||
Get.back();
|
||||
Get.snackbar("Deleted", "Captain has been removed",
|
||||
backgroundColor: Colors.red.withOpacity(0.2));
|
||||
},
|
||||
child: Text('Delete'.tr, style: const TextStyle(color: Colors.white)),
|
||||
),
|
||||
cancel: TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text('Cancel'.tr, style: const TextStyle(color: Colors.grey))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
81
lib/views/admin/captain/driver_details_not_active_page.dart
Normal file
81
lib/views/admin/captain/driver_details_not_active_page.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../controller/drivers/driver_not_active_controller.dart';
|
||||
|
||||
class DriverDetailsPage extends StatelessWidget {
|
||||
final String driverId;
|
||||
final DriverController controller = Get.find();
|
||||
|
||||
DriverDetailsPage({super.key, required this.driverId});
|
||||
|
||||
/// Helper function to safely get String values from dynamic map
|
||||
String safeVal(Map d, String key) {
|
||||
final v = d[key];
|
||||
if (v == null || v == false) return '';
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.getDriverDetails(driverId);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Driver Details")),
|
||||
body: GetBuilder<DriverController>(
|
||||
id: 'driverDetails',
|
||||
builder: (c) {
|
||||
if (c.driverDetails.isEmpty) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final d = c.driverDetails['driver'] as Map;
|
||||
final docs = c.driverDetails['documents'] as List;
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Name: ${safeVal(d, 'first_name')} ${safeVal(d, 'last_name')}"),
|
||||
Text("Phone: ${safeVal(d, 'phone')}"),
|
||||
Text("Email: ${safeVal(d, 'email')}"),
|
||||
Text("National Number: ${safeVal(d, 'national_number')}"),
|
||||
Text("Gender: ${safeVal(d, 'gender')}"),
|
||||
Text("Birthdate: ${safeVal(d, 'birthdate')}"),
|
||||
Text("Status: ${safeVal(d, 'status')}"),
|
||||
Text("License Type: ${safeVal(d, 'license_type')}"),
|
||||
Text("License Categories: ${safeVal(d, 'license_categories')}"),
|
||||
Text("Issue Date: ${safeVal(d, 'issue_date')}"),
|
||||
Text("Expiry Date: ${safeVal(d, 'expiry_date')}"),
|
||||
Text("Address: ${safeVal(d, 'address')}"),
|
||||
Text("Site: ${safeVal(d, 'site')}"),
|
||||
Text("Employment Type: ${safeVal(d, 'employmentType')}"),
|
||||
Text("Marital Status: ${safeVal(d, 'maritalStatus')}"),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Documents:",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 8),
|
||||
...docs.map((doc) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(safeVal(doc, "doc_type")),
|
||||
const SizedBox(height: 4),
|
||||
Image.network(
|
||||
safeVal(doc, "link"),
|
||||
height: 200,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (ctx, err, st) =>
|
||||
const Icon(Icons.broken_image),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,122 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import 'package:sefer_admin1/controller/functions/crud.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/admin/captain_admin_controller.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import 'captain_details.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
|
||||
GetBuilder<CaptainAdminController> formSearchCaptain() {
|
||||
// DbSql sql = DbSql.instance;
|
||||
return GetBuilder<CaptainAdminController>(
|
||||
builder: (controller) => Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Container(
|
||||
decoration:
|
||||
const BoxDecoration(color: AppColor.secondaryColor),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.only(),
|
||||
gapPadding: 4,
|
||||
borderSide: BorderSide(
|
||||
color: AppColor.redColor,
|
||||
width: 2,
|
||||
)),
|
||||
suffixIcon: InkWell(
|
||||
onTap: () async {
|
||||
if (controller.captainController.text.length > 4) {
|
||||
await controller.getCaptains();
|
||||
class FormCaptain extends StatefulWidget {
|
||||
const FormCaptain({super.key});
|
||||
|
||||
Get.defaultDialog(
|
||||
title: controller.captain['message'][0]
|
||||
['email'],
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Name is ${controller.captain['message'][0]['first_name']} ${controller.captain['message'][0]['last_name']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'phone is ${controller.captain['message'][0]['phone']}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Go To Details'.tr,
|
||||
onPressed: () {
|
||||
Get.to(
|
||||
() => const CaptainsDetailsPage(),
|
||||
arguments: {
|
||||
'data': controller
|
||||
.captain['message'][0],
|
||||
});
|
||||
}));
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.search)),
|
||||
hintText: 'Search for Passenger'.tr,
|
||||
hintStyle: AppStyle.title,
|
||||
hintMaxLines: 1,
|
||||
prefixIcon: IconButton(
|
||||
onPressed: () async {
|
||||
controller.captainController.clear();
|
||||
// controller.clearPlaces();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red[300],
|
||||
),
|
||||
),
|
||||
),
|
||||
controller: controller.captainController,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
@override
|
||||
State<FormCaptain> createState() => _FormCaptainState();
|
||||
}
|
||||
|
||||
class _FormCaptainState extends State<FormCaptain> {
|
||||
final CaptainAdminController controller = Get.find();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
late TextEditingController firstNameController;
|
||||
late TextEditingController lastNameController;
|
||||
late TextEditingController phoneController;
|
||||
|
||||
bool isEditMode = false;
|
||||
Map<String, dynamic>? captainData;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (Get.arguments != null && Get.arguments['isEditMode'] == true) {
|
||||
isEditMode = true;
|
||||
captainData = Get.arguments['captainData'];
|
||||
firstNameController =
|
||||
TextEditingController(text: captainData?['first_name'] ?? '');
|
||||
lastNameController =
|
||||
TextEditingController(text: captainData?['last_name'] ?? '');
|
||||
phoneController =
|
||||
TextEditingController(text: captainData?['phone'] ?? '');
|
||||
} else {
|
||||
firstNameController = TextEditingController();
|
||||
lastNameController = TextEditingController();
|
||||
phoneController = TextEditingController();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
firstNameController.dispose();
|
||||
lastNameController.dispose();
|
||||
phoneController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _saveForm() async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Create a map of the updated data
|
||||
Map<String, dynamic> updatedData = {
|
||||
'id': captainData?['id'], // Important for the WHERE clause in SQL
|
||||
// 'first_name': firstNameController.text,
|
||||
// 'last_name': lastNameController.text,
|
||||
'phone': phoneController.text,
|
||||
};
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.updateDriverFromAdmin, payload: updatedData);
|
||||
|
||||
if (res != 'failure') {
|
||||
print('Updating data: $updatedData');
|
||||
|
||||
Get.back(); // Go back after saving
|
||||
Get.snackbar('Success', 'Captain data updated successfully!');
|
||||
}
|
||||
// controller.updateCaptain(updatedData);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyScafolld(
|
||||
title: 'Edit Captain'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: firstNameController,
|
||||
label: 'First Name'.tr,
|
||||
hint: 'Enter first name'.tr,
|
||||
type: TextInputType.name,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
MyTextForm(
|
||||
controller: lastNameController,
|
||||
label: 'Last Name'.tr,
|
||||
hint: 'Enter last name'.tr,
|
||||
type: TextInputType.name,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
MyTextForm(
|
||||
controller: phoneController,
|
||||
label: 'Phone Number'.tr,
|
||||
hint: 'Enter phone number'.tr,
|
||||
type: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
MyElevatedButton(
|
||||
title: 'Update'.tr,
|
||||
onPressed: _saveForm,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
54
lib/views/admin/captain/syrian_driver_not_active.dart
Normal file
54
lib/views/admin/captain/syrian_driver_not_active.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
import 'package:sefer_admin1/constant/box_name.dart';
|
||||
|
||||
import '../../../constant/info.dart';
|
||||
import '../../../constant/char_map.dart';
|
||||
|
||||
import '../../../controller/drivers/driver_not_active_controller.dart';
|
||||
import '../../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../print.dart';
|
||||
import 'driver_details_not_active_page.dart';
|
||||
|
||||
class DriversPendingPage extends StatelessWidget {
|
||||
final DriverController controller = Get.put(DriverController());
|
||||
|
||||
DriversPendingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.getDriversPending();
|
||||
Log.print(
|
||||
': ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}');
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Drivers Pending")),
|
||||
body: GetBuilder<DriverController>(
|
||||
id: 'drivers',
|
||||
builder: (c) {
|
||||
if (c.drivers.isEmpty) {
|
||||
return Center(
|
||||
child: const Text('no drivers found yet',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: c.drivers.length,
|
||||
itemBuilder: (ctx, i) {
|
||||
final d = c.drivers[i];
|
||||
return ListTile(
|
||||
title: Text(d["first_name"] + d['last_name'] ?? ""),
|
||||
subtitle: Text(d["phone"] ?? ""),
|
||||
onTap: () {
|
||||
Get.to(() => DriverDetailsPage(driverId: d["id"].toString()));
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user