Muitas coisas e já me esqueci delas todas, cenas principalmente no dashboard do aluno bug fixes e etc

This commit is contained in:
2026-05-17 19:42:49 +01:00
parent 7a26223a01
commit e388ca3b67
20 changed files with 1989 additions and 1224 deletions

View File

@@ -46,11 +46,8 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
return Scaffold(
appBar: AppBar(
title: const Text(
'Materiais da Turma',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
'Materiais da Disciplina',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
backgroundColor: const Color(0xFF82C9BD),
elevation: 0,
@@ -88,10 +85,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF82C9BD),
Color(0xFFF8F9FA),
],
colors: [Color(0xFF82C9BD), Color(0xFFF8F9FA)],
stops: [0.0, 0.4],
),
),
@@ -101,9 +95,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Color(0xFF82C9BD),
),
child: CircularProgressIndicator(color: Color(0xFF82C9BD)),
);
}
@@ -168,13 +160,19 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
padding: const EdgeInsets.all(16),
itemCount: materials.length,
itemBuilder: (context, index) {
final material = materials[index].data() as Map<String, dynamic>;
final material =
materials[index].data() as Map<String, dynamic>;
final fileName = material['fileName'] ?? 'Ficheiro sem nome';
final createdAt = material['createdAt'] as Timestamp?;
// Inferir tipo pela extensão do filename
final extension = path.extension(fileName).toLowerCase();
final fileType = extension == '.pdf' ? 'pdf' :
(extension == '.jpg' || extension == '.jpeg' || extension == '.png') ? 'image' : 'other';
final fileType = extension == '.pdf'
? 'pdf'
: (extension == '.jpg' ||
extension == '.jpeg' ||
extension == '.png')
? 'image'
: 'other';
final docId = materials[index].id;
final url = material['url'] as String?;
@@ -204,9 +202,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
builder: (context) => Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
child: SafeArea(
child: Padding(
@@ -291,10 +287,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
decoration: BoxDecoration(
color: color.withOpacity(0.05),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: color.withOpacity(0.2),
width: 1,
),
border: Border.all(color: color.withOpacity(0.2), width: 1),
),
child: Row(
children: [
@@ -305,11 +298,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
icon,
color: color,
size: 24,
),
child: Icon(icon, color: color, size: 24),
),
const SizedBox(width: 16),
Expanded(
@@ -327,19 +316,12 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
const SizedBox(height: 2),
Text(
subtitle,
style: TextStyle(
fontSize: 13,
color: Colors.grey[600],
),
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
),
],
),
),
Icon(
Icons.arrow_forward_ios,
color: Colors.grey[400],
size: 16,
),
Icon(Icons.arrow_forward_ios, color: Colors.grey[400], size: 16),
],
),
),
@@ -424,7 +406,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
return;
}
// Carregar as turmas do professor
// Carregar as disciplinas do professor
List<Map<String, String>> teacherClasses = [];
try {
final snapshot = await _firestore
@@ -440,7 +422,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
if (!mounted) return;
// Se o professor não tem turmas, fazer upload sem associar turma
// Se o professor não tem disciplinas, fazer upload sem associar disciplina
if (teacherClasses.isEmpty) {
await _uploadFile(
filePath: filePath,
@@ -450,7 +432,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
return;
}
// Mostrar diálogo de seleção de turma
// Mostrar diálogo de seleção de disciplina
String? selectedClassId = await showDialog<String>(
context: context,
builder: (dialogContext) {
@@ -461,7 +443,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
borderRadius: BorderRadius.circular(16),
),
title: const Text(
'Escolher Turma',
'Escolher Disciplina',
style: TextStyle(fontWeight: FontWeight.bold),
),
content: Column(
@@ -469,7 +451,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Seleciona a turma que terá acesso a este material:',
'Seleciona a disciplina que terá acesso a este material:',
style: TextStyle(fontSize: 14),
),
const SizedBox(height: 16),
@@ -501,7 +483,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
vertical: 10,
),
),
hint: const Text('Seleciona a turma'),
hint: const Text('Seleciona a disciplina'),
items: teacherClasses
.map(
(c) => DropdownMenuItem<String>(
@@ -510,8 +492,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
),
)
.toList(),
onChanged: (value) =>
setDialogState(() => picked = value),
onChanged: (value) => setDialogState(() => picked = value),
),
],
),
@@ -763,9 +744,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
return Card(
margin: const EdgeInsets.only(bottom: 12),
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
@@ -778,11 +757,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
color: iconColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Icon(
iconData,
color: iconColor,
size: 28,
),
child: Icon(iconData, color: iconColor, size: 28),
),
title: Text(
fileName,