Update Saqel Platform: 2026-09-05 23:24:49
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../core/theme/teacher_theme.dart';
|
||||
import '../../core/utils/saqel_toast.dart';
|
||||
import '../../data/models/teacher_models.dart';
|
||||
import '../../logic/cubits/teacher_auth_cubit.dart';
|
||||
import 'tabs/teacher_studio_upload_tab.dart';
|
||||
import 'tabs/teacher_monetization_tab.dart';
|
||||
import 'tabs/teacher_reputation_scorecard_tab.dart';
|
||||
@@ -8,15 +12,18 @@ import 'tabs/teacher_assignments_qna_tab.dart';
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* SAQEL TEACHER STUDIO - MAIN SHELL
|
||||
* SAQEL TEACHER STUDIO - MAIN SHELL (DYNAMIC PROFILE & REAL AUTH)
|
||||
* ==============================================================================
|
||||
*
|
||||
* الهيكل التنفيذي الرئيسي لاستوديو المعلم المعتمد:
|
||||
* - شريط علوي يحمل هوية المعلم، المدرسة، ودرجة الاعتماد الأكاديمي (94%)
|
||||
* - تنقل سفلي مرن بين استوديو الرفع، محفظة التسييل، رادار الأداء، وغرفة الأسئلة.
|
||||
* - شريط علوي ديناميكي يحمل هوية المعلم الحقيقية والمدرسة والصفوف المعتمدة
|
||||
* - إمكانية تعديل الملف والصفوف والمادة التخصصية
|
||||
* - زر تسجيل الخروج الآمن
|
||||
* - تنقل سفلي مرن بين استوديو الرفع، محفظة التسييل، رادار الأداء، وغرفة الأسئلة والبث الصوتي.
|
||||
*/
|
||||
class TeacherMainShell extends StatefulWidget {
|
||||
const TeacherMainShell({super.key});
|
||||
final TeacherProfileModel? initialProfile;
|
||||
const TeacherMainShell({super.key, this.initialProfile});
|
||||
|
||||
@override
|
||||
State<TeacherMainShell> createState() => _TeacherMainShellState();
|
||||
@@ -25,134 +32,326 @@ class TeacherMainShell extends StatefulWidget {
|
||||
class _TeacherMainShellState extends State<TeacherMainShell> {
|
||||
int _currentTabIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Scaffold(
|
||||
backgroundColor: TeacherTheme.backgroundDark,
|
||||
appBar: AppBar(
|
||||
backgroundColor: TeacherTheme.surfaceDark,
|
||||
elevation: 0,
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [TeacherTheme.emeraldPrimary, TeacherTheme.emeraldDark],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'م',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
void _openEditProfileDialog(BuildContext context, TeacherProfileModel profile) {
|
||||
final nameCtrl = TextEditingController(text: profile.name);
|
||||
final subjectCtrl = TextEditingController(text: profile.specialization);
|
||||
final schoolCtrl = TextEditingController(text: profile.schoolName);
|
||||
final bioCtrl = TextEditingController(text: profile.bio);
|
||||
final Set<String> selectedGrades = Set.from(profile.gradesTaught);
|
||||
|
||||
final allAvailableGrades = [
|
||||
'الصف التاسع الأساسي',
|
||||
'الصف العاشر الأساسي',
|
||||
'الأول ثانوي العلمي',
|
||||
'الأول ثانوي الأدبي',
|
||||
'الثاني ثانوي (التوجيهي 2008)',
|
||||
];
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (ctx) => StatefulBuilder(
|
||||
builder: (context, setModalState) => Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(ctx).viewInsets.bottom + 20,
|
||||
top: 24,
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: TeacherTheme.surfaceDark,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
border: Border(top: BorderSide(color: TeacherTheme.emeraldPrimary, width: 2)),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'استوديو المعلم المعتمد',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white,
|
||||
),
|
||||
const Icon(CupertinoIcons.pencil_circle_fill, color: TeacherTheme.emeraldPrimary, size: 28),
|
||||
const SizedBox(width: 10),
|
||||
const Text(
|
||||
'تحديث بيانات المعلم والصفوف والمباحث 📋',
|
||||
style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w800),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
icon: const Icon(CupertinoIcons.xmark_circle_fill, color: Colors.white54, size: 20),
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Icon(CupertinoIcons.checkmark_seal_fill, color: TeacherTheme.emeraldPrimary, size: 16),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'أ. أحمد المجالي · فيزياء التوجيهي (الثقافة العسكرية)',
|
||||
style: TextStyle(fontSize: 11, color: Color(0xFF94A3B8)),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
const Text('الاسم المعتمد:', style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 6),
|
||||
_buildInputBox(controller: nameCtrl, hint: 'الاسم الكامل'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
const Text('المادة التخصصية:', style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 6),
|
||||
_buildInputBox(controller: subjectCtrl, hint: 'المادة (مثال: الفيزياء)'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
const Text('المدرسة / المديرية:', style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 6),
|
||||
_buildInputBox(controller: schoolCtrl, hint: 'المدرسة التابع لها'),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
const Text('الصفوف والشعب التي تدرسها في المنصة:', style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: allAvailableGrades.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) {
|
||||
setModalState(() {
|
||||
if (selected) {
|
||||
selectedGrades.add(grade);
|
||||
} else {
|
||||
if (selectedGrades.length > 1) {
|
||||
selectedGrades.remove(grade);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.emeraldPrimary.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: TeacherTheme.emeraldPrimary.withOpacity(0.4)),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(CupertinoIcons.star_fill, color: TeacherTheme.royalGold, size: 14),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'معتمد 94%',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: TeacherTheme.emeraldLight,
|
||||
const SizedBox(height: 20),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.read<TeacherAuthCubit>().updateProfile(
|
||||
fullName: nameCtrl.text.trim(),
|
||||
specialization: subjectCtrl.text.trim(),
|
||||
schoolName: schoolCtrl.text.trim(),
|
||||
gradesTaught: selectedGrades.toList(),
|
||||
bio: bioCtrl.text.trim(),
|
||||
);
|
||||
Navigator.of(ctx).pop();
|
||||
SaqelToast.showSuccess(context, 'تم تحديث بيانات المعلم والصفوف بنجاح ✨');
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: TeacherTheme.emeraldPrimary,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: const Text('حفظ التعديلات واعتماد الملف 💾', style: TextStyle(fontSize: 13.5, fontWeight: FontWeight.w900)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: IndexedStack(
|
||||
index: _currentTabIndex,
|
||||
children: const [
|
||||
TeacherStudioUploadTab(),
|
||||
TeacherMonetizationTab(),
|
||||
TeacherReputationScorecardTab(),
|
||||
TeacherAssignmentsQnATab(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: TeacherTheme.surfaceDark,
|
||||
border: Border(top: BorderSide(color: TeacherTheme.surfaceBorder)),
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
currentIndex: _currentTabIndex,
|
||||
onTap: (idx) => setState(() => _currentTabIndex = idx),
|
||||
backgroundColor: Colors.transparent,
|
||||
selectedItemColor: TeacherTheme.emeraldPrimary,
|
||||
unselectedItemColor: const Color(0xFF64748B),
|
||||
selectedLabelStyle: const TextStyle(fontWeight: FontWeight.w800, fontSize: 11),
|
||||
unselectedLabelStyle: const TextStyle(fontSize: 10.5),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
elevation: 0,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.videocam_circle_fill),
|
||||
label: 'استوديو الحصص',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.money_dollar_circle_fill),
|
||||
label: 'محفظة التسييل',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.chart_bar_circle_fill),
|
||||
label: 'رادار الأداء',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.chat_bubble_2_fill),
|
||||
label: 'الواجبات والأسئلة',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInputBox({required TextEditingController controller, required String hint}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 13),
|
||||
decoration: InputDecoration(border: InputBorder.none, hintText: hint, hintStyle: const TextStyle(color: Color(0xFF64748B), fontSize: 12)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _confirmLogout(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (ctx) => Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: CupertinoAlertDialog(
|
||||
title: const Text('تسجيل الخروج من استوديو المعلم 🚪'),
|
||||
content: const Text('هل أنت متأكد من رغبتك في إنهاء جلسة العمل الحالية؟'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: const Text('إلغاء'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
context.read<TeacherAuthCubit>().logout();
|
||||
},
|
||||
child: const Text('تسجيل الخروج'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<TeacherAuthCubit, TeacherAuthState>(
|
||||
builder: (context, authState) {
|
||||
TeacherProfileModel profile = widget.initialProfile ??
|
||||
const TeacherProfileModel(
|
||||
id: 1,
|
||||
uuid: 'tch-01',
|
||||
name: 'المهندس حمزة الغويريين',
|
||||
specialization: 'الفيزياء والعلوم التطبيقية',
|
||||
schoolName: 'مدرسة الملك عبد الله الثاني للتميز',
|
||||
gradesTaught: ['الصف العاشر الأساسي', 'الأول ثانوي العلمي'],
|
||||
bio: 'معلم معتمد في منصة صَقِل',
|
||||
);
|
||||
|
||||
if (authState is TeacherAuthenticated) {
|
||||
profile = authState.profile;
|
||||
}
|
||||
|
||||
final initialLetter = profile.name.isNotEmpty ? profile.name.trim().characters.first : 'م';
|
||||
|
||||
return Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Scaffold(
|
||||
backgroundColor: TeacherTheme.backgroundDark,
|
||||
appBar: AppBar(
|
||||
backgroundColor: TeacherTheme.surfaceDark,
|
||||
elevation: 0,
|
||||
title: GestureDetector(
|
||||
onTap: () => _openEditProfileDialog(context, profile),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [TeacherTheme.emeraldPrimary, TeacherTheme.emeraldDark],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
initialLetter,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
profile.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 14.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Icon(CupertinoIcons.checkmark_seal_fill, color: TeacherTheme.emeraldPrimary, size: 15),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'${profile.specialization} · ${profile.gradesTaught.join("، ")}',
|
||||
style: const TextStyle(fontSize: 10.5, color: Color(0xFF94A3B8)),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
// Edit Profile Button
|
||||
IconButton(
|
||||
tooltip: 'تعديل بيانات المعلم والصفوف',
|
||||
icon: const Icon(CupertinoIcons.slider_horizontal_3, color: TeacherTheme.emeraldPrimary, size: 20),
|
||||
onPressed: () => _openEditProfileDialog(context, profile),
|
||||
),
|
||||
// Logout Button
|
||||
IconButton(
|
||||
tooltip: 'تسجيل الخروج',
|
||||
icon: const Icon(CupertinoIcons.square_arrow_right, color: Color(0xFFFF453A), size: 20),
|
||||
onPressed: () => _confirmLogout(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: IndexedStack(
|
||||
index: _currentTabIndex,
|
||||
children: const [
|
||||
TeacherStudioUploadTab(),
|
||||
TeacherMonetizationTab(),
|
||||
TeacherReputationScorecardTab(),
|
||||
TeacherAssignmentsQnATab(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: TeacherTheme.surfaceDark,
|
||||
border: Border(top: BorderSide(color: TeacherTheme.surfaceBorder)),
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
currentIndex: _currentTabIndex,
|
||||
onTap: (idx) => setState(() => _currentTabIndex = idx),
|
||||
backgroundColor: Colors.transparent,
|
||||
selectedItemColor: TeacherTheme.emeraldPrimary,
|
||||
unselectedItemColor: const Color(0xFF64748B),
|
||||
selectedLabelStyle: const TextStyle(fontWeight: FontWeight.w800, fontSize: 11),
|
||||
unselectedLabelStyle: const TextStyle(fontSize: 10.5),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
elevation: 0,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.videocam_circle_fill),
|
||||
label: 'استوديو الحصص',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.money_dollar_circle_fill),
|
||||
label: 'محفظة التسييل',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.chart_bar_circle_fill),
|
||||
label: 'رادار الأداء',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.chat_bubble_2_fill),
|
||||
label: 'الأسئلة والبث 🎙️',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user