Teacher dashboard updates

This commit is contained in:
2026-05-24 20:09:22 +01:00
parent 1a98fff5e8
commit c2fd663170
6 changed files with 301 additions and 307 deletions

View File

@@ -22,9 +22,13 @@ class TeacherDashboardPage extends StatefulWidget {
State<TeacherDashboardPage> createState() => _TeacherDashboardPageState();
}
class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
class _TeacherDashboardPageState extends State<TeacherDashboardPage>
with AutomaticKeepAliveClientMixin {
String _userName = 'Professor';
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
@@ -36,6 +40,12 @@ class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
}
}
Future<void> _refreshDashboard() async {
// Clear cached data to force refresh
TeacherDashboardPage.clearCachedUserName();
await _loadUserData();
}
Future<void> _checkRoleAndLoadData() async {
final user = AuthService.currentUser;
if (user == null) {
@@ -94,6 +104,7 @@ class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
@override
Widget build(BuildContext context) {
super.build(context);
final themeExtras = AppThemeExtras.of(context);
final headerColor = themeExtras.dashboardHeaderTextColor;
@@ -107,83 +118,86 @@ class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
stops: themeExtras.dashboardGradientStops,
),
),
child: SafeArea(
top: false,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(
left: 24.0,
right: 24.0,
bottom: 28.0,
top: 52.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header with logout and settings
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Bem-vindo, $_userName!',
style: TextStyle(
color: headerColor,
fontSize: 28,
fontWeight: FontWeight.bold,
child: RefreshIndicator(
onRefresh: _refreshDashboard,
child: SafeArea(
top: false,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(
left: 24.0,
right: 24.0,
bottom: 28.0,
top: 52.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header with logout and settings
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Bem-vindo, $_userName!',
style: TextStyle(
color: headerColor,
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 4),
Text(
'Painel de Gestão de Conteúdo',
style: TextStyle(
color: headerColor,
fontSize: 16,
fontWeight: FontWeight.w300,
const SizedBox(height: 4),
Text(
'Painel de Gestão de Conteúdo',
style: TextStyle(
color: headerColor,
fontSize: 16,
fontWeight: FontWeight.w300,
),
),
),
],
],
),
),
),
IconButton(
icon: Icon(Icons.settings, color: headerColor),
onPressed: () {
AppRouter.goToSettings(context);
},
tooltip: 'Configurações',
),
IconButton(
icon: Icon(Icons.logout, color: headerColor),
onPressed: () async {
await AuthService.signOut();
if (mounted) {
context.go('/login');
}
},
tooltip: 'Sair',
),
],
),
const SizedBox(height: 32),
IconButton(
icon: Icon(Icons.settings, color: headerColor),
onPressed: () {
AppRouter.goToSettings(context);
},
tooltip: 'Configurações',
),
IconButton(
icon: Icon(Icons.logout, color: headerColor),
onPressed: () async {
await AuthService.signOut();
if (mounted) {
context.go('/login');
}
},
tooltip: 'Sair',
),
],
),
const SizedBox(height: 32),
// Hero Section - Class Overview
TeacherHeroWidget(userName: _userName),
// Hero Section - Class Overview
TeacherHeroWidget(userName: _userName),
const SizedBox(height: 24),
const SizedBox(height: 24),
// Quick Actions Section
const TeacherQuickActionsWidget(),
// Quick Actions Section
const TeacherQuickActionsWidget(),
const SizedBox(height: 24),
const SizedBox(height: 24),
// Classes List Section
const TeacherClassesListWidget(),
// Classes List Section
const TeacherClassesListWidget(),
const SizedBox(height: 40),
],
const SizedBox(height: 40),
],
),
),
),
),