Co-authored-by: eddgranados12 <eddgranados12@users.noreply.github.com>
Co-authored-by: Azareth-Tr <Azareth-Tr@users.noreply.github.com> Co-authored-by: MENDOZA BALLARDO GAEL RICARDO <gael-meb123@users.noreply.github.com> vistas
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/widgets.dart' as w;
|
||||
import 'admin_screen.dart';
|
||||
import 'driver_screen.dart';
|
||||
import 'main_shell.dart';
|
||||
|
||||
enum UserRole { usuario, conductor, administrador }
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@@ -18,7 +14,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailCtrl = TextEditingController();
|
||||
final _passCtrl = TextEditingController();
|
||||
UserRole _selectedRole = UserRole.usuario;
|
||||
bool _obscurePass = true;
|
||||
bool _loading = false;
|
||||
|
||||
@@ -37,22 +32,11 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
setState(() => _loading = false);
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => _homeForRole()),
|
||||
MaterialPageRoute(builder: (_) => const MainShell()),
|
||||
(_) => false,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _homeForRole() {
|
||||
switch (_selectedRole) {
|
||||
case UserRole.conductor:
|
||||
return const DriverShell();
|
||||
case UserRole.administrador:
|
||||
return const AdminShell();
|
||||
case UserRole.usuario:
|
||||
return const MainShell();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -135,37 +119,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
setState(() => _obscurePass = !_obscurePass),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<UserRole>(
|
||||
initialValue: _selectedRole,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Tipo de usuario',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 16),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: UserRole.usuario,
|
||||
child: Text('Usuario'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: UserRole.conductor,
|
||||
child: Text('Conductor'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: UserRole.administrador,
|
||||
child: Text('Administrador'),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() => _selectedRole = value);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
|
||||
Reference in New Issue
Block a user