This commit is contained in:
Hamza-Ayed
2023-12-03 10:35:27 +03:00
parent e095cf564a
commit 2501292424
50 changed files with 1841 additions and 730 deletions

View File

@@ -0,0 +1,56 @@
import 'dart:convert';
import 'package:get/get.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/constant/table_names.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/box_name.dart';
import '../../../constant/links.dart';
import '../../../main.dart';
import '../../functions/crud.dart';
class NotificationCaptainController extends GetxController {
bool isloading = false;
Map notificationData = {};
getNotifications() async {
isloading = true;
update();
var res = await CRUD().get(
link: AppLink.getNotificationCaptain,
payload: {'driverID': box.read(BoxName.driverID)});
if (res == "failure") {
// print(res);
Get.defaultDialog(
title: 'There is no notification yet'.tr,
titleStyle: AppStyle.title,
middleText: '',
confirm: MyElevatedButton(
title: 'Back',
onPressed: () {
Get.back();
Get.back();
}));
}
notificationData = jsonDecode(res);
// sql.insertData(notificationData['message'], TableName.captainNotification);
// print(notificationData);
isloading = false;
update();
}
updateNotification(String id) async {
await CRUD().post(
link: AppLink.updateNotificationCaptain,
payload: {'isShown': true, 'id': id},
);
}
@override
void onInit() {
getNotifications();
super.onInit();
}
}

View File

@@ -12,6 +12,7 @@ import 'package:ride/views/auth/captin/login_captin.dart';
import 'package:ride/views/auth/captin/verify_email_captain.dart';
import '../../../views/auth/captin/ai_page.dart';
import '../../../views/auth/captin/car_license_page.dart';
import '../../../views/auth/verify_email_page.dart';
class RegisterCaptainController extends GetxController {
@@ -76,7 +77,7 @@ class RegisterCaptainController extends GetxController {
});
if (res != 'failure') {
Get.offAll(() => LoginCaptin());
Get.to(() => CarLicensePage());
}
}
@@ -105,7 +106,7 @@ class RegisterCaptainController extends GetxController {
update();
}
void addLisence() async {
Future addLisence() async {
getFromController();
var res = await CRUD().post(link: AppLink.addLicense, payload: {
'name': name,
@@ -114,7 +115,7 @@ class RegisterCaptainController extends GetxController {
'address': address,
'height': height,
'postalCode': postalCode,
'sex': sex == 'M' ? 'Male' : 'Female',
'sex': sex,
'stateCode': stateCode,
'expireDate': expireDate,
'dateOfBirth': dob,
@@ -152,11 +153,11 @@ class RegisterCaptainController extends GetxController {
isLoading = false;
update();
if (jsonDecode(res)['status'] == 'success') {
// Get.to(() => AiPage()); //todo replace this
Get.offAll(() => LoginCaptin()); //todo replace this
}
}
void register() async {
Future register() async {
getFromController();
if (formKey.currentState!.validate()) {
isLoading = true;
@@ -171,11 +172,11 @@ class RegisterCaptainController extends GetxController {
'site': address,
'birthdate': dob,
});
print(jsonDecode(res));
isLoading = false;
update();
if (jsonDecode(res)['status'] == 'success') {
print('sdfffffffffff');
box.write(BoxName.driverID, jsonDecode(res)['message']);
box.write(BoxName.dobDriver, dob);
box.write(BoxName.sexDriver, sex);
box.write(BoxName.phoneDriver, phoneController.text);