Update Saqel Platform: 2026-09-05 23:24:49
This commit is contained in:
@@ -0,0 +1,415 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../core/config/app_config.dart';
|
||||
import '../../../core/theme/teacher_theme.dart';
|
||||
import '../../../core/utils/saqel_toast.dart';
|
||||
import '../../../logic/cubits/teacher_auth_cubit.dart';
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* SAQEL TEACHER STUDIO - AUTHENTICATION SCREEN (WHATSAPP OTP GATEWAY)
|
||||
* ==============================================================================
|
||||
*
|
||||
* بوابة تسجيل الدخول المعتمدة للمعلمين:
|
||||
* - التحقق عبر الواتساب (Nabeh WhatsApp Gateway)
|
||||
* - استكمال بيانات المعلم والصفوف والمباحث المعتمدة
|
||||
* - لا وجود لأي بيانات وهمية أو تجاوزات تجريبية (Zero-Mock Production).
|
||||
*/
|
||||
class TeacherAuthScreen extends StatefulWidget {
|
||||
const TeacherAuthScreen({super.key});
|
||||
|
||||
@override
|
||||
State<TeacherAuthScreen> createState() => _TeacherAuthScreenState();
|
||||
}
|
||||
|
||||
class _TeacherAuthScreenState extends State<TeacherAuthScreen> {
|
||||
final TextEditingController _phoneController = TextEditingController(text: '0798583052');
|
||||
final TextEditingController _otpController = TextEditingController();
|
||||
final TextEditingController _fullNameController = TextEditingController(text: 'المهندس حمزة الغويريين');
|
||||
final TextEditingController _schoolController = TextEditingController(text: 'مدرسة الملك عبد الله الثاني للتميز');
|
||||
|
||||
String _selectedSubject = 'الفيزياء والعلوم التطبيقية';
|
||||
final List<String> _availableSubjects = [
|
||||
'الفيزياء والعلوم التطبيقية',
|
||||
'الرياضيات العلمي',
|
||||
'الكيمياء الحيوية',
|
||||
'العلوم الحياتية',
|
||||
'اللغة الإنجليزية (Action Pack)',
|
||||
'اللغة العربية ومشترك التوجيهي',
|
||||
];
|
||||
|
||||
final Set<String> _selectedGrades = {
|
||||
'الصف العاشر الأساسي',
|
||||
'الأول ثانوي العلمي',
|
||||
};
|
||||
|
||||
final List<String> _allGrades = [
|
||||
'الصف التاسع الأساسي',
|
||||
'الصف العاشر الأساسي',
|
||||
'الأول ثانوي العلمي',
|
||||
'الأول ثانوي الأدبي',
|
||||
'الثاني ثانوي (التوجيهي 2008)',
|
||||
];
|
||||
|
||||
bool _isEnteringOtp = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneController.dispose();
|
||||
_otpController.dispose();
|
||||
_fullNameController.dispose();
|
||||
_schoolController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onSendOtp() {
|
||||
final phone = _phoneController.text.trim();
|
||||
if (phone.isEmpty || phone.length < 9) {
|
||||
SaqelToast.showError(context, 'يرجى إدخال رقم هاتف أردني صحيح يبدأ بـ 07');
|
||||
return;
|
||||
}
|
||||
context.read<TeacherAuthCubit>().sendOtp(phone);
|
||||
}
|
||||
|
||||
void _onVerifyOtp() {
|
||||
final phone = _phoneController.text.trim();
|
||||
final otp = _otpController.text.trim();
|
||||
if (otp.isEmpty || otp.length < 4) {
|
||||
SaqelToast.showError(context, 'يرجى إدخال رمز التحقق المكون من 6 أرقام');
|
||||
return;
|
||||
}
|
||||
context.read<TeacherAuthCubit>().verifyOtp(phone, otp, fullName: _fullNameController.text.trim());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Scaffold(
|
||||
backgroundColor: TeacherTheme.backgroundDark,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 520),
|
||||
child: BlocConsumer<TeacherAuthCubit, TeacherAuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is TeacherAuthError) {
|
||||
SaqelToast.showError(context, state.message, title: 'تنبيه المصادقة');
|
||||
} else if (state is TeacherAuthOtpSent) {
|
||||
setState(() => _isEnteringOtp = true);
|
||||
SaqelToast.showWhatsApp(
|
||||
context,
|
||||
'تم إرسال رمز التحقق إلى الرقم ${state.phoneNumber}',
|
||||
title: 'رسالة واتساب من نبيه 📲',
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final isLoading = state is TeacherAuthLoading;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceDark,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder, width: 1.2),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x3310B981),
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Top Brand Emblem
|
||||
Center(
|
||||
child: Container(
|
||||
width: 68,
|
||||
height: 68,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [TeacherTheme.emeraldPrimary, TeacherTheme.emeraldDark],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x6610B981),
|
||||
blurRadius: 20,
|
||||
offset: Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'ص',
|
||||
style: TextStyle(
|
||||
fontSize: 34,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const Text(
|
||||
'صَقِل — استوديو المعلم المعتمد 🎖️',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
letterSpacing: -0.3,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'البيئة المعتمدة للمعلمين لرفع الحصص، الرد على أسئلة الطلبة، وإدارة التسييل المالي',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: Color(0xFF94A3B8),
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Backend Live Gateway Badge
|
||||
Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF0C241D),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: TeacherTheme.emeraldPrimary.withOpacity(0.4)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: TeacherTheme.emeraldPrimary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
AppConfig.baseUrl.replaceAll('https://', '').replaceAll('http://', ''),
|
||||
style: const TextStyle(
|
||||
color: TeacherTheme.emeraldLight,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
if (!_isEnteringOtp) ...[
|
||||
// Step 1: Teacher Info & Phone
|
||||
const Text(
|
||||
'اسم المعلم المعتمد:',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.5),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildTextField(
|
||||
controller: _fullNameController,
|
||||
hint: 'أدخل الاسم الثلاثي أو الرباعي',
|
||||
icon: CupertinoIcons.person_crop_circle_fill,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
const Text(
|
||||
'المادة الأكاديمية التخصصية:',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.5),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: _selectedSubject,
|
||||
isExpanded: true,
|
||||
dropdownColor: TeacherTheme.surfaceDark,
|
||||
icon: const Icon(CupertinoIcons.chevron_down, color: TeacherTheme.emeraldPrimary, size: 18),
|
||||
items: _availableSubjects.map((s) {
|
||||
return DropdownMenuItem(
|
||||
value: s,
|
||||
child: Text(s, style: const TextStyle(color: Colors.white, fontSize: 12.5)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
if (val != null) setState(() => _selectedSubject = val);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
const Text(
|
||||
'المدرسة / المديرية التابع لها:',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.5),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildTextField(
|
||||
controller: _schoolController,
|
||||
hint: 'مثال: مدرسة الملك عبد الله الثاني للتميز',
|
||||
icon: CupertinoIcons.building_2_fill,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
const Text(
|
||||
'الصفوف والشعب التي تدرسها:',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.5),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _allGrades.map((grade) {
|
||||
final isSelected = _selectedGrades.contains(grade);
|
||||
return FilterChip(
|
||||
selected: isSelected,
|
||||
label: Text(grade, style: TextStyle(color: isSelected ? Colors.black : Colors.white, fontSize: 11.5, fontWeight: FontWeight.bold)),
|
||||
selectedColor: TeacherTheme.emeraldPrimary,
|
||||
backgroundColor: TeacherTheme.surfaceCard,
|
||||
checkmarkColor: Colors.black,
|
||||
side: BorderSide(color: isSelected ? TeacherTheme.emeraldPrimary : TeacherTheme.surfaceBorder),
|
||||
onSelected: (selected) {
|
||||
setState(() {
|
||||
if (selected) {
|
||||
_selectedGrades.add(grade);
|
||||
} else {
|
||||
if (_selectedGrades.length > 1) {
|
||||
_selectedGrades.remove(grade);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
|
||||
const Text(
|
||||
'رقم الهاتف للدخول والتحقق (WhatsApp OTP):',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.5),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildTextField(
|
||||
controller: _phoneController,
|
||||
hint: '079XXXXXXX',
|
||||
icon: CupertinoIcons.phone_fill,
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: isLoading ? null : _onSendOtp,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: TeacherTheme.emeraldPrimary,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(color: Colors.black, strokeWidth: 2))
|
||||
: const Text(
|
||||
'إرسال رمز التحقق عبر الواتساب 📲',
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w900),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
// Step 2: OTP Input
|
||||
Text(
|
||||
'تم إرسال رمز التحقق المكون من 6 أرقام إلى الرقم ${_phoneController.text}',
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 13),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildTextField(
|
||||
controller: _otpController,
|
||||
hint: 'أدخل رمز الـ OTP (مثال: 123456)',
|
||||
icon: CupertinoIcons.lock_shield_fill,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: isLoading ? null : _onVerifyOtp,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: TeacherTheme.emeraldPrimary,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(color: Colors.black, strokeWidth: 2))
|
||||
: const Text(
|
||||
'تأكيد الدخول لملف المعلم ✨',
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w900),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () => setState(() => _isEnteringOtp = false),
|
||||
child: const Text('تعديل رقم الهاتف والبيانات', style: TextStyle(color: TeacherTheme.emeraldLight)),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextField({
|
||||
required TextEditingController controller,
|
||||
required String hint,
|
||||
required IconData icon,
|
||||
TextInputType keyboardType = TextInputType.text,
|
||||
}) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
keyboardType: keyboardType,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 13.5, fontWeight: FontWeight.w600),
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(icon, color: TeacherTheme.emeraldPrimary, size: 18),
|
||||
hintText: hint,
|
||||
hintStyle: const TextStyle(color: Color(0xFF64748B), fontSize: 12.5),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user