Melhoria no funcionamento do histórico, Os nomes no dashboard do aluno carregam a primeira vez e ficam salvos para n ficarem sempre a carregar quando se volta ao dashboard, removi o butão de novo chat na interface de introdução da IA, mudei a aparencia dessa introdução e do histórico

This commit is contained in:
2026-05-23 16:20:27 +01:00
parent 7ee262f4c7
commit 895ce64c6f
22 changed files with 1330 additions and 582 deletions

View File

@@ -326,11 +326,18 @@ class _ContentManagementPageState extends State<ContentManagementPage> {
child: Column(
children: [
SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.only(
left: 16,
right: 16,
bottom: 20,
top: 52,
),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
icon: Icon(Icons.arrow_back, color: cs.onSurface),

View File

@@ -61,8 +61,14 @@ class _PdfViewerPageState extends State<PdfViewerPage> {
child: Column(
children: [
SafeArea(
top: false,
child: Container(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.only(
left: 16,
right: 16,
bottom: 20,
top: 52,
),
decoration: BoxDecoration(
color: cs.surface.withOpacity(0.8),
boxShadow: [
@@ -74,6 +80,7 @@ class _PdfViewerPageState extends State<PdfViewerPage> {
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
icon: Icon(Icons.arrow_back, color: cs.onSurface),

View File

@@ -200,117 +200,126 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
Widget _buildClassTab({required String classId}) {
return SafeArea(
top: false,
child: Stack(
children: [
StreamBuilder<QuerySnapshot>(
stream: _getMaterialsStream(classId),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(color: Color(0xFF82C9BD)),
);
}
if (snapshot.hasError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
color: Colors.red,
size: 48,
),
const SizedBox(height: 16),
Text(
'Erro ao carregar materiais:\n${snapshot.error}',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 16,
),
),
],
),
);
}
final materials = snapshot.data?.docs ?? [];
// Sort by createdAt descending on client side
materials.sort((a, b) {
final aData = a.data() as Map<String, dynamic>?;
final bData = b.data() as Map<String, dynamic>?;
final aTime = aData?['createdAt'] as Timestamp?;
final bTime = bData?['createdAt'] as Timestamp?;
if (aTime == null && bTime == null) return 0;
if (aTime == null) return 1;
if (bTime == null) return -1;
return bTime.compareTo(aTime);
});
if (materials.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.folder_open,
color: Theme.of(context).colorScheme.onSurfaceVariant,
size: 64,
),
const SizedBox(height: 16),
Text(
'Nenhum material enviado ainda.',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16,
),
),
const SizedBox(height: 8),
Text(
'Os materiais enviados aparecerão aqui.',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14,
),
),
],
),
);
}
return ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: materials.length,
itemBuilder: (context, index) {
final material =
materials[index].data() as Map<String, dynamic>;
final fileName = material['fileName'] ?? 'Ficheiro sem nome';
final createdAt = material['createdAt'] as Timestamp?;
final extension = path.extension(fileName).toLowerCase();
final fileType = extension == '.pdf'
? 'pdf'
: (extension == '.jpg' ||
extension == '.jpeg' ||
extension == '.png')
? 'image'
: 'other';
final docId = materials[index].id;
final url = material['url'] as String?;
return _buildMaterialCard(
docId: docId,
fileName: fileName,
fileType: fileType,
createdAt: createdAt,
url: url,
classId: classId,
Padding(
padding: const EdgeInsets.only(top: 52.0),
child: StreamBuilder<QuerySnapshot>(
stream: _getMaterialsStream(classId),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(color: Color(0xFF82C9BD)),
);
},
);
},
}
if (snapshot.hasError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
color: Colors.red,
size: 48,
),
const SizedBox(height: 16),
Text(
'Erro ao carregar materiais:\n${snapshot.error}',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 16,
),
),
],
),
);
}
final materials = snapshot.data?.docs ?? [];
// Sort by createdAt descending on client side
materials.sort((a, b) {
final aData = a.data() as Map<String, dynamic>?;
final bData = b.data() as Map<String, dynamic>?;
final aTime = aData?['createdAt'] as Timestamp?;
final bTime = bData?['createdAt'] as Timestamp?;
if (aTime == null && bTime == null) return 0;
if (aTime == null) return 1;
if (bTime == null) return -1;
return bTime.compareTo(aTime);
});
if (materials.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.folder_open,
color: Theme.of(context).colorScheme.onSurfaceVariant,
size: 64,
),
const SizedBox(height: 16),
Text(
'Nenhum material enviado ainda.',
style: TextStyle(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
fontSize: 16,
),
),
const SizedBox(height: 8),
Text(
'Os materiais enviados aparecerão aqui.',
style: TextStyle(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
fontSize: 14,
),
),
],
),
);
}
return ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: materials.length,
itemBuilder: (context, index) {
final material =
materials[index].data() as Map<String, dynamic>;
final fileName =
material['fileName'] ?? 'Ficheiro sem nome';
final createdAt = material['createdAt'] as Timestamp?;
final extension = path.extension(fileName).toLowerCase();
final fileType = extension == '.pdf'
? 'pdf'
: (extension == '.jpg' ||
extension == '.jpeg' ||
extension == '.png')
? 'image'
: 'other';
final docId = materials[index].id;
final url = material['url'] as String?;
return _buildMaterialCard(
docId: docId,
fileName: fileName,
fileType: fileType,
createdAt: createdAt,
url: url,
classId: classId,
);
},
);
},
),
),
Positioned(
right: 16,