Initial commit for service
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:service/constant/colors.dart';
|
||||
import 'package:service/constant/style.dart';
|
||||
@@ -12,21 +13,35 @@ class WelcomeCall extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(MainController());
|
||||
final controller = Get.put(MainController());
|
||||
|
||||
return MyScaffold(
|
||||
title: 'Welcome Drivers'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
GetBuilder<MainController>(builder: (mainController) {
|
||||
return Expanded(
|
||||
child: CupertinoScrollbar(
|
||||
child: ListView.builder(
|
||||
itemCount: mainController.newDriverRegister.length,
|
||||
itemBuilder: (context, index) {
|
||||
final driver = mainController.newDriverRegister[index];
|
||||
return DriverCard(driver: driver);
|
||||
},
|
||||
final drivers = mainController.newDriverRegister;
|
||||
|
||||
if (drivers.isEmpty) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(32.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'No new drivers found.',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return CupertinoScrollbar(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
itemCount: drivers.length,
|
||||
itemBuilder: (context, index) {
|
||||
final driver = drivers[index];
|
||||
return DriverCard(driver: driver);
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
@@ -39,9 +54,22 @@ class DriverCard extends StatelessWidget {
|
||||
final Map<String, dynamic> driver;
|
||||
|
||||
const DriverCard({super.key, required this.driver});
|
||||
Widget buildActionButton({
|
||||
required IconData icon,
|
||||
required Color color,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
onPressed: onPressed,
|
||||
child: Icon(icon, color: color, size: 28),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = Get.find<MainController>();
|
||||
|
||||
return CupertinoCard(
|
||||
margin: const EdgeInsets.all(16.0),
|
||||
child: Padding(
|
||||
@@ -49,38 +77,37 @@ class DriverCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// حالة التلوين حسب isCall
|
||||
Container(
|
||||
decoration: AppStyle.boxDecoration1.copyWith(
|
||||
color: driver['isCall'].toString() == '1'
|
||||
? AppColor.greenColor
|
||||
: AppColor.accentColor),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
|
||||
child: Text(
|
||||
'Driver Information'.tr,
|
||||
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
|
||||
),
|
||||
color: driver['isCall'].toString() == '1'
|
||||
? AppColor.greenColor
|
||||
: AppColor.accentColor,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
child: Text(
|
||||
'Driver Information'.tr,
|
||||
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
InfoText('Name'.tr, driver['name_arabic'].toString()),
|
||||
InfoText('Phone'.tr, driver['phone'].toString()),
|
||||
InfoText('Email'.tr, driver['email'].toString()),
|
||||
InfoText('License Type'.tr, driver['license_type'].toString()),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
InfoText(
|
||||
'License Categories'.tr, driver['license_categories'] ?? ''),
|
||||
InfoText(
|
||||
'National Number'.tr, driver['national_number'].toString()),
|
||||
InfoText('Occupation'.tr, driver['occupation'].toString()),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Notes:'.tr,
|
||||
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
|
||||
),
|
||||
'Name'.tr, driver['first_name'] + ' ' + driver['last_name']),
|
||||
InfoText('Phone'.tr, driver['phone']),
|
||||
InfoText('Email'.tr, driver['email']),
|
||||
InfoText('License Type'.tr, driver['license_type']),
|
||||
InfoText('License Categories'.tr, driver['license_categories']),
|
||||
InfoText('National Number'.tr, driver['national_number']),
|
||||
InfoText('Occupation'.tr, driver['occupation']),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Text('Notes:'.tr,
|
||||
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CupertinoTextField(
|
||||
controller: Get.find<MainController>().notesController,
|
||||
controller: controller.notesController,
|
||||
placeholder: driver['notes'] ?? 'Enter notes here...'.tr,
|
||||
maxLines: 3,
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
@@ -89,25 +116,55 @@ class DriverCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Get.width * .4,
|
||||
child: MyElevatedButton(
|
||||
title: 'Call Driver'.tr,
|
||||
onPressed: () {
|
||||
Get.find<MainController>()
|
||||
.makePhoneCall(driver['phone'].toString());
|
||||
})),
|
||||
CupertinoButton(
|
||||
onPressed: () async {
|
||||
await Get.find<MainController>().addWelcomeCall(
|
||||
driver['id'].toString(),
|
||||
);
|
||||
},
|
||||
child: Text('Save Changes'.tr),
|
||||
Expanded(
|
||||
child: MyElevatedButton(
|
||||
title: 'Call Driver'.tr,
|
||||
onPressed: () {
|
||||
controller.makePhoneCall(driver['phone'].toString());
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: CupertinoButton(
|
||||
onPressed: () async {
|
||||
await controller.addWelcomeCall(driver['id'].toString());
|
||||
},
|
||||
child: Text('Save Changes'.tr),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CupertinoButton(
|
||||
onPressed: () async {
|
||||
final phone = driver['phone'];
|
||||
|
||||
if (phone == null || phone.toString().isEmpty) {
|
||||
Get.snackbar("خطأ", "لا يوجد رقم هاتف لهذا السائق");
|
||||
return;
|
||||
}
|
||||
|
||||
String message = "مرحباً،\n\n"
|
||||
"يعطيك العافية أستاذ. نرحب بك في شركة *انطلق* للنقل الذكي.\n"
|
||||
"نود تعريفك بالتطبيق ومميزاته لتتمكن من الاستفادة الكاملة وبدء العمل معنا بسهولة.\n\n"
|
||||
"لأي استفسار أو مساعدة، يمكنك التواصل معنا على الأرقام التالية:\n\n"
|
||||
"+963 952 475 742\n"
|
||||
"+963 952 475 740\n"
|
||||
"+963 952 475 734\n\n"
|
||||
"فريق انطلق يتمنى لك تجربة موفقة ويوم سعيد.";
|
||||
|
||||
Get.find<MainController>().launchCommunication(
|
||||
'whatsapp',
|
||||
phone,
|
||||
message,
|
||||
);
|
||||
},
|
||||
child: Text('send'.tr),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -120,16 +177,17 @@ class DriverCard extends StatelessWidget {
|
||||
|
||||
class InfoText extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
final dynamic value;
|
||||
|
||||
const InfoText(this.label, this.value, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final display = value?.toString() ?? 'N/A';
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||
child: Text(
|
||||
'$label: $value',
|
||||
'$label: $display',
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user