hotfix: navbar fixed
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
// main.dart
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'src/views/domicilios.dart';
|
|
||||||
import 'src/views/rutas.dart';
|
import 'src/views/rutas.dart';
|
||||||
import 'src/views/main_screen.dart';
|
import 'src/views/login.dart';
|
||||||
import 'src/views/login.dart'; // Importar LoginView
|
import 'src/views/home_screen.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@@ -61,10 +59,10 @@ class RegistroView extends StatelessWidget {
|
|||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Navegar a MainScreen (app principal)
|
// ✅ Navegar a HomeScreen (única barra de navegación)
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => const DomiciliosView()),
|
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)),
|
child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
// domicilios.dart
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'rutas.dart';
|
import 'rutas.dart';
|
||||||
import '../models/domicilio_model.dart';
|
import '../models/domicilio_model.dart';
|
||||||
import '../services/geolocation_service.dart';
|
import '../services/geolocation_service.dart';
|
||||||
import 'nav_bar.dart';
|
|
||||||
import 'main_screen.dart';
|
|
||||||
|
|
||||||
class DomiciliosView extends StatefulWidget {
|
class DomiciliosView extends StatefulWidget {
|
||||||
const DomiciliosView({super.key});
|
const DomiciliosView({super.key});
|
||||||
@@ -102,17 +99,12 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⬇️⬇️⬇️ ESTE ES EL MÉTODO QUE DEBES TENER ⬇️⬇️⬇️
|
|
||||||
Future<void> _obtenerUbicacionYAgregar() async {
|
Future<void> _obtenerUbicacionYAgregar() async {
|
||||||
print('🔵 Iniciando obtención de ubicación');
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoadingLocation = true;
|
_isLoadingLocation = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verificar GPS
|
|
||||||
final serviceEnabled = await GeolocationService.isLocationServiceEnabled();
|
final serviceEnabled = await GeolocationService.isLocationServiceEnabled();
|
||||||
print('📡 GPS activado: $serviceEnabled');
|
|
||||||
|
|
||||||
if (!serviceEnabled) {
|
if (!serviceEnabled) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoadingLocation = false;
|
_isLoadingLocation = false;
|
||||||
@@ -121,69 +113,41 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text('Activa el GPS para agregar un domicilio'),
|
content: Text('Activa el GPS para agregar un domicilio'),
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
duration: Duration(seconds: 3),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar permisos
|
|
||||||
final hasPermission = await _showLocationPermissionDialog();
|
final hasPermission = await _showLocationPermissionDialog();
|
||||||
print('🔐 Permiso concedido: $hasPermission');
|
|
||||||
|
|
||||||
if (!hasPermission) {
|
if (!hasPermission) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoadingLocation = false;
|
_isLoadingLocation = false;
|
||||||
});
|
});
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text('Necesitamos tu ubicación para continuar'),
|
content: Text('Necesitamos tu ubicación'),
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
duration: Duration(seconds: 3),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mostrar mensaje de "obteniendo ubicación"
|
final position = await GeolocationService.getCurrentLocation();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
|
||||||
),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text('Obteniendo tu ubicación...'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
backgroundColor: colorAzul,
|
|
||||||
duration: Duration(seconds: 5),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Obtener ubicación con reintentos
|
|
||||||
final position = await GeolocationService.getCurrentLocationWithRetry(maxRetries: 3);
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoadingLocation = false;
|
_isLoadingLocation = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
print('❌ No se pudo obtener ubicación después de reintentos');
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text('No se pudo obtener tu ubicación. Revisa tu GPS.'),
|
content: Text('No se pudo obtener tu ubicación.'),
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
duration: Duration(seconds: 4),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print('✅ Ubicación obtenida exitosamente: ${position.latitude}, ${position.longitude}');
|
|
||||||
_mostrarDialogoAgregarConUbicacion(position);
|
_mostrarDialogoAgregarConUbicacion(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,17 +168,11 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text('Añadir domicilio', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: colorAzul)),
|
||||||
'Añadir domicilio',
|
|
||||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: colorAzul),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: Colors.green.withOpacity(0.1), borderRadius: BorderRadius.circular(12)),
|
||||||
color: Colors.green.withOpacity(0.1),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.location_on, color: Colors.green[700], size: 24),
|
Icon(Icons.location_on, color: Colors.green[700], size: 24),
|
||||||
@@ -223,8 +181,7 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('📍 Ubicación obtenida',
|
Text('📍 Ubicación obtenida', style: TextStyle(fontSize: 12, color: Colors.green[700])),
|
||||||
style: TextStyle(fontSize: 12, color: Colors.green[700])),
|
|
||||||
Text('Lat: ${position.latitude.toStringAsFixed(6)}'),
|
Text('Lat: ${position.latitude.toStringAsFixed(6)}'),
|
||||||
Text('Lng: ${position.longitude.toStringAsFixed(6)}'),
|
Text('Lng: ${position.longitude.toStringAsFixed(6)}'),
|
||||||
],
|
],
|
||||||
@@ -247,10 +204,7 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(side: BorderSide(color: colorAzul, width: 2), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))),
|
||||||
side: BorderSide(color: colorAzul, width: 2),
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
child: const Text('Cancelar', style: TextStyle(color: colorAzul)),
|
child: const Text('Cancelar', style: TextStyle(color: colorAzul)),
|
||||||
),
|
),
|
||||||
@@ -258,10 +212,7 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(backgroundColor: colorAzul, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))),
|
||||||
backgroundColor: colorAzul,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
|
||||||
),
|
|
||||||
onPressed: () => _agregarDomicilio(latitud: position.latitude, longitud: position.longitude),
|
onPressed: () => _agregarDomicilio(latitud: position.latitude, longitud: position.longitude),
|
||||||
child: const Text('Agregar', style: TextStyle(color: Colors.white)),
|
child: const Text('Agregar', style: TextStyle(color: Colors.white)),
|
||||||
),
|
),
|
||||||
@@ -289,14 +240,8 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
hintText: hint,
|
hintText: hint,
|
||||||
prefixIcon: Icon(icon, color: colorAzul),
|
prefixIcon: Icon(icon, color: colorAzul),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15)),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15)),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15), borderSide: BorderSide(color: colorAzul.withOpacity(0.5))),
|
||||||
borderRadius: BorderRadius.circular(15),
|
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15), borderSide: const BorderSide(color: colorAzul, width: 2)),
|
||||||
borderSide: BorderSide(color: colorAzul.withOpacity(0.5)),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
borderSide: const BorderSide(color: colorAzul, width: 2),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -330,7 +275,7 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Domicilio agregado'), backgroundColor: colorAzul, duration: const Duration(seconds: 2)),
|
SnackBar(content: Text('Domicilio agregado'), backgroundColor: colorAzul),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,95 +300,79 @@ class _DomiciliosViewState extends State<DomiciliosView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _navegarA(int index) {
|
|
||||||
if (index == 1) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const MainScreen()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return SafeArea(
|
||||||
backgroundColor: Colors.white,
|
child: Column(
|
||||||
body: SafeArea(
|
children: [
|
||||||
child: Column(
|
Container(
|
||||||
children: [
|
width: double.infinity,
|
||||||
Container(
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16),
|
||||||
width: double.infinity,
|
decoration: const BoxDecoration(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16),
|
color: colorAzul,
|
||||||
decoration: const BoxDecoration(
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)),
|
||||||
color: colorAzul,
|
|
||||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
child: const Text('Domicilios', style: TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
child: const Text('Domicilios', style: TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
||||||
child: _isLoading
|
),
|
||||||
? const Center(child: CircularProgressIndicator(color: colorAzul))
|
Expanded(
|
||||||
: domicilios.isEmpty
|
child: _isLoading
|
||||||
? Center(
|
? const Center(child: CircularProgressIndicator(color: colorAzul))
|
||||||
child: Column(
|
: domicilios.isEmpty
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
? Center(
|
||||||
children: [
|
child: Column(
|
||||||
Icon(Icons.home_outlined, size: 100, color: Colors.grey.withOpacity(0.5)),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
const SizedBox(height: 20),
|
children: [
|
||||||
Text('No hay domicilios', style: TextStyle(fontSize: 18, color: Colors.grey.withOpacity(0.7))),
|
Icon(Icons.home_outlined, size: 100, color: Colors.grey.withOpacity(0.5)),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
Text('Toca el botón + para agregar', style: TextStyle(fontSize: 14, color: Colors.grey.withOpacity(0.5))),
|
Text('No hay domicilios', style: TextStyle(fontSize: 18, color: Colors.grey.withOpacity(0.7))),
|
||||||
],
|
const SizedBox(height: 10),
|
||||||
),
|
Text('Toca el botón + para agregar', style: TextStyle(fontSize: 14, color: Colors.grey.withOpacity(0.5))),
|
||||||
)
|
],
|
||||||
: ListView.builder(
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
itemCount: domicilios.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final d = domicilios[index];
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 20),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(15),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: Colors.black, width: 4),
|
|
||||||
borderRadius: BorderRadius.circular(25),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.home_outlined, size: 60),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(d.nombre, style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
|
||||||
Text(d.direccionCompleta, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
|
||||||
Text('📍 ${d.latitud.toStringAsFixed(4)}, ${d.longitud.toStringAsFixed(4)}', style: TextStyle(fontSize: 12, color: Colors.grey[600])),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(onPressed: () => _eliminarDomicilio(index), icon: const Icon(Icons.delete_outline, size: 40), color: Colors.red),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
Padding(
|
: ListView.builder(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: _isLoadingLocation
|
itemCount: domicilios.length,
|
||||||
? Container(width: double.infinity, height: 100, decoration: BoxDecoration(color: colorAzul, borderRadius: BorderRadius.circular(20)), child: const Center(child: CircularProgressIndicator(color: Colors.white)))
|
itemBuilder: (context, index) {
|
||||||
: GestureDetector(
|
final d = domicilios[index];
|
||||||
onTap: _obtenerUbicacionYAgregar,
|
return Padding(
|
||||||
child: Container(width: double.infinity, height: 100, decoration: BoxDecoration(color: colorAzul, borderRadius: BorderRadius.circular(20)), child: const Icon(Icons.add, color: Colors.white, size: 80)),
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
),
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(15),
|
||||||
|
decoration: BoxDecoration(border: Border.all(color: Colors.black, width: 4), borderRadius: BorderRadius.circular(25)),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.home_outlined, size: 60),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(d.nombre, style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||||
|
Text(d.direccionCompleta, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
|
Text('📍 ${d.latitud.toStringAsFixed(4)}, ${d.longitud.toStringAsFixed(4)}', style: TextStyle(fontSize: 12, color: Colors.grey[600])),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(onPressed: () => _eliminarDomicilio(index), icon: const Icon(Icons.delete_outline, size: 40), color: Colors.red),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: _isLoadingLocation
|
||||||
|
? Container(width: double.infinity, height: 100, decoration: BoxDecoration(color: colorAzul, borderRadius: BorderRadius.circular(20)), child: const Center(child: CircularProgressIndicator(color: Colors.white)))
|
||||||
|
: GestureDetector(
|
||||||
|
onTap: _obtenerUbicacionYAgregar,
|
||||||
|
child: Container(width: double.infinity, height: 100, decoration: BoxDecoration(color: colorAzul, borderRadius: BorderRadius.circular(20)), child: const Icon(Icons.add, color: Colors.white, size: 80)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: CustomNavBar(currentIndex: 0, onTap: _navegarA),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
42
lib/src/views/home_screen.dart
Normal file
42
lib/src/views/home_screen.dart
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// home_screen.dart
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'domicilios.dart';
|
||||||
|
import 'horarios.dart';
|
||||||
|
import 'configuracion.dart';
|
||||||
|
import 'rutas.dart';
|
||||||
|
import 'nav_bar.dart';
|
||||||
|
|
||||||
|
class HomeScreen extends StatefulWidget {
|
||||||
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HomeScreen> createState() => _HomeScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
|
int _currentIndex = 0; // 0: Domicilios, 1: Rutas, 2: Configuración
|
||||||
|
|
||||||
|
final List<Widget> _paginas = const [
|
||||||
|
DomiciliosView(),
|
||||||
|
HorariosView(),
|
||||||
|
ConfiguracionView(),
|
||||||
|
];
|
||||||
|
|
||||||
|
void _onNavBarTap(int index) {
|
||||||
|
setState(() {
|
||||||
|
_currentIndex = index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
body: _paginas[_currentIndex],
|
||||||
|
bottomNavigationBar: CustomNavBar(
|
||||||
|
currentIndex: _currentIndex,
|
||||||
|
onTap: _onNavBarTap,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
|
// login.dart - cambiar MainScreen por HomeScreen
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'rutas.dart';
|
import 'rutas.dart';
|
||||||
import 'main_screen.dart';
|
import 'home_screen.dart'; // ← Importar HomeScreen
|
||||||
|
|
||||||
class LoginView extends StatelessWidget {
|
class LoginView extends StatelessWidget {
|
||||||
const LoginView({super.key});
|
const LoginView({super.key});
|
||||||
@@ -27,16 +28,12 @@ class LoginView extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(30.0),
|
padding: const EdgeInsets.all(30.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Campo de Correo
|
|
||||||
_buildInput(Icons.email_outlined, 'Correo electrónico', obscureText: false),
|
_buildInput(Icons.email_outlined, 'Correo electrónico', obscureText: false),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
// Campo de Contraseña
|
|
||||||
_buildInput(Icons.lock_outline, 'Contraseña', obscureText: true),
|
_buildInput(Icons.lock_outline, 'Contraseña', obscureText: true),
|
||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
// Botones
|
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
// Botón Iniciar Sesión
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: colorAzul,
|
backgroundColor: colorAzul,
|
||||||
@@ -44,9 +41,10 @@ class LoginView extends StatelessWidget {
|
|||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// ✅ Navegar a HomeScreen
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => const MainScreen()),
|
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -55,7 +53,6 @@ class LoginView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
// Botón Crear Cuenta
|
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
minimumSize: const Size(double.infinity, 55),
|
minimumSize: const Size(double.infinity, 55),
|
||||||
|
|||||||
Reference in New Issue
Block a user