criação da tela home dos professores e aniquilação do placeholder da home dos professores
(talzes o "já tenho conta" desapareça, talvez nao, que seja oq deus quiser)
This commit is contained in:
@@ -1,26 +1,153 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/theme/app_colors.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../../core/services/auth_service.dart';
|
||||
import '../widgets/teacher_hero_widget.dart';
|
||||
import '../widgets/teacher_quick_actions_widget.dart';
|
||||
import '../widgets/teacher_analytics_preview_widget.dart';
|
||||
|
||||
class TeacherDashboardPage extends StatelessWidget {
|
||||
class TeacherDashboardPage extends StatefulWidget {
|
||||
const TeacherDashboardPage({super.key});
|
||||
|
||||
@override
|
||||
State<TeacherDashboardPage> createState() => _TeacherDashboardPageState();
|
||||
}
|
||||
|
||||
class _TeacherDashboardPageState extends State<TeacherDashboardPage> {
|
||||
String _userName = 'Professor';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUserData();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_loadUserData();
|
||||
}
|
||||
|
||||
Future<void> _loadUserData() async {
|
||||
try {
|
||||
final user = AuthService.currentUser;
|
||||
if (user != null) {
|
||||
print('DEBUG: Loading teacher data for dashboard');
|
||||
print('DEBUG: User email: ${user.email}');
|
||||
print('DEBUG: User displayName before reload: ${user.displayName}');
|
||||
|
||||
await user.reload();
|
||||
|
||||
final updatedUser = AuthService.currentUser;
|
||||
if (updatedUser != null) {
|
||||
print(
|
||||
'DEBUG: User displayName after reload: ${updatedUser.displayName}',
|
||||
);
|
||||
|
||||
String displayName = updatedUser.displayName ?? '';
|
||||
print('DEBUG: Initial displayName value: "$displayName"');
|
||||
|
||||
if (displayName.isEmpty && updatedUser.email != null) {
|
||||
displayName = updatedUser.email!.split('@')[0];
|
||||
print('DEBUG: Extracted name from email: "$displayName"');
|
||||
}
|
||||
if (displayName.isEmpty) {
|
||||
displayName = 'Professor';
|
||||
print('DEBUG: Using fallback "Professor"');
|
||||
}
|
||||
|
||||
print('DEBUG: Final displayName to use: "$displayName"');
|
||||
setState(() {
|
||||
_userName = displayName;
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('DEBUG: Error loading user data: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.background,
|
||||
appBar: AppBar(
|
||||
title: const Text('Teacher Dashboard'),
|
||||
backgroundColor: AppColors.surface,
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
elevation: 0,
|
||||
),
|
||||
body: const Center(
|
||||
child: Text(
|
||||
'Teacher Dashboard - Coming Soon',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.textPrimary,
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFF82C9BD),
|
||||
Color(0xFF7BA89C),
|
||||
Color(0xFFF68D2D),
|
||||
Color(0xFFF8F9FA),
|
||||
],
|
||||
stops: [0.0, 0.2, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header with logout
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Bem-vindo, $_userName!',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'Painel de Gestão de Conteúdo',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w300,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout, color: Colors.white),
|
||||
onPressed: () async {
|
||||
await AuthService.signOut();
|
||||
if (mounted) {
|
||||
context.go('/login');
|
||||
}
|
||||
},
|
||||
tooltip: 'Sair',
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Hero Section - Class Overview
|
||||
TeacherHeroWidget(userName: _userName),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Quick Actions Section
|
||||
const TeacherQuickActionsWidget(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Analytics Preview Section
|
||||
const TeacherAnalyticsPreviewWidget(),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user