diff --git a/lib/main.dart b/lib/main.dart index b20b63e..f272b45 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'src/views/rutas.dart'; +import 'src/views/main_screen.dart'; // Importar la pantalla principal void main() { runApp(const MyApp()); @@ -13,6 +14,10 @@ class MyApp extends StatelessWidget { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Hackaton App', + theme: ThemeData( + fontFamily: 'Roboto', + scaffoldBackgroundColor: colorAzul, + ), home: const RegistroView(), ); } @@ -54,7 +59,11 @@ class RegistroView extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)) ), onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => const HorariosView())); + // ✅ Navegar a la pantalla principal con todas las vistas + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const MainScreen()), + ); }, child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)), ), @@ -64,7 +73,14 @@ class RegistroView extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)) ), - onPressed: () {}, + onPressed: () { + // TODO: Implementar inicio de sesión + // Por ahora también navega a MainScreen + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const MainScreen()), + ); + }, child: const Text('Iniciar Sesion', style: TextStyle(color: Colors.white, fontSize: 18)), ), ], diff --git a/lib/src/views/configuracion.dart b/lib/src/views/configuracion.dart index 583a494..0934141 100644 --- a/lib/src/views/configuracion.dart +++ b/lib/src/views/configuracion.dart @@ -1,61 +1,64 @@ +// configuracion.dart 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( - backgroundColor: Colors.white, - appBar: AppBar( - backgroundColor: colorAzul, - title: const Text('Configuración', - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)), - centerTitle: true, - ), - body: Padding( - padding: const EdgeInsets.all(20.0), + return Container( + color: Colors.white, + child: SafeArea( child: Column( children: [ - GestureDetector( - onTap: () {}, - child: Container( - padding: const EdgeInsets.all(15), - decoration: BoxDecoration( - border: Border.all(color: Colors.black, width: 4), - borderRadius: BorderRadius.circular(25), + // AppBar personalizado + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), + decoration: const BoxDecoration( + color: colorAzul, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), ), - child: const Row( + ), + child: const Text( + 'Configuración', + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), + ), + // Contenido + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( children: [ - Icon(Icons.notifications_active_outlined, size: 60), - SizedBox(width: 10), - Text('7 días', - style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), - Spacer(), - Icon(Icons.keyboard_arrow_down, size: 50), + GestureDetector( + onTap: () {}, + child: Container( + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + border: Border.all(color: Colors.black, width: 4), + borderRadius: BorderRadius.circular(25), + ), + child: const Row( + children: [ + Icon(Icons.notifications_active_outlined, size: 60), + SizedBox(width: 10), + Text('7 días', + style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), + Spacer(), + Icon(Icons.keyboard_arrow_down, size: 50), + ], + ), + ), + ), ], ), ), @@ -63,10 +66,6 @@ class ConfiguracionView extends StatelessWidget { ], ), ), - bottomNavigationBar: CustomNavBar( - currentIndex: 2, - onTap: (index) => _navigateTo(context, index), - ), ); } } \ No newline at end of file diff --git a/lib/src/views/domicilios.dart b/lib/src/views/domicilios.dart index d84419b..12e9223 100644 --- a/lib/src/views/domicilios.dart +++ b/lib/src/views/domicilios.dart @@ -1,92 +1,91 @@ +// domicilios.dart import 'package:flutter/material.dart'; -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( - backgroundColor: Colors.white, - appBar: AppBar( - backgroundColor: colorAzul, - title: const Text('Domicilios', - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)), - centerTitle: true, - ), - body: Padding( - padding: const EdgeInsets.all(20.0), + return Container( + color: Colors.white, // Fondo blanco para el contenido + child: SafeArea( child: Column( children: [ + // AppBar personalizado Container( - padding: const EdgeInsets.all(15), - decoration: BoxDecoration( - border: Border.all(color: Colors.black, width: 4), - borderRadius: BorderRadius.circular(25), + width: double.infinity, + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), + decoration: const BoxDecoration( + color: colorAzul, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), ), - child: Row( - children: [ - const Icon(Icons.home_outlined, size: 60), - const SizedBox(width: 10), - const Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Mi Casa', - style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), - Text('Centro, Ruta 1', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), - ], - ), - const Spacer(), - IconButton( - onPressed: () {}, - icon: const Icon(Icons.more_horiz, size: 40), - ), - ], + child: const Text( + 'Domicilios', + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, ), ), - const SizedBox(height: 20), - GestureDetector( - onTap: () {}, - child: Container( - width: double.infinity, - height: 100, - decoration: BoxDecoration( - color: colorAzul, - borderRadius: BorderRadius.circular(20), + // Contenido + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + 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), + const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Mi Casa', + style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), + Text('Centro, Ruta 1', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), + ], + ), + const Spacer(), + IconButton( + onPressed: () {}, + icon: const Icon(Icons.more_horiz, size: 40), + ), + ], + ), + ), + const SizedBox(height: 20), + GestureDetector( + onTap: () {}, + 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), + ), + ), + ], ), - child: const Icon(Icons.add, color: Colors.white, size: 80), ), ), ], ), ), - bottomNavigationBar: CustomNavBar( - currentIndex: 0, - onTap: (index) => _navigateTo(context, index), - ), ); } } \ No newline at end of file diff --git a/lib/src/views/horarios.dart b/lib/src/views/horarios.dart index 60813e1..1886447 100644 --- a/lib/src/views/horarios.dart +++ b/lib/src/views/horarios.dart @@ -1,31 +1,9 @@ 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> rutas = List.generate( @@ -37,43 +15,63 @@ class HorariosView extends StatelessWidget { }, ); - return Scaffold( - backgroundColor: Colors.white, - appBar: AppBar( - backgroundColor: colorAzul, - title: const Text('Horarios', - style: TextStyle(color: Colors.white, fontSize: 32, fontWeight: FontWeight.bold)), - centerTitle: true, - ), - body: ListView.builder( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24), - itemCount: rutas.length, - itemBuilder: (context, index) { - final item = rutas[index]; - return Padding( - padding: const EdgeInsets.symmetric(vertical: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(item['colonia']!, - style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), - Text(item['ruta']!, - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), - ], + return Container( + color: Colors.white, + child: SafeArea( + child: Column( + children: [ + // AppBar personalizado + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), + decoration: const BoxDecoration( + color: colorAzul, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), ), - Text(item['horario']!, - style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), - ], + ), + child: const Text( + 'Horarios', + style: TextStyle( + color: Colors.white, + fontSize: 32, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), ), - ); - }, - ), - bottomNavigationBar: CustomNavBar( - currentIndex: 1, - onTap: (index) => _navigateTo(context, index), + // Lista de horarios + Expanded( + child: ListView.builder( + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24), + itemCount: rutas.length, + itemBuilder: (context, index) { + final item = rutas[index]; + return Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(item['colonia']!, + style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), + Text(item['ruta']!, + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), + ], + ), + Text(item['horario']!, + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), + ], + ), + ); + }, + ), + ), + ], + ), ), ); } diff --git a/lib/src/views/main_screen.dart b/lib/src/views/main_screen.dart new file mode 100644 index 0000000..8da4e50 --- /dev/null +++ b/lib/src/views/main_screen.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'rutas.dart'; +import 'domicilios.dart'; +import 'horarios.dart'; +import 'configuracion.dart'; +import 'nav_bar.dart'; + +class MainScreen extends StatefulWidget { + const MainScreen({super.key}); + + @override + State createState() => _MainScreenState(); +} + +class _MainScreenState extends State { + late PageController _pageController; + int _currentIndex = 1; // Comenzar en Horarios (Rutas) + + @override + void initState() { + super.initState(); + _pageController = PageController(initialPage: _currentIndex); + } + + @override + void dispose() { + _pageController.dispose(); + super.dispose(); + } + + void _onPageChanged(int index) { + setState(() { + _currentIndex = index; + }); + } + + void _onNavBarTap(int index) { + if (_currentIndex != index) { + setState(() { + _currentIndex = index; + }); + _pageController.animateToPage( + index, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: colorAzul, // Mismo color de fondo para evitar flash blanco + body: PageView( + controller: _pageController, + onPageChanged: _onPageChanged, + physics: const BouncingScrollPhysics(), // Efecto de rebote al deslizar + children: const [ + DomiciliosView(), + HorariosView(), + ConfiguracionView(), + ], + ), + bottomNavigationBar: CustomNavBar( + currentIndex: _currentIndex, + onTap: _onNavBarTap, + ), + ); + } +} \ No newline at end of file