hotfix: Views logic
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'nav_bar.dart';
|
||||
import 'rutas.dart';
|
||||
import 'domicilios.dart';
|
||||
import 'horarios.dart';
|
||||
|
||||
class ConfiguracionView extends StatelessWidget {
|
||||
const ConfiguracionView({super.key});
|
||||
|
||||
void _navigateTo(BuildContext context, int index) {
|
||||
if (index == 2) return; // Ya estamos en Configuración
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const DomiciliosView()),
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HorariosView()),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -20,8 +41,7 @@ class ConfiguracionView extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
},
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
@@ -43,7 +63,10 @@ class ConfiguracionView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: const CustomNavBar(currentIndex: 2),
|
||||
bottomNavigationBar: CustomNavBar(
|
||||
currentIndex: 2,
|
||||
onTap: (index) => _navigateTo(context, index),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'nav_bar.dart'; // Importar la nueva barra
|
||||
import 'nav_bar.dart';
|
||||
import 'rutas.dart';
|
||||
import 'horarios.dart';
|
||||
import 'configuracion.dart';
|
||||
|
||||
class DomiciliosView extends StatelessWidget {
|
||||
const DomiciliosView({super.key});
|
||||
|
||||
void _navigateTo(BuildContext context, int index) {
|
||||
if (index == 0) return;
|
||||
|
||||
switch (index) {
|
||||
case 1:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HorariosView()),
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const ConfiguracionView()),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -32,7 +53,7 @@ class DomiciliosView extends StatelessWidget {
|
||||
const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Mi Casa', // Cambiar por datos reales
|
||||
Text('Mi Casa',
|
||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||
Text('Centro, Ruta 1',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
@@ -40,7 +61,7 @@ class DomiciliosView extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: () {}, // Menú de opciones
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.more_horiz, size: 40),
|
||||
),
|
||||
],
|
||||
@@ -48,9 +69,7 @@ class DomiciliosView extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Acción para agregar nuevo domicilio
|
||||
},
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 100,
|
||||
@@ -64,7 +83,10 @@ class DomiciliosView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: const CustomNavBar(currentIndex: 0),
|
||||
bottomNavigationBar: CustomNavBar(
|
||||
currentIndex: 0,
|
||||
onTap: (index) => _navigateTo(context, index),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'nav_bar.dart';
|
||||
import 'rutas.dart';
|
||||
import 'domicilios.dart';
|
||||
import 'configuracion.dart';
|
||||
|
||||
class HorariosView extends StatelessWidget {
|
||||
const HorariosView({super.key});
|
||||
|
||||
void _navigateTo(BuildContext context, int index) {
|
||||
if (index == 1) return; // Ya estamos en Horarios
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const DomiciliosView()),
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const ConfiguracionView()),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Map<String, String>> rutas = List.generate(
|
||||
@@ -50,7 +71,10 @@ class HorariosView extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: const CustomNavBar(currentIndex: 1),
|
||||
bottomNavigationBar: CustomNavBar(
|
||||
currentIndex: 1,
|
||||
onTap: (index) => _navigateTo(context, index),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,15 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'rutas.dart';
|
||||
import 'domicilios.dart';
|
||||
import 'horarios.dart';
|
||||
import 'configuracion.dart';
|
||||
|
||||
class CustomNavBar extends StatelessWidget {
|
||||
final int currentIndex;
|
||||
final Function(int) onTap;
|
||||
|
||||
const CustomNavBar({super.key, required this.currentIndex});
|
||||
|
||||
void _navigateTo(BuildContext context, int index) {
|
||||
if (currentIndex == index) return;
|
||||
|
||||
Widget destino;
|
||||
switch (index) {
|
||||
case 0:
|
||||
destino = const DomiciliosView();
|
||||
break;
|
||||
case 1:
|
||||
destino = const HorariosView();
|
||||
break;
|
||||
case 2:
|
||||
destino = const ConfiguracionView();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => destino),
|
||||
);
|
||||
}
|
||||
const CustomNavBar({
|
||||
super.key,
|
||||
required this.currentIndex,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -44,32 +21,32 @@ class CustomNavBar extends StatelessWidget {
|
||||
children: [
|
||||
// BOTÓN DOMICILIOS
|
||||
_buildNavButton(
|
||||
context: context,
|
||||
index: 0,
|
||||
currentIndex: currentIndex,
|
||||
iconNormal: Icons.home_outlined,
|
||||
iconActive: Icons.home,
|
||||
label: 'Domicilios',
|
||||
onTap: onTap,
|
||||
),
|
||||
|
||||
// BOTÓN RUTAS (HORARIOS)
|
||||
_buildNavButton(
|
||||
context: context,
|
||||
index: 1,
|
||||
currentIndex: currentIndex,
|
||||
iconNormal: Icons.alt_route_rounded,
|
||||
iconActive: Icons.alt_route_rounded,
|
||||
label: 'Rutas',
|
||||
onTap: onTap,
|
||||
),
|
||||
|
||||
// BOTÓN CONFIGURACIÓN
|
||||
_buildNavButton(
|
||||
context: context,
|
||||
index: 2,
|
||||
currentIndex: currentIndex,
|
||||
iconNormal: Icons.settings_outlined,
|
||||
iconActive: Icons.settings,
|
||||
label: 'Configuración',
|
||||
onTap: onTap,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -77,29 +54,27 @@ class CustomNavBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildNavButton({
|
||||
required BuildContext context,
|
||||
required int index,
|
||||
required int currentIndex,
|
||||
required IconData iconNormal,
|
||||
required IconData iconActive,
|
||||
required String label,
|
||||
required Function(int) onTap,
|
||||
}) {
|
||||
final bool isActive = currentIndex == index;
|
||||
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => _navigateTo(context, index),
|
||||
onTap: () => onTap(index),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// ÍCONO: más grande si está activo
|
||||
Icon(
|
||||
isActive ? iconActive : iconNormal,
|
||||
color: Colors.white,
|
||||
size: isActive ? 55 : 35, // ¡EL ACTIVO ES MÁS GRANDE!
|
||||
size: isActive ? 55 : 35,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
// TEXTO: opcional, para mejor UX
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user