refactor: إعادة تسمية التطبيقات الأربعة siro_* → intaleq_*
المجلدات وأسماء حزم dart واستيراداتها: siro_rider → intaleq_rider siro_driver → intaleq_driver siro_admin → intaleq_admin siro_service → intaleq_service شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات (115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت). + ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة. ⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER · shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها كوميت منفصل، والهويات تحتاج قرار المالك. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
92dc6b3641
commit
0aab85c732
@@ -0,0 +1,153 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intaleq_service/views/widgets/mycircular.dart';
|
||||
import 'package:intaleq_service/constant/links.dart';
|
||||
import 'package:intaleq_service/controller/functions/crud.dart';
|
||||
import 'package:intaleq_service/controller/functions/device_helper.dart';
|
||||
import 'package:intaleq_service/print.dart';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
class RegisterController extends GetxController {
|
||||
final firstName = TextEditingController();
|
||||
final lastName = TextEditingController();
|
||||
final email = TextEditingController();
|
||||
final phone = TextEditingController();
|
||||
final password = TextEditingController();
|
||||
|
||||
final FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
var isLoading = false.obs;
|
||||
|
||||
void register() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
isLoading.value = true;
|
||||
|
||||
// الحصول على البصمة
|
||||
String fingerprint = await DeviceHelper.getDeviceFingerprint();
|
||||
|
||||
var payload = {
|
||||
"first_name": firstName.text,
|
||||
"last_name": lastName.text,
|
||||
"email": email.text,
|
||||
"phone": phone.text,
|
||||
"password": password.text,
|
||||
"fingerprint": fingerprint,
|
||||
};
|
||||
|
||||
Log.print('🚀 Register Payload: $payload');
|
||||
var res = await CRUD().post(link: AppLink.register, payload: payload);
|
||||
Log.print('📥 Register Response: $res');
|
||||
|
||||
isLoading.value = false;
|
||||
|
||||
if (res != 'failure' && res is Map && res['status'] == 'success') {
|
||||
// حفظ كلمة المرور للدخول التلقائي لاحقاً
|
||||
await storage.write(key: 'password', value: password.text);
|
||||
|
||||
// Request OTP
|
||||
bool otpSent = await _sendOtp(phone.text);
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone.text, res['message']?['message'] ?? 'Your request has been submitted successfully. Please wait for admin approval.'.tr);
|
||||
} else {
|
||||
mySnackbarError('Failed to send OTP'.tr);
|
||||
}
|
||||
} else {
|
||||
mySnackbarError(
|
||||
res is Map ? res['message'].toString() : "فشل تقديم طلب التسجيل".tr,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _sendOtp(String phoneNumber) async {
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/request.php',
|
||||
payload: {
|
||||
'receiver': phoneNumber,
|
||||
'user_type': 'service'
|
||||
},
|
||||
);
|
||||
return response != 'failure';
|
||||
} catch (e) {
|
||||
Log.print('OTP SEND ERROR: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void _showOtpDialog(String phoneNumber, String successMessage) {
|
||||
String otpCode = '';
|
||||
Get.defaultDialog(
|
||||
title: 'رمز التحقق'.tr,
|
||||
content: Column(
|
||||
children: [
|
||||
Text('تم إرسال رمز التحقق إلى رقمك ($phoneNumber)'.tr),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
onChanged: (val) => otpCode = val,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'أدخل الرمز هنا'.tr,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
textConfirm: 'تحقق'.tr,
|
||||
confirmTextColor: Colors.white,
|
||||
onConfirm: () async {
|
||||
if (otpCode.length >= 3) {
|
||||
Get.back(); // close dialog
|
||||
await _verifyOtpAndFinalize(phoneNumber, otpCode, successMessage);
|
||||
} else {
|
||||
mySnackbarError('الرجاء إدخال رمز صحيح'.tr);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _verifyOtpAndFinalize(String phoneNumber, String otp, String successMessage) async {
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: '${AppLink.server}/auth/otp/verify.php',
|
||||
payload: {
|
||||
'phone_number': phoneNumber,
|
||||
'token_code': otp,
|
||||
'user_type': 'service',
|
||||
},
|
||||
);
|
||||
Get.back(); // close loading
|
||||
|
||||
if (response != 'failure' && response['status'] == 'success') {
|
||||
Get.defaultDialog(
|
||||
title: "نجاح".tr,
|
||||
middleText: successMessage,
|
||||
onConfirm: () {
|
||||
Get.back(); // close success dialog
|
||||
Get.back(); // return to login page
|
||||
},
|
||||
textConfirm: "موافق".tr,
|
||||
);
|
||||
} else {
|
||||
mySnackbarError('Invalid OTP'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.back(); // close loading
|
||||
Log.print('OTP VERIFY ERROR: $e');
|
||||
mySnackbarError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
firstName.dispose();
|
||||
lastName.dispose();
|
||||
email.dispose();
|
||||
phone.dispose();
|
||||
password.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user