Finalização de detalhes e pequenas adições em dashboards de alunos e professores

This commit is contained in:
2026-05-18 22:48:27 +01:00
parent c0ade9ef76
commit 7f12f3eb1f
58 changed files with 1347 additions and 1065 deletions

View File

@@ -23,6 +23,8 @@ class AnalyticsPage extends StatefulWidget {
class _AnalyticsPageState extends State<AnalyticsPage>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final _classSearchController = TextEditingController();
String _classSearchQuery = '';
List<ClassStats> _classStats = [];
bool _loading = true;
String? _selectedClassId;
@@ -38,6 +40,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
@override
void dispose() {
_tabController.dispose();
_classSearchController.dispose();
super.dispose();
}
@@ -46,7 +49,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
final user = AuthService.currentUser;
if (user == null) return;
// Obter disciplinas do professor
// Obter turmas do professor
final classesSnapshot = await FirebaseFirestore.instance
.collection('classes')
.where('teacherId', isEqualTo: user.uid)
@@ -85,7 +88,6 @@ class _AnalyticsPageState extends State<AnalyticsPage>
@override
Widget build(BuildContext context) {
final themeExtras = AppThemeExtras.of(context);
final cs = Theme.of(context).colorScheme;
return PopScope(
canPop: false,
@@ -94,9 +96,9 @@ class _AnalyticsPageState extends State<AnalyticsPage>
context.go('/teacher-dashboard');
},
child: Scaffold(
backgroundColor: cs.surface,
backgroundColor: Colors.transparent,
resizeToAvoidBottomInset: false,
body: Container(
body: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
@@ -106,6 +108,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
),
child: SafeArea(
bottom: false,
child: Column(
children: [
// Header
@@ -137,7 +140,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
const SizedBox(height: 4),
Text(
'Acompanhe o desempenho das disciplinas',
'Acompanhe o desempenho das turmas',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 16,
@@ -163,7 +166,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
indicatorColor: Colors.white,
indicatorWeight: 2,
tabs: const [
Tab(text: 'Disciplinas'),
Tab(text: 'Turmas'),
Tab(text: 'Alunos'),
],
),
@@ -205,7 +208,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
const SizedBox(height: 16),
Text(
'Nenhuma disciplina encontrada',
'Nenhuma turma encontrada',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.7),
fontSize: 18,
@@ -213,7 +216,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
const SizedBox(height: 8),
Text(
'Crie disciplinas para ver as analytics aqui',
'Crie turmas para ver as analytics aqui',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 14,
@@ -224,47 +227,131 @@ class _AnalyticsPageState extends State<AnalyticsPage>
);
}
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Overview Cards
Row(
children: [
Expanded(
child: _buildOverviewCard(
'Total de Alunos',
'${_classStats.fold(0, (sum, stats) => sum + stats.totalStudents)}',
Icons.people,
Colors.blue,
),
),
const SizedBox(width: 12),
Expanded(
child: _buildOverviewCard(
'Alunos Ativos',
'${_classStats.fold(0, (sum, stats) => sum + stats.activeStudents)}',
Icons.trending_up,
Colors.green,
),
),
],
),
const SizedBox(height: 20),
final filtered = _classSearchQuery.isEmpty
? _classStats
: _classStats
.where(
(s) => s.className.toLowerCase().contains(_classSearchQuery),
)
.toList();
// Class Cards
..._classStats.map(
(stats) => Padding(
padding: const EdgeInsets.only(bottom: 16),
child: ClassAnalyticsCard(
classStats: stats,
onTap: () => _showClassStudents(stats),
return CustomScrollView(
slivers: [
SliverPadding(
padding: const EdgeInsets.fromLTRB(24, 24, 24, 0),
sliver: SliverToBoxAdapter(
child: Column(
children: [
// Overview Cards
Center(
child: _buildOverviewCard(
'Total de Alunos',
'${_classStats.fold(0, (sum, s) => sum + s.totalStudents)}',
Icons.people,
Colors.blue,
),
),
const SizedBox(height: 20),
// Search bar
Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withValues(alpha: 0.2),
),
),
child: Row(
children: [
Icon(
Icons.search,
color: Colors.white.withValues(alpha: 0.7),
size: 20,
),
const SizedBox(width: 10),
Expanded(
child: Theme(
data: ThemeData.dark().copyWith(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: Colors.white,
selectionColor: Colors.white24,
selectionHandleColor: Colors.white,
),
),
child: TextField(
controller: _classSearchController,
onChanged: (v) => setState(
() => _classSearchQuery = v.trim().toLowerCase(),
),
style: const TextStyle(
color: Colors.white,
fontSize: 14,
),
cursorColor: Colors.white,
decoration: InputDecoration(
hintText: 'Pesquisar turma…',
hintStyle: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 14,
),
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
),
),
),
if (_classSearchQuery.isNotEmpty)
GestureDetector(
onTap: () {
_classSearchController.clear();
setState(() => _classSearchQuery = '');
},
child: Icon(
Icons.close,
color: Colors.white.withValues(alpha: 0.7),
size: 18,
),
),
],
),
),
const SizedBox(height: 20),
],
),
),
),
if (filtered.isEmpty)
SliverFillRemaining(
hasScrollBody: false,
child: Center(
child: Text(
'Nenhuma turma encontrada',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.6),
fontSize: 15,
),
),
),
)
else
SliverPadding(
padding: const EdgeInsets.fromLTRB(24, 0, 24, 24),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ClassAnalyticsCard(
classStats: filtered[index],
onTap: () => _showClassStudents(filtered[index]),
),
childCount: filtered.length,
),
),
),
],
),
],
);
}
@@ -281,7 +368,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
const SizedBox(height: 16),
Text(
'Seleciona uma disciplina',
'Seleciona uma turma',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.7),
fontSize: 18,
@@ -289,7 +376,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
),
const SizedBox(height: 8),
Text(
'Clica numa disciplina no separador "Disciplinas" para ver os alunos',
'Clica numa turma no separador "Turmas" para ver os alunos',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 14,

View File

@@ -76,7 +76,10 @@ class ClassAnalyticsCard extends StatelessWidget {
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(16),
@@ -84,7 +87,11 @@ class ClassAnalyticsCard extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.trending_up, color: Colors.white, size: 16),
const Icon(
Icons.trending_up,
color: Colors.white,
size: 16,
),
const SizedBox(width: 4),
Text(
'${(classStats.averageProgress * 100).toInt()}%',
@@ -190,39 +197,47 @@ class ClassAnalyticsCard extends StatelessWidget {
],
),
const SizedBox(height: 8),
...classStats.studentsNeedingSupport.take(3).map((student) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
children: [
Container(
width: 6,
height: 6,
decoration: const BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
...classStats.studentsNeedingSupport
.take(3)
.map(
(student) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
children: [
Container(
width: 6,
height: 6,
decoration: const BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
student.studentName,
style: TextStyle(
color: Colors.white.withValues(
alpha: 0.8,
),
fontSize: 11,
),
),
),
Text(
'${student.averageScore.toInt()}%',
style: TextStyle(
color: Colors.white.withValues(
alpha: 0.8,
),
fontSize: 11,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
student.studentName,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 11,
),
),
),
Text(
'${student.averageScore.toInt()}%',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 11,
fontWeight: FontWeight.bold,
),
),
],
),
)),
),
if (classStats.studentsNeedingSupport.length > 3)
Text(
'+${classStats.studentsNeedingSupport.length - 3} alunos',
@@ -242,7 +257,7 @@ class ClassAnalyticsCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Ver ranking detalhado',
'Ver alunos da turma',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 12,
@@ -272,7 +287,7 @@ class ClassAnalyticsCard extends StatelessWidget {
bool isWarning = false,
}) {
final cs = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
@@ -285,11 +300,7 @@ class ClassAnalyticsCard extends StatelessWidget {
),
child: Column(
children: [
Icon(
icon,
color: isWarning ? Colors.orange : Colors.white,
size: 20,
),
Icon(icon, color: isWarning ? Colors.orange : Colors.white, size: 20),
const SizedBox(height: 6),
Text(
value,

View File

@@ -269,7 +269,7 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
),
const SizedBox(height: 16),
Text(
'Nenhum aluno na disciplina',
'Nenhum aluno na turma',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.7),
fontSize: 18,

View File

@@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
/// Inline widget (no Scaffold) showing enrolled students for a class,
/// with search, real-time updates, and remove-student functionality.
class ClassStudentsInlineWidget extends StatefulWidget {
final String classId;
final String className;
@@ -21,6 +19,7 @@ class ClassStudentsInlineWidget extends StatefulWidget {
}
class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
final _searchController = TextEditingController();
String _searchQuery = '';
String? _classCode;
late Stream<QuerySnapshot> _enrollmentsStream;
@@ -32,13 +31,6 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
_initStream();
}
void _initStream() {
_enrollmentsStream = FirebaseFirestore.instance
.collection('enrollments')
.where('classId', isEqualTo: widget.classId)
.snapshots();
}
@override
void didUpdateWidget(ClassStudentsInlineWidget oldWidget) {
super.didUpdateWidget(oldWidget);
@@ -48,20 +40,30 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
}
}
@override
void dispose() {
_searchController.dispose();
super.dispose();
}
void _initStream() {
_enrollmentsStream = FirebaseFirestore.instance
.collection('enrollments')
.where('classId', isEqualTo: widget.classId)
.snapshots();
}
Future<void> _loadClassCode() async {
final doc = await FirebaseFirestore.instance
.collection('classes')
.doc(widget.classId)
.get();
if (mounted) {
setState(() {
_classCode = doc.data()?['code'] as String? ?? '';
});
setState(() => _classCode = doc.data()?['code'] as String? ?? '');
}
}
Future<void> _removeStudent(
BuildContext context,
Future<void> _confirmRemove(
String enrollmentDocId,
String studentName,
) async {
@@ -72,7 +74,7 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: const Text('Remover aluno'),
content: Text(
'Tens a certeza que queres remover "$studentName" desta disciplina?',
'Tens a certeza que queres remover "$studentName" desta turma?',
),
actions: [
TextButton(
@@ -87,15 +89,187 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
],
),
);
if (confirmed != true) return;
await _deleteEnrollment(enrollmentDocId, studentName);
}
Future<void> _deleteEnrollment(
String enrollmentDocId,
String studentName,
) async {
final cs = Theme.of(context).colorScheme;
try {
await FirebaseFirestore.instance
.collection('enrollments')
.doc(enrollmentDocId)
.delete();
if (mounted) {
if (!mounted) return;
ScaffoldMessenger.of(context)
..clearSnackBars()
..showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
backgroundColor: cs.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
content: Text(
'"$studentName" foi removido da turma.',
style: const TextStyle(color: Colors.white),
),
),
);
} catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Erro ao remover: $e')));
}
}
// ── Build ──────────────────────────────────────────────────────────────────
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return StreamBuilder<QuerySnapshot>(
stream: _enrollmentsStream,
builder: (context, snapshot) {
final docs = snapshot.data?.docs ?? [];
final enrollments = List<QueryDocumentSnapshot>.from(docs)
..sort((a, b) {
final aTs = (a.data() as Map)['joinedAt'] as Timestamp?;
final bTs = (b.data() as Map)['joinedAt'] as Timestamp?;
if (aTs == null && bTs == null) return 0;
if (aTs == null) return 1;
if (bTs == null) return -1;
return aTs.compareTo(bTs);
});
final filtered = _searchQuery.isEmpty
? enrollments
: enrollments.where((doc) {
final d = doc.data() as Map<String, dynamic>;
final name = (d['studentName'] as String? ?? '').toLowerCase();
final email = (d['studentEmail'] as String? ?? '')
.toLowerCase();
return name.contains(_searchQuery) ||
email.contains(_searchQuery);
}).toList();
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
return CustomScrollView(
physics: const NeverScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
sliver: SliverToBoxAdapter(
child: _buildHeader(cs, enrollments.length, snapshot),
),
),
SliverPadding(
padding: const EdgeInsets.fromLTRB(20, 14, 20, 0),
sliver: SliverToBoxAdapter(child: _buildSearchBar()),
),
if (snapshot.connectionState == ConnectionState.waiting &&
snapshot.data == null)
const SliverFillRemaining(
child: Center(
child: CircularProgressIndicator(color: Colors.white),
),
)
else if (filtered.isEmpty) ...[
SliverFillRemaining(
hasScrollBody: false,
child: Padding(
padding: EdgeInsets.only(bottom: bottomInset),
child: _buildEmpty(cs),
),
),
] else
SliverPadding(
padding: EdgeInsets.fromLTRB(20, 14, 20, 20 + bottomInset),
sliver: SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
final doc = filtered[index];
final data = doc.data() as Map<String, dynamic>;
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: _buildStudentCard(
cs: cs,
enrollmentDocId: doc.id,
studentName:
data['studentName'] as String? ?? 'Aluno sem nome',
studentEmail: data['studentEmail'] as String? ?? '',
joinedAt: data['joinedAt'] as Timestamp?,
),
);
}, childCount: filtered.length),
),
),
],
);
},
);
}
// ── Sub-widgets ────────────────────────────────────────────────────────────
Widget _buildHeader(
ColorScheme cs,
int count,
AsyncSnapshot<QuerySnapshot> snapshot,
) {
return Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [cs.primary, cs.primary.withValues(alpha: 0.8)],
),
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.className,
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
snapshot.connectionState == ConnectionState.waiting &&
snapshot.data == null
? 'A carregar…'
: '$count aluno${count == 1 ? '' : 's'} inscrito${count == 1 ? '' : 's'}',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.85),
fontSize: 13,
),
),
],
),
),
_buildCodeBadge(cs),
],
),
);
}
Widget _buildCodeBadge(ColorScheme cs) {
return GestureDetector(
onTap: () {
if (_classCode == null || _classCode == '') return;
Clipboard.setData(ClipboardData(text: _classCode!));
ScaffoldMessenger.of(context)
..clearSnackBars()
..showSnackBar(
@@ -106,287 +280,124 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
content: Text(
'"$studentName" foi removido da disciplina.',
style: const TextStyle(color: Colors.white),
duration: const Duration(seconds: 2),
content: const Text(
'Código copiado!',
style: TextStyle(color: Colors.white),
),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Erro ao remover aluno: $e')));
}
}
}
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return StreamBuilder<QuerySnapshot>(
stream: _enrollmentsStream,
builder: (context, snapshot) {
// Keep showing previous data while new data loads (prevents flash)
final docs = snapshot.data?.docs ?? [];
// Sort client-side by joinedAt ascending
final enrollments = List<QueryDocumentSnapshot>.from(docs)
..sort((a, b) {
final aData = a.data() as Map<String, dynamic>;
final bData = b.data() as Map<String, dynamic>;
final aTs = aData['joinedAt'] as Timestamp?;
final bTs = bData['joinedAt'] as Timestamp?;
if (aTs == null && bTs == null) return 0;
if (aTs == null) return 1;
if (bTs == null) return -1;
return aTs.compareTo(bTs);
});
final filtered = _searchQuery.isEmpty
? enrollments
: enrollments.where((doc) {
final data = doc.data() as Map<String, dynamic>;
final name = (data['studentName'] as String? ?? '')
.toLowerCase();
final email = (data['studentEmail'] as String? ?? '')
.toLowerCase();
final q = _searchQuery.toLowerCase();
return name.contains(q) || email.contains(q);
}).toList();
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
return Padding(
padding: EdgeInsets.only(bottom: bottomInset),
child: Container(
margin: const EdgeInsets.all(20),
child: Column(
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.18),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.white.withValues(alpha: 0.3)),
),
child: Column(
children: [
const Text(
'Código',
style: TextStyle(
color: Colors.white70,
fontSize: 10,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
_classCode ?? '',
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
letterSpacing: 2,
),
),
const SizedBox(height: 2),
Row(
mainAxisSize: MainAxisSize.min,
children: [
// ── Header ──────────────────────────────────────────────────
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [cs.primary, cs.primary.withValues(alpha: 0.8)],
),
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.className,
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
snapshot.connectionState ==
ConnectionState.waiting
? 'A carregar…'
: '${enrollments.length} aluno${enrollments.length == 1 ? '' : 's'} inscrito${enrollments.length == 1 ? '' : 's'}',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.85),
fontSize: 13,
),
),
],
),
),
// Código da disciplina
GestureDetector(
onTap: () {
if (_classCode != null && _classCode != '') {
Clipboard.setData(ClipboardData(text: _classCode!));
ScaffoldMessenger.of(context)
..clearSnackBars()
..showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 12,
),
backgroundColor: cs.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
duration: const Duration(seconds: 2),
content: const Text(
'Código copiado!',
style: TextStyle(color: Colors.white),
),
),
);
}
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.18),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withValues(alpha: 0.3),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
'Código',
style: TextStyle(
color: Colors.white70,
fontSize: 10,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
_classCode ?? '',
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
letterSpacing: 2,
),
),
const SizedBox(height: 2),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.copy,
color: Colors.white.withValues(alpha: 0.7),
size: 10,
),
const SizedBox(width: 3),
Text(
'copiar',
style: TextStyle(
color: Colors.white.withValues(
alpha: 0.7,
),
fontSize: 9,
),
),
],
),
],
),
),
),
],
),
Icon(
Icons.copy,
color: Colors.white.withValues(alpha: 0.7),
size: 10,
),
const SizedBox(height: 14),
// ── Search bar ──────────────────────────────────────────────
Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
const SizedBox(width: 3),
Text(
'copiar',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.7),
fontSize: 9,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withValues(alpha: 0.2),
),
),
child: Row(
children: [
Icon(
Icons.search,
color: Colors.white.withValues(alpha: 0.7),
size: 20,
),
const SizedBox(width: 10),
Expanded(
child: TextField(
onChanged: (v) =>
setState(() => _searchQuery = v.trim()),
style: const TextStyle(
color: Colors.white,
fontSize: 14,
),
cursorColor: Colors.white,
decoration: InputDecoration(
hintText: 'Pesquisar aluno…',
hintStyle: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 14,
),
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
),
),
if (_searchQuery.isNotEmpty)
GestureDetector(
onTap: () => setState(() => _searchQuery = ''),
child: Icon(
Icons.close,
color: Colors.white.withValues(alpha: 0.7),
size: 18,
),
),
],
),
),
const SizedBox(height: 14),
// ── List ────────────────────────────────────────────────────
Expanded(
child:
snapshot.connectionState == ConnectionState.waiting &&
snapshot.data == null
? const Center(
child: CircularProgressIndicator(color: Colors.white),
)
: filtered.isEmpty
? _buildEmpty(cs)
: ListView.separated(
padding: EdgeInsets.zero,
itemCount: filtered.length,
separatorBuilder: (_, __) =>
const SizedBox(height: 10),
itemBuilder: (context, index) {
final doc = filtered[index];
final data = doc.data() as Map<String, dynamic>;
final studentName =
data['studentName'] as String? ??
'Aluno sem nome';
final studentEmail =
data['studentEmail'] as String? ?? '';
final joinedAt = data['joinedAt'] as Timestamp?;
final enrollmentDocId = doc.id;
return _buildStudentCard(
cs: cs,
enrollmentDocId: enrollmentDocId,
studentName: studentName,
studentEmail: studentEmail,
joinedAt: joinedAt,
index: index,
);
},
),
),
],
),
],
),
),
);
}
Widget _buildSearchBar() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.white.withValues(alpha: 0.2)),
),
child: Row(
children: [
Icon(
Icons.search,
color: Colors.white.withValues(alpha: 0.7),
size: 20,
),
);
},
const SizedBox(width: 10),
Expanded(
child: Theme(
data: ThemeData.dark().copyWith(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: Colors.white,
selectionColor: Colors.white24,
selectionHandleColor: Colors.white,
),
),
child: TextField(
controller: _searchController,
onChanged: (v) =>
setState(() => _searchQuery = v.trim().toLowerCase()),
style: const TextStyle(color: Colors.white, fontSize: 14),
cursorColor: Colors.white,
decoration: InputDecoration(
hintText: 'Pesquisar aluno…',
hintStyle: TextStyle(
color: Colors.white.withValues(alpha: 0.5),
fontSize: 14,
),
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
),
),
),
if (_searchQuery.isNotEmpty)
GestureDetector(
onTap: () {
_searchController.clear();
setState(() => _searchQuery = '');
},
child: Icon(
Icons.close,
color: Colors.white.withValues(alpha: 0.7),
size: 18,
),
),
],
),
);
}
@@ -396,7 +407,6 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
required String studentName,
required String studentEmail,
required Timestamp? joinedAt,
required int index,
}) {
return Dismissible(
key: Key(enrollmentDocId),
@@ -410,7 +420,7 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
),
title: const Text('Remover aluno'),
content: Text(
'Tens a certeza que queres remover "$studentName" desta disciplina?',
'Tens a certeza que queres remover "$studentName" desta turma?',
),
actions: [
TextButton(
@@ -427,41 +437,7 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
);
return confirmed ?? false;
},
onDismissed: (_) async {
try {
await FirebaseFirestore.instance
.collection('enrollments')
.doc(enrollmentDocId)
.delete();
if (mounted) {
ScaffoldMessenger.of(context)
..clearSnackBars()
..showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 12,
),
backgroundColor: cs.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
content: Text(
'"$studentName" foi removido da disciplina.',
style: const TextStyle(color: Colors.white),
),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Erro ao remover: $e')));
}
}
},
onDismissed: (_) => _deleteEnrollment(enrollmentDocId, studentName),
background: Container(
decoration: BoxDecoration(
color: cs.error.withValues(alpha: 0.85),
@@ -480,7 +456,6 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
),
child: Row(
children: [
// Avatar with initial
Container(
width: 42,
height: 42,
@@ -500,7 +475,6 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
),
),
const SizedBox(width: 14),
// Info
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -536,7 +510,6 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
],
),
),
// Remove button
IconButton(
icon: Icon(
Icons.person_remove_outlined,
@@ -544,8 +517,7 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
size: 20,
),
tooltip: 'Remover aluno',
onPressed: () =>
_removeStudent(context, enrollmentDocId, studentName),
onPressed: () => _confirmRemove(enrollmentDocId, studentName),
),
],
),
@@ -595,7 +567,7 @@ class _ClassStudentsInlineWidgetState extends State<ClassStudentsInlineWidget> {
),
const SizedBox(height: 6),
Text(
'Partilha o código da disciplina com os alunos.',
'Partilha o código da turma com os alunos.',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.45),
fontSize: 13,

View File

@@ -217,10 +217,12 @@ class _LoginPageState extends State<LoginPage> {
? AppThemeExtras.of(context).authBackgroundGradient
: [
Theme.of(context).colorScheme.background,
Theme.of(context).colorScheme.primary
.withOpacity(0.1),
Theme.of(context).colorScheme.secondary
.withOpacity(0.05),
Theme.of(
context,
).colorScheme.primary.withOpacity(0.1),
Theme.of(
context,
).colorScheme.secondary.withOpacity(0.05),
Theme.of(context).colorScheme.background,
],
),
@@ -239,55 +241,26 @@ class _LoginPageState extends State<LoginPage> {
// Logo/Title
Container(
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surface.withOpacity(0.9),
borderRadius: BorderRadius.circular(16.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10.0,
offset: const Offset(0, 4),
),
],
width: double.infinity,
height: 84,
decoration: const BoxDecoration(
color: Color(0xFFF9EEE8),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Column(
children: [
Text(
'EPVC',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
foreground: Paint()
..shader =
LinearGradient(
colors: [
Theme.of(
context,
).colorScheme.primary,
Theme.of(
context,
).colorScheme.secondary,
],
).createShader(
Rect.fromLTWH(0, 0, 200, 20),
),
child: Center(
child: SizedBox(
width: 140,
height: 140,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.asset(
'assets/images/logo.png',
fit: BoxFit.cover,
),
),
const SizedBox(height: 8),
Text(
'Escola Profissional de Vila do Conde',
style: TextStyle(
fontSize: 14,
color: Theme.of(
context,
).colorScheme.onSurface,
fontWeight: FontWeight.w500,
),
),
],
),
),
).animate().fadeIn(
duration: const Duration(milliseconds: 800),

View File

@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/theme/app_theme_extension.dart';
import '../../../../l10n/app_localizations.dart';
class RoleSelectionPage extends StatefulWidget {
const RoleSelectionPage({super.key});
@@ -43,115 +42,61 @@ class _RoleSelectionPageState extends State<RoleSelectionPage> {
padding: const EdgeInsets.all(24.0),
child: Column(
children: [
const SizedBox(height: 60),
const Spacer(flex: 1),
// Logo and title
Center(
child: Column(
children: [
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context)
.actionCardGradientStart,
AppThemeExtras.of(context)
.actionCardGradientEnd,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.3),
blurRadius: 25,
offset: const Offset(0, 10),
),
],
),
child: const Icon(
Icons.school,
size: 50,
color: Colors.white,
),
)
.animate()
.scale(
duration: const Duration(milliseconds: 800),
curve: Curves.elasticOut,
)
.then()
.shimmer(
duration: const Duration(milliseconds: 2000),
color: Colors.white.withOpacity(0.4),
),
const SizedBox(height: 32),
Text(
AppLocalizations.of(context)!.appTitle,
style: Theme.of(context).textTheme.headlineLarge
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
)
.animate()
.fadeIn(
duration: const Duration(milliseconds: 800),
delay: const Duration(milliseconds: 200),
)
.slideY(
duration: const Duration(milliseconds: 600),
delay: const Duration(milliseconds: 200),
begin: -0.3,
),
const SizedBox(height: 12),
ShaderMask(
shaderCallback: (bounds) => LinearGradient(
colors: [
Theme.of(context).colorScheme.primary,
Theme.of(context).colorScheme.secondary,
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
).createShader(bounds),
child: Text(
AppLocalizations.of(context)!.schoolName,
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: Colors.white,
fontWeight: FontWeight.w600,
),
),
)
.animate()
.fadeIn(
duration: const Duration(milliseconds: 800),
delay: const Duration(milliseconds: 400),
)
.slideY(
duration: const Duration(milliseconds: 600),
delay: const Duration(milliseconds: 400),
begin: -0.2,
),
],
// Wide rectangle with image at top
Container(
width: double.infinity,
height: 84,
decoration: const BoxDecoration(
color: Color(0xFFF9EEE8),
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: Center(
child: SizedBox(
width: 140,
height: 140,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.asset(
'assets/images/logo.png',
fit: BoxFit.cover,
),
),
),
),
).animate().fadeIn(
duration: const Duration(milliseconds: 800),
delay: const Duration(milliseconds: 200),
),
const Spacer(),
const SizedBox(height: 24),
// Role selection title
ShaderMask(
shaderCallback: (bounds) => LinearGradient(
colors: [
Theme.of(context).colorScheme.primary,
Theme.of(context).colorScheme.secondary,
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
).createShader(bounds),
child: Text(
'Assistente de estudo IA',
style: Theme.of(context).textTheme.headlineSmall
?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
).animate().fadeIn(
duration: const Duration(milliseconds: 800),
delay: const Duration(milliseconds: 300),
),
const SizedBox(height: 32),
// Title
Text(
'Quem é você?',
style: Theme.of(context).textTheme.headlineMedium
@@ -239,15 +184,16 @@ class _RoleSelectionPageState extends State<RoleSelectionPage> {
? _handleContinue
: null,
style: ElevatedButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
foregroundColor: Theme.of(
context,
).colorScheme.onPrimary,
elevation: 4,
shadowColor: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.3),
shadowColor: Theme.of(
context,
).colorScheme.primary.withOpacity(0.3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
@@ -290,6 +236,8 @@ class _RoleSelectionPageState extends State<RoleSelectionPage> {
),
const SizedBox(height: 32),
const Spacer(flex: 1),
],
),
),
@@ -338,7 +286,9 @@ class _RoleSelectionPageState extends State<RoleSelectionPage> {
border: Border.all(
color: isSelected
? gradientColor
: Theme.of(context).colorScheme.primary.withOpacity(0.2),
: Theme.of(
context,
).colorScheme.primary.withOpacity(0.2),
width: isSelected ? 2 : 1,
),
boxShadow: [

View File

@@ -270,57 +270,26 @@ class _SignupPageState extends State<SignupPage> {
// Logo/Title
Container(
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surface.withOpacity(0.9),
borderRadius: BorderRadius.circular(16.0),
boxShadow: [
BoxShadow(
color: Theme.of(
context,
).colorScheme.shadow.withOpacity(0.1),
blurRadius: 10.0,
offset: const Offset(0, 4),
),
],
width: double.infinity,
height: 84,
decoration: const BoxDecoration(
color: Color(0xFFF9EEE8),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: Column(
children: [
Text(
'EPVC',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
foreground: Paint()
..shader =
LinearGradient(
colors: [
Theme.of(
context,
).colorScheme.primary,
Theme.of(
context,
).colorScheme.secondary,
],
).createShader(
Rect.fromLTWH(0, 0, 200, 20),
),
child: Center(
child: SizedBox(
width: 140,
height: 140,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.asset(
'assets/images/logo.png',
fit: BoxFit.cover,
),
),
const SizedBox(height: 8),
Text(
'Escola Profissional de Vila do Conde',
style: TextStyle(
fontSize: 14,
color: Theme.of(
context,
).colorScheme.onSurface,
fontWeight: FontWeight.w500,
),
),
],
),
),
).animate().fadeIn(
duration: const Duration(milliseconds: 800),

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../../../../core/services/auth_service.dart';
/// Página para visualizar os alunos de uma disciplina específica
/// Página para visualizar os alunos de uma turma específica
class ClassStudentsPage extends StatefulWidget {
final String classId;
final String className;
@@ -97,7 +97,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
),
const SizedBox(height: 12),
Text(
'Só podes ver os alunos das tuas próprias disciplinas.',
'Só podes ver os alunos das tuas próprias turmas.',
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14),
textAlign: TextAlign.center,
),
@@ -183,7 +183,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
),
const SizedBox(height: 24),
Text(
'Nenhum aluno entrou nesta disciplina ainda.',
'Nenhum aluno entrou nesta turma ainda.',
style: TextStyle(
color: cs.onSurfaceVariant,
fontSize: 16,
@@ -192,7 +192,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
),
const SizedBox(height: 8),
Text(
'Partilha o código da disciplina para os alunos se juntarem.',
'Partilha o código da turma para os alunos se juntarem.',
style: TextStyle(
color: cs.onSurfaceVariant.withValues(alpha: 0.7),
fontSize: 13,
@@ -215,6 +215,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
final studentName =
enrollment['studentName'] as String? ?? 'Aluno sem nome';
final joinedAt = enrollment['joinedAt'] as Timestamp?;
final enrollmentId = enrollments[index].id;
return Container(
decoration: BoxDecoration(
@@ -263,6 +264,15 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
),
),
),
trailing: IconButton(
icon: Icon(Icons.delete_outline, color: cs.error),
onPressed: () => _showRemoveStudentDialog(
context,
enrollmentId,
studentName,
),
tooltip: 'Remover aluno',
),
),
);
},
@@ -275,4 +285,82 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
String _formatDate(DateTime date) {
return DateFormat('dd/MM/yyyy').format(date);
}
Future<void> _showRemoveStudentDialog(
BuildContext context,
String enrollmentId,
String studentName,
) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Remover Aluno'),
content: Text(
'Tem a certeza que deseja remover $studentName desta turma?',
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Cancelar'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.error,
),
child: const Text('Remover'),
),
],
),
);
if (confirmed == true && context.mounted) {
try {
await FirebaseFirestore.instance
.collection('enrollments')
.doc(enrollmentId)
.delete();
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
Icon(Icons.check_circle, color: Colors.white),
const SizedBox(width: 12),
const Text('Aluno removido com sucesso'),
],
),
backgroundColor: Colors.green,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
duration: const Duration(seconds: 3),
),
);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
Icon(Icons.error_outline, color: Colors.white),
const SizedBox(width: 12),
Text('Erro ao remover aluno: $e'),
],
),
backgroundColor: Colors.red,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
duration: const Duration(seconds: 4),
),
);
}
}
}
}
}

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import '../../../dashboard/presentation/widgets/teacher_classes_list_widget.dart';
/// Página dedicada para o professor ver todas as suas disciplinas
/// Página dedicada para o professor ver todas as suas turmas
/// Reutiliza o TeacherClassesListWidget existente
class TeacherAllClassesPage extends StatelessWidget {
const TeacherAllClassesPage({super.key});
@@ -18,7 +18,7 @@ class TeacherAllClassesPage extends StatelessWidget {
onPressed: () => Navigator.of(context).pop(),
),
title: const Text(
'As Minhas Disciplinas',
'As Minhas Turmas',
style: TextStyle(
color: Colors.white,
fontSize: 18,

View File

@@ -6,7 +6,6 @@ import '../../../../core/routing/app_router.dart';
import '../widgets/teacher_hero_widget.dart';
import '../widgets/teacher_quick_actions_widget.dart';
import '../widgets/teacher_classes_list_widget.dart';
import '../widgets/teacher_analytics_preview_widget.dart';
class TeacherDashboardPage extends StatefulWidget {
const TeacherDashboardPage({super.key});
@@ -162,11 +161,6 @@ class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
// Classes List Section
const TeacherClassesListWidget(),
const SizedBox(height: 24),
// Analytics Preview Section
const TeacherAnalyticsPreviewWidget(),
const SizedBox(height: 40),
],
),

View File

@@ -245,7 +245,7 @@ class DashboardActionCard extends StatelessWidget {
}
}
/// Surface-styled vertical card (Quiz, Criar Disciplina, etc.).
/// Surface-styled vertical card (Quiz, Criar Turma, etc.).
class DashboardActionCardSurface extends StatelessWidget {
const DashboardActionCardSurface({
super.key,

View File

@@ -187,24 +187,27 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
const SizedBox(height: 16),
// Progress Bar
Container(
height: 12,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(6),
),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: overallProgress,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context).heroProgressStart,
AppThemeExtras.of(context).heroProgressEnd,
],
GestureDetector(
onTap: () => _showProgressExplanation(context),
child: Container(
height: 12,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(6),
),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: overallProgress,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context).heroProgressStart,
AppThemeExtras.of(context).heroProgressEnd,
],
),
borderRadius: BorderRadius.circular(6),
),
borderRadius: BorderRadius.circular(6),
),
),
),
@@ -215,10 +218,14 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
Row(
children: [
Expanded(
child: _buildStatCard(
icon: Icons.access_time,
value: '${(studyTimeMinutes / 60).toStringAsFixed(1)}h',
label: 'Tempo de Estudo',
child: GestureDetector(
onTap: () => _showStudyTimeDetails(context, userStats),
child: _buildStatCard(
icon: Icons.access_time,
value:
'${(studyTimeMinutes / 60).toStringAsFixed(1)}h',
label: 'Tempo de Estudo',
),
),
),
const SizedBox(width: 12),
@@ -362,4 +369,111 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
),
);
}
void _showProgressExplanation(BuildContext context) {
final cs = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Row(
children: [
Icon(Icons.info_outline, color: cs.primary),
const SizedBox(width: 8),
const Text('Progresso Geral'),
],
),
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'O Progresso Geral representa a média dos níveis de domínio dos conceitos que já dominaste.',
style: TextStyle(fontSize: 14),
),
SizedBox(height: 12),
Text(
'Como é calculado:',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
SizedBox(height: 8),
Text(
'• Cada conceito tem um nível de 0 a 100\n'
'• O progresso é a média de todos os conceitos dominados\n'
'• Quanto mais alto, melhor o teu domínio',
style: TextStyle(fontSize: 13, color: Colors.grey),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('Entendi'),
),
],
),
);
}
void _showStudyTimeDetails(BuildContext context, UserStats? userStats) {
final cs = Theme.of(context).colorScheme;
final totalMinutes = userStats?.totalStudyTime ?? 0;
final weeklyMinutes = userStats?.weeklyStudyTime ?? 0;
final monthlyMinutes = userStats?.monthlyStudyTime ?? 0;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Row(
children: [
Icon(Icons.access_time, color: cs.primary),
const SizedBox(width: 8),
const Text('Tempo de Estudo'),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildTimeRow('Total', totalMinutes, cs),
const SizedBox(height: 12),
_buildTimeRow('Esta semana', weeklyMinutes, cs),
const SizedBox(height: 12),
_buildTimeRow('Este mês', monthlyMinutes, cs),
const SizedBox(height: 16),
const Text(
'O tempo é contado automaticamente quando completas quizzes.',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('Fechar'),
),
],
),
);
}
Widget _buildTimeRow(String label, int minutes, ColorScheme cs) {
final hours = minutes ~/ 60;
final mins = minutes % 60;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(label, style: TextStyle(fontSize: 14, color: cs.onSurface)),
Text(
hours > 0 ? '${hours}h ${mins}min' : '${mins}min',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: cs.primary,
),
),
],
);
}
}

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import '../../../../core/theme/app_theme_extension.dart';
import '../../../../core/services/auth_service.dart';
import '../../../../core/services/gamification_service.dart';
import '../../../../core/models/class_stats.dart';
@@ -11,10 +10,12 @@ class TeacherAnalyticsPreviewWidget extends StatefulWidget {
const TeacherAnalyticsPreviewWidget({super.key});
@override
State<TeacherAnalyticsPreviewWidget> createState() => _TeacherAnalyticsPreviewWidgetState();
State<TeacherAnalyticsPreviewWidget> createState() =>
_TeacherAnalyticsPreviewWidgetState();
}
class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewWidget> {
class _TeacherAnalyticsPreviewWidgetState
extends State<TeacherAnalyticsPreviewWidget> {
List<StudentRanking> _topStudents = [];
bool _loading = true;
@@ -36,7 +37,7 @@ class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewW
.get();
List<StudentRanking> allStudents = [];
// Buscar ranking de cada turma
for (final classDoc in classesSnapshot.docs) {
final classId = classDoc.id;
@@ -67,232 +68,130 @@ class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewW
@override
Widget build(BuildContext context) {
final user = AuthService.currentUser;
final userName = user?.displayName ?? 'Professor';
final userEmail = user?.email ?? '';
return Container(
margin: const EdgeInsets.only(top: 24),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
_buildQuickStat(
icon: Icons.check_circle,
label: 'Alunos Ativos',
value: '18/24',
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 12),
_buildQuickStat(
icon: Icons.warning_amber,
label: 'Precisam Apoio',
value: '3',
color: Theme.of(context).colorScheme.secondary,
),
const SizedBox(width: 12),
_buildQuickStat(
icon: Icons.emoji_events,
label: 'Média Turma',
value: '72%',
color: Theme.of(context).colorScheme.primary.withOpacity(0.8),
),
],
),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Profile Header
Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context).actionCardGradientStart,
AppThemeExtras.of(context).actionCardGradientEnd,
],
),
borderRadius: BorderRadius.circular(24),
),
child: const Icon(Icons.school, color: Colors.white, size: 24),
const SizedBox(height: 20),
// Top Performing Students Preview
Row(
children: [
Icon(
Icons.leaderboard,
color: Theme.of(context).colorScheme.secondary,
size: 20,
),
const SizedBox(width: 8),
Text(
'Melhores Desempenhos',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold,
),
const SizedBox(width: 16),
),
],
),
const SizedBox(height: 12),
// Student List Preview
if (_loading)
const Center(child: CircularProgressIndicator())
else if (_topStudents.isEmpty)
const Center(
child: Text(
'Nenhum aluno encontrado',
style: TextStyle(fontSize: 14),
),
)
else
..._topStudents.asMap().entries.map((entry) {
final index = entry.key;
final student = entry.value;
final color = _getStudentColor(context, index);
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: _buildStudentPerformanceItem(
context,
student.studentName,
student.overallScore.toInt(),
color,
),
);
}).toList(),
const SizedBox(height: 20),
// Content Quality Alert
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
),
),
child: Row(
children: [
Icon(
Icons.info_outline,
color: Theme.of(context).colorScheme.primary,
size: 20,
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
userName,
'Qualidade do Conteúdo',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 18,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 2),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
userEmail,
style: TextStyle(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
fontSize: 14,
),
),
if (userEmail.length > 20) ...[
const SizedBox(width: 8),
Icon(
Icons.more_horiz,
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
size: 16,
),
],
],
Text(
'12 conteúdos verificados • 2 pendentes de revisão',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 12,
),
),
],
),
),
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.secondary.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.settings,
color: Theme.of(context).colorScheme.secondary,
size: 20,
),
),
],
),
const SizedBox(height: 20),
// Quick Stats Row
Row(
children: [
_buildQuickStat(
icon: Icons.check_circle,
label: 'Alunos Ativos',
value: '18/24',
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 12),
_buildQuickStat(
icon: Icons.warning_amber,
label: 'Precisam Apoio',
value: '3',
color: Theme.of(context).colorScheme.secondary,
),
const SizedBox(width: 12),
_buildQuickStat(
icon: Icons.emoji_events,
label: 'Média Disciplina',
value: '72%',
color: Theme.of(context).colorScheme.primary.withOpacity(0.8),
),
],
),
const SizedBox(height: 20),
// Top Performing Students Preview
Row(
children: [
Icon(
Icons.leaderboard,
color: Theme.of(context).colorScheme.secondary,
size: 20,
),
const SizedBox(width: 8),
Text(
'Melhores Desempenhos',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 12),
// Student List Preview
if (_loading)
const Center(child: CircularProgressIndicator())
else if (_topStudents.isEmpty)
const Center(
child: Text(
'Nenhum aluno encontrado',
style: TextStyle(fontSize: 14),
),
)
else
..._topStudents.asMap().entries.map((entry) {
final index = entry.key;
final student = entry.value;
final color = _getStudentColor(context, index);
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: _buildStudentPerformanceItem(
context,
student.studentName,
student.overallScore.toInt(),
color,
),
);
}).toList(),
const SizedBox(height: 20),
// Content Quality Alert
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
),
),
child: Row(
children: [
Icon(
Icons.info_outline,
color: Theme.of(context).colorScheme.primary,
size: 20,
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Qualidade do Conteúdo',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 2),
Text(
'12 conteúdos verificados • 2 pendentes de revisão',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 12,
),
),
],
),
),
],
),
),
],
),
),
],
);
}

View File

@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import '../../../../core/services/auth_service.dart';
import '../../../classes/presentation/pages/class_students_page.dart';
/// Widget para listar as disciplinas criadas pelo professor
/// Widget para listar as turmas criadas pelo professor
class TeacherClassesListWidget extends StatelessWidget {
const TeacherClassesListWidget({super.key});
@@ -44,7 +44,7 @@ class TeacherClassesListWidget extends StatelessWidget {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Text(
'Ainda não criaste nenhuma disciplina.',
'Ainda não criaste nenhuma turma.',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14,
@@ -65,7 +65,7 @@ class TeacherClassesListWidget extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
'As Minhas Disciplinas',
'As Minhas Turmas',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 20,
@@ -144,7 +144,7 @@ class TeacherClassesListWidget extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(20),
child: Text(
'As Minhas Disciplinas',
'As Minhas Turmas',
style: TextStyle(
color: cs.onSurface,
fontSize: 20,

View File

@@ -31,7 +31,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
final user = AuthService.currentUser;
if (user == null) return;
// Obter disciplinas do professor
// Obter turmas do professor
final classesSnapshot = await FirebaseFirestore.instance
.collection('classes')
.where('teacherId', isEqualTo: user.uid)
@@ -116,7 +116,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Visão Geral da Disciplina',
'Visão Geral da Turma',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 20,
@@ -193,7 +193,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
children: [
const Flexible(
child: Text(
'Progresso Médio da Disciplina',
'Progresso Médio da Turma',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -226,24 +226,27 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
const SizedBox(height: 16),
// Progress Bar
Container(
height: 12,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(6),
),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: classAverageProgress,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context).heroProgressStart,
AppThemeExtras.of(context).heroProgressEnd,
],
GestureDetector(
onTap: () => _showProgressExplanation(context),
child: Container(
height: 12,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(6),
),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: classAverageProgress,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppThemeExtras.of(context).heroProgressStart,
AppThemeExtras.of(context).heroProgressEnd,
],
),
borderRadius: BorderRadius.circular(6),
),
borderRadius: BorderRadius.circular(6),
),
),
),
@@ -369,14 +372,14 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
_buildActivityItem(
context,
'Nenhuma atividade recente',
'Comece criando disciplinas e conteúdos',
'Comece criando turmas e conteúdos',
Theme.of(context).colorScheme.onSurfaceVariant,
),
);
return activities;
}
// Adicionar atividades baseadas nas estatísticas das disciplinas
// Adicionar atividades baseadas nas estatísticas das turmas
for (final stats in _classStats.take(3)) {
if (stats.activeQuizzes > 0) {
activities.add(
@@ -425,7 +428,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
_buildActivityItem(
context,
'Nenhuma atividade recente',
'Comece criando disciplinas e conteúdos',
'Comece criando turmas e conteúdos',
Theme.of(context).colorScheme.onSurfaceVariant,
),
]
@@ -473,4 +476,24 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
],
);
}
void _showProgressExplanation(BuildContext context) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Progresso Médio da Turma'),
content: const Text(
'O progresso médio da turma é calculado com base no domínio dos conceitos por cada aluno. '
'Cada aluno tem um nível de domínio para cada conceito (0-100%), e o progresso médio '
'é a média de todos esses níveis de domínio em toda a turma.',
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Entendi'),
),
],
),
);
}
}

View File

@@ -20,7 +20,7 @@ class TeacherQuickActionsWidget extends StatefulWidget {
class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
bool _isCreatingClass = false;
/// Mesmas dimensões dos cards em "As Minhas Disciplinas".
/// Mesmas dimensões dos cards em "As Minhas Turmas".
static const double _scrollCardWidth = 200;
static const double _scrollRowHeight = 156;
static const double _cardMinHeight = 156;
@@ -128,7 +128,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
final cs = Theme.of(context).colorScheme;
return DashboardActionCardSurface(
title: 'Analytics',
subtitle: 'Desempenho da disciplina',
subtitle: 'Desempenho da turma',
icon: Icons.analytics,
minHeight: _cardMinHeight,
titleFontSize: _titleFontSize,
@@ -142,7 +142,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
color: cs.primary.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Icon(Icons.analytics, color: cs.primary, size: _iconSize),
child: const Icon(Icons.analytics, color: Colors.blue, size: 28),
),
onTap: () => context.go('/teacher/analytics'),
);
@@ -153,7 +153,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
return ClipRRect(
borderRadius: BorderRadius.circular(16),
child: DashboardActionCardSurface(
title: 'Criar Disciplina',
title: 'Criar Turma',
subtitle: 'Gerar código de acesso',
icon: Icons.school,
minHeight: _cardMinHeight,
@@ -202,7 +202,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
},
),
_TeacherActionItem(
title: 'Criar Disciplina',
title: 'Criar Turma',
subtitle: 'Gerar código de acesso',
icon: Icons.school,
onTap: () {
@@ -221,7 +221,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
),
_TeacherActionItem(
title: 'Analytics',
subtitle: 'Desempenho da disciplina',
subtitle: 'Desempenho da turma',
icon: Icons.analytics,
onTap: () {
Navigator.pop(context);
@@ -367,7 +367,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
borderRadius: BorderRadius.circular(16),
),
title: Text(
'Criar Nova Disciplina',
'Criar Nova Turma',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
@@ -378,7 +378,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Nome da disciplina:',
'Nome da turma:',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14,
@@ -432,7 +432,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
),
const SizedBox(width: 10),
Text(
'A carregar disciplinas...',
'A carregar turmas...',
style: TextStyle(
color: Theme.of(
context,
@@ -571,7 +571,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Disciplina "$className" criada com sucesso! Código: $classCode',
'Turma "$className" criada com sucesso! Código: $classCode',
),
backgroundColor: Theme.of(context).colorScheme.primary,
behavior: SnackBarBehavior.floating,
@@ -585,7 +585,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erro ao criar disciplina: $e'),
content: Text('Erro ao criar turma: $e'),
backgroundColor: Colors.red,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(

View File

@@ -2374,11 +2374,13 @@ class _InteractiveQuizSheetState extends State<_InteractiveQuizSheet> {
late List<int> _chosen;
bool _submitted = false;
bool _saving = false;
DateTime? _startTime;
@override
void initState() {
super.initState();
_chosen = List.filled(widget.questions.length, -1);
_startTime = DateTime.now();
}
void _selectOption(int idx) {
@@ -2427,6 +2429,19 @@ class _InteractiveQuizSheetState extends State<_InteractiveQuizSheet> {
totalQuestions: widget.questions.length,
materialName: widget.title,
);
// Registrar tempo de estudo real
if (_startTime != null) {
final elapsedDuration = DateTime.now().difference(_startTime!);
final elapsedMinutes = elapsedDuration.inMinutes;
final elapsedSeconds = elapsedDuration.inSeconds % 60;
if (elapsedMinutes > 0 || elapsedSeconds > 0) {
Logger.info(
'Quiz study time recorded: ${elapsedMinutes}m ${elapsedSeconds}s',
);
await GamificationService.recordStudyTime(user.uid, elapsedMinutes);
}
}
}
} catch (e) {
Logger.error('Error saving quiz result: $e');
@@ -2837,11 +2852,13 @@ class _TeacherQuizInteractiveSheetState
late List<int> _chosen;
bool _submitted = false;
bool _saving = false;
DateTime? _startTime;
@override
void initState() {
super.initState();
_chosen = List.filled(widget.questions.length, -1);
_startTime = DateTime.now();
}
void _selectOption(int idx) {
@@ -2914,6 +2931,19 @@ class _TeacherQuizInteractiveSheetState
totalQuestions: total,
materialName: matName,
);
// Registrar tempo de estudo real
if (_startTime != null) {
final elapsedDuration = DateTime.now().difference(_startTime!);
final elapsedMinutes = elapsedDuration.inMinutes;
final elapsedSeconds = elapsedDuration.inSeconds % 60;
if (elapsedMinutes > 0 || elapsedSeconds > 0) {
Logger.info(
'Quiz study time recorded: ${elapsedMinutes}m ${elapsedSeconds}s',
);
await GamificationService.recordStudyTime(user.uid, elapsedMinutes);
}
}
}
} catch (e) {
Logger.error('Error submitting teacher quiz result: $e');

View File

@@ -231,10 +231,12 @@ class _SplashPageState extends State<SplashPage> {
),
],
),
child: const Icon(
Icons.school,
size: 40,
color: Colors.white,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.asset(
'assets/images/epvc.png',
fit: BoxFit.cover,
),
),
)
.animate()