This commit is contained in:
Hamza-Ayed
2026-05-01 01:43:59 +03:00
parent cdda136006
commit 5fc160e374
25 changed files with 1526 additions and 1856 deletions

View File

@@ -6,6 +6,7 @@ import '../../controller/auth/login_controller.dart';
import '../../controller/auth/otp_helper.dart';
import '../../controller/functions/crud.dart';
import '../../print.dart';
import '../admin/admin_home_page.dart';
// ─── Colors (نفس نظام الألوان المستخدم في التطبيق) ──────────────────────────
class _C {
@@ -31,30 +32,28 @@ class AdminLoginPage extends StatefulWidget {
class _AdminLoginPageState extends State<AdminLoginPage>
with SingleTickerProviderStateMixin {
final _phoneController = TextEditingController();
final _passwordController = TextEditingController();
final _formKey = GlobalKey<FormState>();
bool _isLoading = false;
late final AnimationController _glowCtrl;
late final Animation<double> _glowAnim;
// ─── Logic (بدون تغيير) ────────────────────────────────────────────────────
Future<void> _submit() async {
final allowedPhones = Env.ALLOWED_ADMIN_PHONES;
Log.print('allowedPhones: ${allowedPhones}');
allowedPhones.toString().split(',');
final password = _passwordController.text.trim();
final phone = _phoneController.text.trim();
if (!allowedPhones.contains(phone)) {
Get.snackbar('رفض الدخول', 'رقم الهاتف غير مخوّل بالدخول إلى الإدارة');
if (password.isEmpty) {
Get.snackbar('خطأ', 'يرجى إدخال كلمة المرور');
return;
}
setState(() => _isLoading = true);
final otpSent = await OtpHelper.sendOtp(phone);
if (otpSent) {
Get.to(() => OtpVerificationAdmin(phone: phone));
final otpHelper = Get.find<OtpHelper>();
bool success = await otpHelper.loginWithPassword(password);
if (success) {
Get.offAll(() => const AdminHomePage());
}
setState(() => _isLoading = false);
@@ -75,7 +74,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
}
void _initializeToken() async {
await CRUD().getJWT();
// await CRUD().getJWT();
}
@override
@@ -168,7 +167,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
),
const SizedBox(height: 8),
const Text(
'أدخل رقم هاتفك للمتابعة',
'أدخل كلمة المرور للمتابعة',
style: TextStyle(
color: _C.textSec,
fontSize: 14,
@@ -195,14 +194,15 @@ class _AdminLoginPageState extends State<AdminLoginPage>
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// ── Field label ─────────────────────────────
const SizedBox(height: 20),
// ── Field label (Password) ─────────────────────────────
const Row(
children: [
Icon(Icons.phone_android_rounded,
Icon(Icons.lock_outline_rounded,
color: _C.accent, size: 16),
SizedBox(width: 8),
Text(
'رقم الهاتف',
'كلمة المرور',
style: TextStyle(
color: _C.textSec,
fontSize: 13,
@@ -213,28 +213,19 @@ class _AdminLoginPageState extends State<AdminLoginPage>
],
),
const SizedBox(height: 10),
// ── Phone field ─────────────────────────────
// ── Password field ─────────────────────────────
TextFormField(
controller: _phoneController,
keyboardType: TextInputType.phone,
textDirection: TextDirection.ltr,
controller: _passwordController,
obscureText: true,
style: const TextStyle(
color: _C.textPrimary,
fontSize: 16,
fontFamily: 'monospace',
letterSpacing: 1.2,
),
decoration: InputDecoration(
hintText: '+963 XXX XXX XXX',
hintStyle: const TextStyle(
color: _C.textSec,
fontSize: 14,
letterSpacing: 0.5),
hintText: '••••••••',
hintStyle: const TextStyle(color: _C.textSec),
filled: true,
fillColor: _C.inputBg,
prefixIcon: const Icon(Icons.dialpad_rounded,
color: _C.accentDim, size: 20),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide.none,
@@ -249,24 +240,12 @@ class _AdminLoginPageState extends State<AdminLoginPage>
borderSide: const BorderSide(
color: _C.accent, width: 1.5),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(
color: _C.error, width: 1),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(
color: _C.error, width: 1.5),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 16),
errorStyle: const TextStyle(
color: _C.error, fontSize: 12),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'الرجاء إدخال رقم الهاتف';
return 'الرجاء إدخال كلمة المرور';
}
return null;
},
@@ -296,6 +275,21 @@ class _AdminLoginPageState extends State<AdminLoginPage>
const SizedBox(height: 32),
// ── Register Button ─────────────────────────────────
TextButton(
onPressed: () => Get.toNamed('/register'),
child: const Text(
'ليس لديك حساب؟ طلب انضمام',
style: TextStyle(
color: _C.accent,
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
// ── Footer ──────────────────────────────────────────
Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -435,8 +429,8 @@ class _SubmitButtonState extends State<_SubmitButton>
children: [
Icon(Icons.send_rounded, color: Colors.white, size: 18),
SizedBox(width: 10),
Text(
'إرسال رمز التحقق',
const Text(
'تسجيل الدخول',
style: TextStyle(
color: Colors.white,
fontSize: 16,