Update Saqel Platform: 2026-09-08 13:43:36
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'dart:typed_data';
|
||||
import '../../data/models/teacher_models.dart';
|
||||
import '../../data/repositories/teacher_repository.dart';
|
||||
|
||||
@@ -15,27 +16,59 @@ import '../../data/repositories/teacher_repository.dart';
|
||||
class TeacherStudioState {
|
||||
final String lessonTitle;
|
||||
final double durationMinutes;
|
||||
final String gradeLevel;
|
||||
final String? selectedFileName;
|
||||
final double? selectedFileSizeMb;
|
||||
final String? selectedFilePath;
|
||||
final Uint8List? selectedFileBytes;
|
||||
final bool isAuditing;
|
||||
final TeacherLessonAuditModel? auditResult;
|
||||
final bool isUploading;
|
||||
final bool isUploaded;
|
||||
final String? uploadSuccessMessage;
|
||||
|
||||
const TeacherStudioState({
|
||||
required this.lessonTitle,
|
||||
required this.durationMinutes,
|
||||
this.gradeLevel = 'الصف العاشر الأساسي',
|
||||
this.selectedFileName,
|
||||
this.selectedFileSizeMb,
|
||||
this.selectedFilePath,
|
||||
this.selectedFileBytes,
|
||||
required this.isAuditing,
|
||||
this.auditResult,
|
||||
this.isUploading = false,
|
||||
this.isUploaded = false,
|
||||
this.uploadSuccessMessage,
|
||||
});
|
||||
|
||||
TeacherStudioState copyWith({
|
||||
String? lessonTitle,
|
||||
double? durationMinutes,
|
||||
String? gradeLevel,
|
||||
String? selectedFileName,
|
||||
double? selectedFileSizeMb,
|
||||
String? selectedFilePath,
|
||||
Uint8List? selectedFileBytes,
|
||||
bool? isAuditing,
|
||||
TeacherLessonAuditModel? auditResult,
|
||||
bool? isUploading,
|
||||
bool? isUploaded,
|
||||
String? uploadSuccessMessage,
|
||||
}) {
|
||||
return TeacherStudioState(
|
||||
lessonTitle: lessonTitle ?? this.lessonTitle,
|
||||
durationMinutes: durationMinutes ?? this.durationMinutes,
|
||||
gradeLevel: gradeLevel ?? this.gradeLevel,
|
||||
selectedFileName: selectedFileName ?? this.selectedFileName,
|
||||
selectedFileSizeMb: selectedFileSizeMb ?? this.selectedFileSizeMb,
|
||||
selectedFilePath: selectedFilePath ?? this.selectedFilePath,
|
||||
selectedFileBytes: selectedFileBytes ?? this.selectedFileBytes,
|
||||
isAuditing: isAuditing ?? this.isAuditing,
|
||||
auditResult: auditResult ?? this.auditResult,
|
||||
isUploading: isUploading ?? this.isUploading,
|
||||
isUploaded: isUploaded ?? this.isUploaded,
|
||||
uploadSuccessMessage: uploadSuccessMessage ?? this.uploadSuccessMessage,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +79,7 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
TeacherStudioCubit({required this.repository})
|
||||
: super(const TeacherStudioState(
|
||||
lessonTitle: 'شرح قاعدة لنتز والحث الكهرومغناطيسي — فيزياء 2008',
|
||||
durationMinutes: 22.5,
|
||||
durationMinutes: 13.0,
|
||||
isAuditing: false,
|
||||
auditResult: null,
|
||||
));
|
||||
@@ -59,6 +92,28 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
emit(state.copyWith(durationMinutes: duration));
|
||||
}
|
||||
|
||||
void updateGradeLevel(String grade) {
|
||||
emit(state.copyWith(gradeLevel: grade));
|
||||
}
|
||||
|
||||
void selectVideoFile(
|
||||
String fileName,
|
||||
double sizeMb,
|
||||
double durationMinutes, {
|
||||
String? path,
|
||||
Uint8List? bytes,
|
||||
}) {
|
||||
emit(state.copyWith(
|
||||
selectedFileName: fileName,
|
||||
selectedFileSizeMb: sizeMb,
|
||||
selectedFilePath: path,
|
||||
selectedFileBytes: bytes,
|
||||
durationMinutes: durationMinutes,
|
||||
isUploaded: false,
|
||||
uploadSuccessMessage: null,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> runQualityGate() async {
|
||||
emit(state.copyWith(isAuditing: true));
|
||||
try {
|
||||
@@ -75,4 +130,35 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
emit(state.copyWith(isAuditing: false));
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> uploadAndPublishLesson() async {
|
||||
if (state.selectedFileName == null ||
|
||||
(state.selectedFilePath == null && state.selectedFileBytes == null)) {
|
||||
return false;
|
||||
}
|
||||
emit(state.copyWith(isUploading: true));
|
||||
try {
|
||||
final res = await repository.uploadLesson(
|
||||
title: state.lessonTitle,
|
||||
durationMinutes: state.durationMinutes,
|
||||
gradeLevel: state.gradeLevel,
|
||||
subject: 'الفيزياء والعلوم التطبيقية',
|
||||
fileName: state.selectedFileName ?? 'lentz_law_physics_2008.mp4',
|
||||
fileSizeMb: state.selectedFileSizeMb ?? 48.2,
|
||||
filePath: state.selectedFilePath,
|
||||
fileBytes: state.selectedFileBytes,
|
||||
);
|
||||
|
||||
final msg = res['message']?.toString() ?? 'تم رفع ونشر الحصة بنجاح في المنهاج الوزاري وسوق صَقِل! 🚀';
|
||||
emit(state.copyWith(
|
||||
isUploading: false,
|
||||
isUploaded: true,
|
||||
uploadSuccessMessage: msg,
|
||||
));
|
||||
return true;
|
||||
} catch (e) {
|
||||
emit(state.copyWith(isUploading: false));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user