Mudanças em criar conta
This commit is contained in:
@@ -14,13 +14,16 @@ class SignupPage extends StatefulWidget {
|
||||
|
||||
class _SignupPageState extends State<SignupPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
bool _isLoading = false;
|
||||
bool _obscurePassword = true;
|
||||
String _selectedRole = 'student'; // 'student' or 'teacher'
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
@@ -34,16 +37,20 @@ class _SignupPageState extends State<SignupPage> {
|
||||
});
|
||||
|
||||
try {
|
||||
// Get email and password from controllers
|
||||
// Get name, email and password from controllers
|
||||
final name = _nameController.text.trim();
|
||||
final email = _emailController.text.trim();
|
||||
final password = _passwordController.text.trim();
|
||||
|
||||
print('DEBUG: Iniciando processo de signup para: $email');
|
||||
print('DEBUG: Nome: $name, Papel: $_selectedRole');
|
||||
|
||||
// Attempt signup with Firebase
|
||||
await AuthService.signUpWithEmailAndPassword(
|
||||
email: email,
|
||||
password: password,
|
||||
displayName: name,
|
||||
role: _selectedRole,
|
||||
);
|
||||
|
||||
print('DEBUG: Signup Firebase bem-sucedido, navegando para dashboard');
|
||||
@@ -59,8 +66,12 @@ class _SignupPageState extends State<SignupPage> {
|
||||
message: 'Conta criada com sucesso!',
|
||||
);
|
||||
|
||||
// Navigate to student dashboard after successful signup
|
||||
context.go('/student-dashboard');
|
||||
// Navigate to appropriate dashboard based on role
|
||||
if (_selectedRole == 'teacher') {
|
||||
context.go('/teacher-dashboard');
|
||||
} else {
|
||||
context.go('/student-dashboard');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('DEBUG: Erro no signup: $e');
|
||||
@@ -181,6 +192,51 @@ class _SignupPageState extends State<SignupPage> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Name field
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
keyboardType: TextInputType.name,
|
||||
style: const TextStyle(color: Color(0xFF2D3748)),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Nome Completo',
|
||||
labelStyle: const TextStyle(
|
||||
color: Color(0xFF2D3748),
|
||||
),
|
||||
hintStyle: const TextStyle(
|
||||
color: Color(0xFF718096),
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.person,
|
||||
color: Color(0xFF82C9BD),
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0xFFE2E8F0),
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0xFF82C9BD),
|
||||
),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: const Color(0xFFF8F9FA),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Nome é obrigatório';
|
||||
}
|
||||
if (value.length < 2) {
|
||||
return 'Nome muito curto';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Email field
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
@@ -282,6 +338,61 @@ class _SignupPageState extends State<SignupPage> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Role selection
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Eu sou:',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF2D3748),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RadioListTile<String>(
|
||||
title: const Text(
|
||||
'Aluno',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
value: 'student',
|
||||
groupValue: _selectedRole,
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
_selectedRole = value!;
|
||||
});
|
||||
},
|
||||
activeColor: const Color(0xFF82C9BD),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: RadioListTile<String>(
|
||||
title: const Text(
|
||||
'Professor',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
value: 'teacher',
|
||||
groupValue: _selectedRole,
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
_selectedRole = value!;
|
||||
});
|
||||
},
|
||||
activeColor: const Color(0xFF82C9BD),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Signup button
|
||||
|
||||
Reference in New Issue
Block a user