Initial commit for service
This commit is contained in:
@@ -12,465 +12,485 @@ import 'package:service/views/widgets/elevated_btn.dart';
|
||||
import 'package:service/views/widgets/my_dialog.dart';
|
||||
import 'package:service/views/widgets/my_textField.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../controller/mainController/pages/add_car.dart';
|
||||
import '../../controller/mainController/pages/contact_page.dart';
|
||||
import '../../controller/mainController/pages/drivers_cant_register.dart';
|
||||
import '../../controller/mainController/pages/new_driver.dart';
|
||||
import '../../controller/mainController/pages/welcome_call.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../widgets/my_scafold.dart';
|
||||
|
||||
// --- Service Item Model ---
|
||||
// A helper class to structure the data for each service card.
|
||||
// This makes the code cleaner and easier to manage.
|
||||
class ServiceItem {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
|
||||
ServiceItem({required this.title, required this.icon, required this.onTap});
|
||||
}
|
||||
|
||||
// --- Main Screen Widget (Redesigned) ---
|
||||
class Main extends StatelessWidget {
|
||||
Main({super.key});
|
||||
MainController mainController = Get.put(MainController());
|
||||
|
||||
final MainController mainController = Get.put(MainController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyScaffold(title: 'Sefer Service'.tr, isleading: false, body: [
|
||||
ListView(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'insert passenger phone'.tr,
|
||||
'midTitle',
|
||||
Column(
|
||||
children: [
|
||||
Form(
|
||||
key: mainController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: mainController.passengerPhoneController,
|
||||
label: 'insert passenger phone'.tr,
|
||||
hint: 'insert passenger phone'.tr,
|
||||
type: TextInputType.phone,
|
||||
)),
|
||||
],
|
||||
),
|
||||
() {
|
||||
mainController.searchPassengerByPhone();
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'passenger details by phone'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
// --- List of Services ---
|
||||
// All services are defined here in a list. This makes it easy to add, remove, or reorder them.
|
||||
// The original onTap logic is preserved exactly as it was.
|
||||
final List<ServiceItem> services = [
|
||||
ServiceItem(
|
||||
title: 'passenger details by phone'.tr,
|
||||
icon: Icons.person_search_rounded,
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'insert passenger phone'.tr,
|
||||
'midTitle',
|
||||
Column(children: [
|
||||
Form(
|
||||
key: mainController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: mainController.passengerPhoneController,
|
||||
label: 'insert passenger phone'.tr,
|
||||
hint: 'insert passenger phone'.tr,
|
||||
type: TextInputType.phone,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'insert Driver phone'.tr,
|
||||
'midTitle',
|
||||
Column(
|
||||
children: [
|
||||
Form(
|
||||
key: mainController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: mainController.driverPhoneController,
|
||||
label: 'insert Driver phone'.tr,
|
||||
hint: 'insert Driver phone'.tr,
|
||||
type: TextInputType.phone,
|
||||
)),
|
||||
],
|
||||
),
|
||||
() {
|
||||
mainController.searchDriverByPhone();
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Driver details by phone'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
]),
|
||||
() => mainController.searchPassengerByPhone(),
|
||||
);
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Driver details by phone'.tr,
|
||||
icon: Icons.support_agent_rounded,
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'insert Driver phone'.tr,
|
||||
'midTitle',
|
||||
Column(children: [
|
||||
Form(
|
||||
key: mainController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: mainController.driverPhoneController,
|
||||
label: 'insert Driver phone'.tr,
|
||||
hint: 'insert Driver phone'.tr,
|
||||
type: TextInputType.phone,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getDriverNotCompleteRegistration();
|
||||
Get.to(() => DriversCantRegister());
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Drivers Cant Register'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
]),
|
||||
() => mainController.searchDriverByPhone(),
|
||||
);
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Driver details by national number'.tr,
|
||||
icon: Icons.support_agent_rounded,
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'insert Driver national'.tr,
|
||||
'midTitle',
|
||||
Column(children: [
|
||||
Form(
|
||||
key: mainController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: mainController.driverPhoneController,
|
||||
label: 'insert Driver national'.tr,
|
||||
hint: 'insert Driver national'.tr,
|
||||
type: TextInputType.number,
|
||||
),
|
||||
),
|
||||
]),
|
||||
() => mainController.searchDriverByNational(),
|
||||
);
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Drivers waitting Register'.tr,
|
||||
icon: Icons.pending_actions_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getDriverWantCompleteRegistration();
|
||||
Get.to(() => DriversCantRegister());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Register new driver'.tr,
|
||||
icon: Icons.person,
|
||||
onTap: () {
|
||||
// await mainController.getDriverWantCompleteRegistration();
|
||||
Get.to(() => RegisterCaptain());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Drivers Cant Register'.tr,
|
||||
icon: Icons.car_crash,
|
||||
onTap: () async {
|
||||
await mainController.getDriverNotCompleteRegistration();
|
||||
Get.to(() => DriversCantRegister());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Drivers phones not register'.tr,
|
||||
icon: Icons.person,
|
||||
onTap: () async {
|
||||
await mainController.getDriversPhoneNotComplete();
|
||||
Get.to(() => DriversCantRegister());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Drivers Activity'.tr,
|
||||
icon: Icons.person,
|
||||
onTap: () async {
|
||||
await mainController.getDriversPhoneNotComplete();
|
||||
Get.to(() => DriversCantRegister());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Passengers Cant Register'.tr,
|
||||
icon: Icons.group_off_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getPassengerNotCompleteRegistration();
|
||||
Get.to(() => PassengersCantRegister());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Add car'.tr,
|
||||
icon: Icons.add_circle_outline_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getdriverWithoutCar();
|
||||
if (mainController.driverWithoutCar.isNotEmpty) {
|
||||
Get.to(() => const AddCar());
|
||||
}
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: 'Edit car plate'.tr,
|
||||
icon: Icons.edit_note_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getCarPlateNotEdit();
|
||||
if (mainController.carPlateNotEdit.isNotEmpty) {
|
||||
Get.to(() => const EditCarPlate());
|
||||
}
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: "View complaint".tr,
|
||||
icon: Icons.report_problem_rounded,
|
||||
onTap: () {
|
||||
Get.to(() => const Complaint());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: "Welcome call".tr,
|
||||
icon: Icons.ring_volume_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getNewDriverRegister();
|
||||
Get.to(() => const WelcomeCall());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: "best driver".tr,
|
||||
icon: Icons.emoji_events_rounded,
|
||||
onTap: () async {
|
||||
await mainController.getNewDriverRegister();
|
||||
Get.to(() => DriverTheBest());
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: "Add Driver Who Wants to Work".tr,
|
||||
icon: Icons.person_add_alt_1_rounded,
|
||||
onTap: () {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Add Driver Who Wants to Work".tr,
|
||||
content: SizedBox(
|
||||
width: Get.width * .7,
|
||||
height: 300,
|
||||
child: Form(
|
||||
key: mainController.formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: mainController.driverNameController,
|
||||
label: 'Insert Name of Driver'.tr,
|
||||
hint: 'Insert Name of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.nationalIdController,
|
||||
label: 'Insert national ID of Driver'.tr,
|
||||
hint: 'Insert national ID of Driver'.tr,
|
||||
type: TextInputType.number),
|
||||
MyTextForm(
|
||||
controller: mainController.phoneController,
|
||||
label: 'Insert phone of Driver'.tr,
|
||||
hint: 'Insert phone of Driver'.tr,
|
||||
type: TextInputType.phone),
|
||||
MyTextForm(
|
||||
controller: mainController.licenseTypeController,
|
||||
label: 'Insert license type of Driver'.tr,
|
||||
hint: 'Insert license type of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.siteDriverController,
|
||||
label: 'Insert site of Driver'.tr,
|
||||
hint: 'Insert site of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.birthDateController,
|
||||
label: 'Insert birth_date of Driver'.tr,
|
||||
hint: 'Insert license type of Driver'.tr,
|
||||
type: TextInputType.number),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getPassengerNotCompleteRegistration();
|
||||
Get.to(() => PassengersCantRegister());
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Passengers Cant Register'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add'.tr,
|
||||
onPressed: () async {
|
||||
// if (mainController.formKey.currentState!.validate()) {
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.addDriverWantWork, payload: {
|
||||
"driver_name": mainController.driverNameController.text,
|
||||
"national_id": mainController.nationalIdController.text,
|
||||
"birth_date": mainController.birthDateController.text,
|
||||
"site": mainController.siteDriverController.text,
|
||||
"license_type": mainController.licenseTypeController.text,
|
||||
"phone": mainController.phoneController.text,
|
||||
});
|
||||
if (res != 'failure') {
|
||||
Get.back();
|
||||
mainController.driverNameController.clear();
|
||||
mainController.nationalIdController.clear();
|
||||
mainController.birthDateController.clear();
|
||||
mainController.licenseTypeController.clear();
|
||||
mainController.siteDriverController.clear();
|
||||
mainController.phoneController.clear();
|
||||
Get.snackbar('done', '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
// }
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getdriverWithoutCar();
|
||||
if (mainController.driverWithoutCar.isNotEmpty) {
|
||||
Get.to(() => const AddCar());
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Add car'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Cancel'.tr,
|
||||
kolor: AppColor.redColor,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
ServiceItem(
|
||||
title: "Add Car Who Wants to Work".tr,
|
||||
icon: Icons.directions_car_filled_rounded,
|
||||
onTap: () {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Add Car Who Wants to Work".tr,
|
||||
content: SizedBox(
|
||||
width: Get.width * .7,
|
||||
height: 300,
|
||||
child: Form(
|
||||
key: mainController.formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: mainController.carOwnerWorkController,
|
||||
label: 'Insert Name of Owner'.tr,
|
||||
hint: 'Insert Name of Owner'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.carNumberController,
|
||||
label: 'Insert car_number of Driver'.tr,
|
||||
hint: 'Insert car_number of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.phoneCarController,
|
||||
label: 'Insert phone of Owner'.tr,
|
||||
hint: 'Insert phone of Owner'.tr,
|
||||
type: TextInputType.phone),
|
||||
MyTextForm(
|
||||
controller: mainController.manufactureYearController,
|
||||
label: 'Insert year of Car'.tr,
|
||||
hint: 'Insert year of Car'.tr,
|
||||
type: TextInputType.number),
|
||||
MyTextForm(
|
||||
controller: mainController.carModelController,
|
||||
label: 'Insert car_model of Driver'.tr,
|
||||
hint: 'Insert car_model of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.siteCarController,
|
||||
label: 'Insert site of Owner'.tr,
|
||||
hint: 'Insert site of Owner'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.carTypeController,
|
||||
label: 'Insert car_type of Driver'.tr,
|
||||
hint: 'Insert car_type of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.registrationDateController,
|
||||
label: 'Insert registration_date of Car'.tr,
|
||||
hint: 'Insert registration_date of Car'.tr,
|
||||
type: TextInputType.datetime),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getCarPlateNotEdit();
|
||||
if (mainController.carPlateNotEdit.isNotEmpty) {
|
||||
Get.to(() => const EditCarPlate());
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Edit car plate'.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add'.tr,
|
||||
onPressed: () async {
|
||||
// if (mainController.formKey.currentState!.validate()) {
|
||||
var res =
|
||||
await CRUD().post(link: AppLink.addCarWantWork, payload: {
|
||||
"owner_name": mainController.carOwnerWorkController.text,
|
||||
"car_number": mainController.carNumberController.text,
|
||||
"manufacture_year":
|
||||
mainController.manufactureYearController.text,
|
||||
"car_model": mainController.carModelController.text,
|
||||
"car_type": mainController.carTypeController.text,
|
||||
"site": mainController.siteCarController.text,
|
||||
"registration_date":
|
||||
mainController.registrationDateController.text,
|
||||
"phone": mainController.phoneCarController.text,
|
||||
});
|
||||
Log.print('res: ${res}');
|
||||
if (res != 'failure') {
|
||||
Get.back();
|
||||
mainController.ownerController.clear();
|
||||
mainController.carNumberController.clear();
|
||||
mainController.manufactureYearController.clear();
|
||||
mainController.carModelController.clear();
|
||||
mainController.siteCarController.clear();
|
||||
mainController.carTypeController.clear();
|
||||
mainController.registrationDateController.clear();
|
||||
mainController.phoneController.clear();
|
||||
Get.snackbar('done', '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
// }
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Cancel'.tr,
|
||||
kolor: AppColor.redColor,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
// --- Building the UI ---
|
||||
return MyScaffold(
|
||||
title: 'Intaleq Service'.tr,
|
||||
isleading: false,
|
||||
action: MyElevatedButton(
|
||||
title: 'Logout'.tr,
|
||||
onPressed: () async {
|
||||
// box.write(BoxName.employeename, 'masa');
|
||||
print(box.read(BoxName.employeename).toString());
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
// The body now uses a GridView for a better layout.
|
||||
// You can replace the color with your main theme color.
|
||||
// backgroundColor: const Color(0xFFF5F7FA),
|
||||
body: [
|
||||
GridView.builder(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
itemCount: services.length,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2, // Two columns
|
||||
crossAxisSpacing: 16.0, // Horizontal space between cards
|
||||
mainAxisSpacing: 16.0, // Vertical space between cards
|
||||
childAspectRatio: 1.1, // Adjust card shape (width/height ratio)
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
// await mainController.getCarPlateNotEdit();
|
||||
// if (mainController.carPlateNotEdit.isNotEmpty) {
|
||||
Get.to(() => const Complaint());
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"View complaint".tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getNewDriverRegister();
|
||||
// if (mainController.carPlateNotEdit.isNotEmpty) {
|
||||
Get.to(() => const WelcomeCall());
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Welcome call".tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await mainController.getNewDriverRegister();
|
||||
// if (mainController.carPlateNotEdit.isNotEmpty) {
|
||||
Get.to(() => DriverTheBest());
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"best driver".tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Add Driver Who Wants to Work".tr,
|
||||
content: SizedBox(
|
||||
width: Get.width * .7,
|
||||
height: 300,
|
||||
child: Form(
|
||||
key: mainController.formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: mainController.driverNameController,
|
||||
label: 'Insert Name of Driver'.tr,
|
||||
hint: 'Insert Name of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.nationalIdController,
|
||||
label: 'Insert national ID of Driver'.tr,
|
||||
hint: 'Insert national ID of Driver'.tr,
|
||||
type: TextInputType.number),
|
||||
MyTextForm(
|
||||
controller: mainController.phoneController,
|
||||
label: 'Insert phone of Driver'.tr,
|
||||
hint: 'Insert phone of Driver'.tr,
|
||||
type: TextInputType.phone),
|
||||
MyTextForm(
|
||||
controller: mainController.licenseTypeController,
|
||||
label: 'Insert license type of Driver'.tr,
|
||||
hint: 'Insert license type of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.siteDriverController,
|
||||
label: 'Insert site of Driver'.tr,
|
||||
hint: 'Insert site of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.birthDateController,
|
||||
label: 'Insert birth_date of Driver'.tr,
|
||||
hint: 'Insert license type of Driver'.tr,
|
||||
type: TextInputType.number),
|
||||
],
|
||||
)),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add'.tr,
|
||||
onPressed: () async {
|
||||
if (mainController.formKey.currentState!.validate()) {
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.addDriverWantWork, payload: {
|
||||
"driver_name": mainController.driverNameController.text,
|
||||
"national_id": mainController.nationalIdController.text,
|
||||
"birth_date": mainController.birthDateController.text,
|
||||
"site": mainController.siteDriverController.text,
|
||||
"license_type":
|
||||
mainController.licenseTypeController.text,
|
||||
"phone": mainController.phoneController.text,
|
||||
});
|
||||
if (res != 'failure') {
|
||||
Get.back();
|
||||
mainController.driverNameController.clear();
|
||||
mainController.nationalIdController.clear();
|
||||
mainController.birthDateController.clear();
|
||||
mainController.licenseTypeController.clear();
|
||||
mainController.siteDriverController.clear();
|
||||
mainController.phoneController.clear();
|
||||
Get.snackbar('done', '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
}
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Cancel'.tr,
|
||||
kolor: AppColor.redColor,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Add Driver Who Wants to Work".tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Add Car Who Wants to Work".tr,
|
||||
content: SizedBox(
|
||||
width: Get.width * .7,
|
||||
height: 300,
|
||||
child: Form(
|
||||
key: mainController.formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
MyTextForm(
|
||||
controller: mainController.carOwnerWorkController,
|
||||
label: 'Insert Name of Owner'.tr,
|
||||
hint: 'Insert Name of Owner'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.carNumberController,
|
||||
label: 'Insert car_number of Driver'.tr,
|
||||
hint: 'Insert car_number of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.phoneCarController,
|
||||
label: 'Insert phone of Owner'.tr,
|
||||
hint: 'Insert phone of Owner'.tr,
|
||||
type: TextInputType.phone),
|
||||
MyTextForm(
|
||||
controller:
|
||||
mainController.manufactureYearController,
|
||||
label: 'Insert year of Car'.tr,
|
||||
hint: 'Insert year of Car'.tr,
|
||||
type: TextInputType.number),
|
||||
MyTextForm(
|
||||
controller: mainController.carModelController,
|
||||
label: 'Insert car_model of Driver'.tr,
|
||||
hint: 'Insert car_model of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.siteCarController,
|
||||
label: 'Insert site of Owner'.tr,
|
||||
hint: 'Insert site of Owner'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller: mainController.carTypeController,
|
||||
label: 'Insert car_type of Driver'.tr,
|
||||
hint: 'Insert car_type of Driver'.tr,
|
||||
type: TextInputType.name),
|
||||
MyTextForm(
|
||||
controller:
|
||||
mainController.registrationDateController,
|
||||
label: 'Insert registration_date of Car'.tr,
|
||||
hint: 'Insert registration_date of Car'.tr,
|
||||
type: TextInputType.datetime),
|
||||
],
|
||||
)),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add'.tr,
|
||||
onPressed: () async {
|
||||
if (mainController.formKey.currentState!.validate()) {
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.addCarWantWork, payload: {
|
||||
"owner_name":
|
||||
mainController.carOwnerWorkController.text,
|
||||
"car_number": mainController.carNumberController.text,
|
||||
"manufacture_year":
|
||||
mainController.manufactureYearController.text,
|
||||
"car_model": mainController.carModelController.text,
|
||||
"car_type": mainController.carTypeController.text,
|
||||
"site": mainController.siteCarController.text,
|
||||
"registration_date":
|
||||
mainController.registrationDateController.text,
|
||||
"phone": mainController.phoneCarController.text,
|
||||
});
|
||||
if (res != 'failure') {
|
||||
Get.back();
|
||||
mainController.ownerController.clear();
|
||||
mainController.carNumberController.clear();
|
||||
mainController.manufactureYearController.clear();
|
||||
mainController.carModelController.clear();
|
||||
mainController.siteCarController.clear();
|
||||
mainController.carTypeController.clear();
|
||||
mainController.registrationDateController.clear();
|
||||
mainController.phoneController.clear();
|
||||
Get.snackbar('done', '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
}
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Cancel'.tr,
|
||||
kolor: AppColor.redColor,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Add Car Who Wants to Work".tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// Get.to(() => const ContactPage());
|
||||
// },
|
||||
// child: Container(
|
||||
// decoration: AppStyle.boxDecoration,
|
||||
// child: const Center(child: Text('contact')),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
)
|
||||
]);
|
||||
itemBuilder: (context, index) {
|
||||
final service = services[index];
|
||||
return ServiceCard(
|
||||
title: service.title,
|
||||
icon: service.icon,
|
||||
onTap: service.onTap,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Service Card Widget ---
|
||||
// A reusable widget for displaying each service.
|
||||
class ServiceCard extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const ServiceCard({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.15),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Icon
|
||||
Icon(
|
||||
icon,
|
||||
size: 48.0,
|
||||
// You can replace this color with your AppStyle color
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Title
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
// You can replace this color with your AppStyle color
|
||||
color: Color(0xFF4A4A4A),
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ class MyScaffold extends StatelessWidget {
|
||||
actions: [action],
|
||||
title: Text(
|
||||
title,
|
||||
style: AppStyle.title.copyWith(fontSize: 30),
|
||||
style: AppStyle.title
|
||||
.copyWith(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
body: SafeArea(child: Stack(children: body)));
|
||||
|
||||
@@ -55,11 +55,7 @@ class MyTextForm extends StatelessWidget {
|
||||
return 'Please enter a valid email.'.tr;
|
||||
}
|
||||
} else if (type == TextInputType.phone) {
|
||||
if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
if (value.length != 11) {
|
||||
return 'Please enter a valid phone number.'.tr;
|
||||
}
|
||||
} else if (value.length != 11) {
|
||||
if (value.length > 14) {
|
||||
//for this you will return to 10 but now for service egypt
|
||||
return 'Please enter a valid phone number.'.tr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user