Compare commits
9 Commits
dev
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8df86daf25 | ||
|
|
7cf5f13d88 | ||
|
|
04d56e18c6 | ||
|
|
fa60bb0dcc | ||
|
|
f24087b134 | ||
|
|
28b7820641 | ||
|
|
bdde457b45 | ||
|
|
df7b74063b | ||
|
|
6012674aa5 |
@@ -1,5 +1,8 @@
|
|||||||
|
// main.dart
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'src/views/rutas.dart';
|
import 'src/views/rutas.dart';
|
||||||
|
import 'src/views/main_screen.dart';
|
||||||
|
import 'src/views/login.dart'; // Importar LoginView
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@@ -13,6 +16,10 @@ class MyApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'Hackaton App',
|
title: 'Hackaton App',
|
||||||
|
theme: ThemeData(
|
||||||
|
fontFamily: 'Roboto',
|
||||||
|
scaffoldBackgroundColor: colorAzul,
|
||||||
|
),
|
||||||
home: const RegistroView(),
|
home: const RegistroView(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -39,8 +46,7 @@ class RegistroView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildInput(Icons.person_outline, 'Nombre'),
|
_buildInput(Icons.person_outline, 'Nombre Completo'),
|
||||||
_buildInput(Icons.person_outline, 'Apellidos'),
|
|
||||||
_buildInput(Icons.email_outlined, 'Correo'),
|
_buildInput(Icons.email_outlined, 'Correo'),
|
||||||
_buildInput(Icons.lock_outline, 'Contraseña'),
|
_buildInput(Icons.lock_outline, 'Contraseña'),
|
||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
@@ -54,7 +60,11 @@ class RegistroView extends StatelessWidget {
|
|||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const HorariosView()));
|
// Navegar a MainScreen (app principal)
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const MainScreen()),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)),
|
child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||||
),
|
),
|
||||||
@@ -64,8 +74,14 @@ class RegistroView extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
child: const Text('Iniciar Sesion', style: TextStyle(color: Colors.white, fontSize: 18)),
|
// Navegar a LoginView
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const LoginView()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('¿Tienes cuenta?', style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
48
lib/src/models/domicilio_model.dart
Normal file
48
lib/src/models/domicilio_model.dart
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class Domicilio {
|
||||||
|
final String nombre;
|
||||||
|
final String colonia;
|
||||||
|
final String calle;
|
||||||
|
final String numero;
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
Domicilio({
|
||||||
|
required this.nombre,
|
||||||
|
required this.colonia,
|
||||||
|
required this.calle,
|
||||||
|
required this.numero,
|
||||||
|
required this.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
String get direccionCompleta => '$colonia, $calle $numero';
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'nombre': nombre,
|
||||||
|
'colonia': colonia,
|
||||||
|
'calle': calle,
|
||||||
|
'numero': numero,
|
||||||
|
'id': id,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory Domicilio.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Domicilio(
|
||||||
|
nombre: json['nombre'],
|
||||||
|
colonia: json['colonia'],
|
||||||
|
calle: json['calle'],
|
||||||
|
numero: json['numero'],
|
||||||
|
id: json['id'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String encode(List<Domicilio> domicilios) {
|
||||||
|
return json.encode(
|
||||||
|
domicilios.map((d) => d.toJson()).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Domicilio> decode(String domiciliosString) {
|
||||||
|
final List<dynamic> data = json.decode(domiciliosString);
|
||||||
|
return data.map((item) => Domicilio.fromJson(item)).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,71 +1,239 @@
|
|||||||
|
// configuracion.dart
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'rutas.dart';
|
import 'rutas.dart';
|
||||||
|
|
||||||
class ConfiguracionView extends StatelessWidget {
|
class ConfiguracionView extends StatefulWidget {
|
||||||
const ConfiguracionView({super.key});
|
const ConfiguracionView({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<ConfiguracionView> createState() => _ConfiguracionViewState();
|
||||||
return Scaffold(
|
}
|
||||||
backgroundColor: Colors.white,
|
|
||||||
appBar: AppBar(
|
class _ConfiguracionViewState extends State<ConfiguracionView> {
|
||||||
|
String selectedOption = '7 días'; // Valor por defecto
|
||||||
|
bool _isLoading = true;
|
||||||
|
|
||||||
|
// Opciones del combobox
|
||||||
|
final List<String> opciones = [
|
||||||
|
'Cada día',
|
||||||
|
'Cada 3 días',
|
||||||
|
'Cada semana',
|
||||||
|
'Cada quincena',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Mapa para mostrar valores más amigables
|
||||||
|
final Map<String, String> opcionesMap = {
|
||||||
|
'Cada día': '1 día',
|
||||||
|
'Cada 3 días': '3 días',
|
||||||
|
'Cada semana': '7 días',
|
||||||
|
'Cada quincena': '15 días',
|
||||||
|
};
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_cargarPreferencia();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cargar la preferencia guardada
|
||||||
|
Future<void> _cargarPreferencia() async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? savedOption = prefs.getString('notificacion_frecuencia');
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
if (savedOption != null && opciones.contains(savedOption)) {
|
||||||
|
selectedOption = savedOption;
|
||||||
|
}
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
print('Error al cargar preferencia: $e');
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guardar la preferencia
|
||||||
|
Future<void> _guardarPreferencia(String value) async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setString('notificacion_frecuencia', value);
|
||||||
|
|
||||||
|
// Mostrar mensaje de confirmación
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Notificaciones: $value'),
|
||||||
backgroundColor: colorAzul,
|
backgroundColor: colorAzul,
|
||||||
title: const Text('Configuracion', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
duration: const Duration(seconds: 1),
|
||||||
centerTitle: true,
|
|
||||||
),
|
),
|
||||||
body: Padding(
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Error al guardar preferencia: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mostrar diálogo con opciones
|
||||||
|
void _mostrarSelector() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Frecuencia de notificaciones',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: colorAzul,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
...opciones.map((opcion) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
selectedOption == opcion ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
|
color: colorAzul,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
opcion,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: selectedOption == opcion ? FontWeight.bold : FontWeight.normal,
|
||||||
|
color: selectedOption == opcion ? colorAzul : Colors.black87,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: Text(
|
||||||
|
opcionesMap[opcion]!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
selectedOption = opcion;
|
||||||
|
});
|
||||||
|
_guardarPreferencia(opcion);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'Configuración',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Contenido
|
||||||
|
Expanded(
|
||||||
|
child: _isLoading
|
||||||
|
? const Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: colorAzul,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
padding: const EdgeInsets.all(20.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
// Selector de notificaciones
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _mostrarSelector,
|
||||||
|
child: Container(
|
||||||
padding: const EdgeInsets.all(15),
|
padding: const EdgeInsets.all(15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.black, width: 4),
|
border: Border.all(color: Colors.black, width: 4),
|
||||||
borderRadius: BorderRadius.circular(25),
|
borderRadius: BorderRadius.circular(25),
|
||||||
),
|
),
|
||||||
child: const Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.notifications_active_outlined, size: 60),
|
const Icon(Icons.notifications_active_outlined, size: 60),
|
||||||
SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text('{Rango dias}', style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
Text(
|
||||||
Spacer(),
|
selectedOption,
|
||||||
Icon(Icons.keyboard_arrow_down, size: 50)
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
const Icon(Icons.keyboard_arrow_down, size: 50),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
// Información adicional
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(15),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorAzul.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: _customNavBarConfig(context),
|
child: Row(
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _customNavBarConfig(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
height: 90, color: colorAzul,
|
|
||||||
child: Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Icon(Icons.info_outline, color: colorAzul, size: 30),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
const SizedBox(width: 10),
|
||||||
children: [
|
Expanded(
|
||||||
IconButton(onPressed: () {}, icon: const Icon(Icons.home_outlined, color: Colors.white, size: 40)),
|
child: Text(
|
||||||
IconButton(onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => const HorariosView())),
|
'Recibirás notificaciones cada ${opcionesMap[selectedOption]}',
|
||||||
icon: const Icon(Icons.alt_route_rounded, color: Colors.white, size: 40)),
|
style: TextStyle(
|
||||||
const SizedBox(width: 80),
|
fontSize: 16,
|
||||||
],
|
color: colorAzul,
|
||||||
),
|
),
|
||||||
Positioned(
|
|
||||||
top: -25, right: 30, // Posición según img 3
|
|
||||||
child: Container(
|
|
||||||
width: 85, height: 85,
|
|
||||||
decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle, border: Border.all(color: colorVerde, width: 4)),
|
|
||||||
child: const Icon(Icons.settings, color: colorVerde, size: 45),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,371 @@
|
|||||||
|
// domicilios.dart
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'rutas.dart';
|
import 'rutas.dart';
|
||||||
|
import '../models/domicilio_model.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
class DomiciliosView extends StatelessWidget {
|
class DomiciliosView extends StatefulWidget {
|
||||||
const DomiciliosView({super.key});
|
const DomiciliosView({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<DomiciliosView> createState() => _DomiciliosViewState();
|
||||||
return Scaffold(
|
}
|
||||||
backgroundColor: Colors.white,
|
|
||||||
appBar: AppBar(
|
class _DomiciliosViewState extends State<DomiciliosView> {
|
||||||
backgroundColor: colorAzul,
|
List<Domicilio> domicilios = [];
|
||||||
title: const Text('Domicilios', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
bool _isLoading = true;
|
||||||
centerTitle: true,
|
|
||||||
|
// Controladores para el formulario
|
||||||
|
final TextEditingController nombreController = TextEditingController();
|
||||||
|
final TextEditingController coloniaController = TextEditingController();
|
||||||
|
final TextEditingController calleController = TextEditingController();
|
||||||
|
final TextEditingController numeroController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_cargarDomicilios();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
nombreController.dispose();
|
||||||
|
coloniaController.dispose();
|
||||||
|
calleController.dispose();
|
||||||
|
numeroController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cargar domicilios guardados
|
||||||
|
Future<void> _cargarDomicilios() async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? domiciliosString = prefs.getString('domicilios');
|
||||||
|
|
||||||
|
if (domiciliosString != null && domiciliosString.isNotEmpty) {
|
||||||
|
setState(() {
|
||||||
|
domicilios = Domicilio.decode(domiciliosString);
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Error al cargar domicilios: $e');
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guardar domicilios en SharedPreferences
|
||||||
|
Future<void> _guardarDomicilios() async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String domiciliosString = Domicilio.encode(domicilios);
|
||||||
|
await prefs.setString('domicilios', domiciliosString);
|
||||||
|
} catch (e) {
|
||||||
|
print('Error al guardar domicilios: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _mostrarDialogoAgregar() {
|
||||||
|
// Limpiar controladores
|
||||||
|
nombreController.clear();
|
||||||
|
coloniaController.clear();
|
||||||
|
calleController.clear();
|
||||||
|
numeroController.clear();
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Título
|
||||||
|
const Text(
|
||||||
|
'Añadir domicilio',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: colorAzul,
|
||||||
),
|
),
|
||||||
body: Padding(
|
),
|
||||||
padding: const EdgeInsets.all(20.0),
|
const SizedBox(height: 20),
|
||||||
|
// Campo: Nombre del domicilio
|
||||||
|
_buildCampoTexto(
|
||||||
|
controller: nombreController,
|
||||||
|
hint: 'Nombre del domicilio',
|
||||||
|
icon: Icons.home_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
// Campo: Colonia
|
||||||
|
_buildCampoTexto(
|
||||||
|
controller: coloniaController,
|
||||||
|
hint: 'Colonia',
|
||||||
|
icon: Icons.location_city_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
// Campo: Calle
|
||||||
|
_buildCampoTexto(
|
||||||
|
controller: calleController,
|
||||||
|
hint: 'Calle',
|
||||||
|
icon: Icons.streetview,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
// Campo: Número
|
||||||
|
_buildCampoTexto(
|
||||||
|
controller: numeroController,
|
||||||
|
hint: 'Número',
|
||||||
|
icon: Icons.numbers,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
// Botones
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
// Botón Cancelar
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: BorderSide(color: colorAzul, width: 2),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Cancelar',
|
||||||
|
style: TextStyle(fontSize: 16, color: colorAzul),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
// Botón Agregar
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: colorAzul,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_agregarDomicilio();
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Agregar',
|
||||||
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCampoTexto({
|
||||||
|
required TextEditingController controller,
|
||||||
|
required String hint,
|
||||||
|
required IconData icon,
|
||||||
|
TextInputType keyboardType = TextInputType.text,
|
||||||
|
}) {
|
||||||
|
return TextField(
|
||||||
|
controller: controller,
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: hint,
|
||||||
|
prefixIcon: Icon(icon, color: colorAzul),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
borderSide: const BorderSide(color: colorAzul),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
borderSide: BorderSide(color: colorAzul.withOpacity(0.5)),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
borderSide: const BorderSide(color: colorAzul, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _agregarDomicilio() async {
|
||||||
|
// Validar que todos los campos estén llenos
|
||||||
|
if (nombreController.text.isEmpty ||
|
||||||
|
coloniaController.text.isEmpty ||
|
||||||
|
calleController.text.isEmpty ||
|
||||||
|
numeroController.text.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Por favor, llena todos los campos'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crear nuevo domicilio con ID único
|
||||||
|
final nuevoDomicilio = Domicilio(
|
||||||
|
nombre: nombreController.text,
|
||||||
|
colonia: coloniaController.text,
|
||||||
|
calle: calleController.text,
|
||||||
|
numero: numeroController.text,
|
||||||
|
id: DateTime.now().millisecondsSinceEpoch.toString(), // ID único
|
||||||
|
);
|
||||||
|
|
||||||
|
// Agregar a la lista
|
||||||
|
setState(() {
|
||||||
|
domicilios.add(nuevoDomicilio);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Guardar en SharedPreferences
|
||||||
|
await _guardarDomicilios();
|
||||||
|
|
||||||
|
// Cerrar el diálogo
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
// Mostrar mensaje de éxito
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Domicilio "${nombreController.text}" agregado'),
|
||||||
|
backgroundColor: colorAzul,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _eliminarDomicilio(int index) async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Eliminar domicilio'),
|
||||||
|
content: Text('¿Deseas eliminar "${domicilios[index].nombre}"?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Cancelar'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
setState(() {
|
||||||
|
domicilios.removeAt(index);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Guardar cambios en SharedPreferences
|
||||||
|
await _guardarDomicilios();
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Domicilio eliminado'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Eliminar', style: TextStyle(color: Colors.red)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// AppBar personalizado
|
||||||
Container(
|
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 Text(
|
||||||
|
'Domicilios',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Contenido
|
||||||
|
Expanded(
|
||||||
|
child: _isLoading
|
||||||
|
? const Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: colorAzul,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: domicilios.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.home_outlined,
|
||||||
|
size: 100,
|
||||||
|
color: Colors.grey.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'No hay domicilios agregados',
|
||||||
|
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 domicilio = domicilios[index];
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
|
child: Container(
|
||||||
padding: const EdgeInsets.all(15),
|
padding: const EdgeInsets.all(15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.black, width: 4),
|
border: Border.all(color: Colors.black, width: 4),
|
||||||
@@ -27,61 +375,58 @@ class DomiciliosView extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Icon(Icons.home_outlined, size: 60),
|
const Icon(Icons.home_outlined, size: 60),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
const Column(
|
Expanded(
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('{NAME}', style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
Text(
|
||||||
Text('Colonia y Ruta', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
domicilio.nombre,
|
||||||
],
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
domicilio.direccionCompleta,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
|
||||||
IconButton(onPressed: () {}, icon: const Icon(Icons.more_horiz, size: 40))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
IconButton(
|
||||||
Container(
|
onPressed: () => _eliminarDomicilio(index),
|
||||||
|
icon: const Icon(Icons.delete_outline, size: 40),
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Botón flotante de agregar
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _mostrarDialogoAgregar,
|
||||||
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 100,
|
height: 100,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colorAzul,
|
color: colorAzul,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.add, color: Colors.black, size: 80),
|
child: const Icon(Icons.add, color: Colors.white, size: 80),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: _customNavBarDomicilio(context),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _customNavBarDomicilio(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
height: 90, color: colorAzul,
|
|
||||||
child: Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
const SizedBox(width: 80),
|
|
||||||
IconButton(onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => const HorariosView())),
|
|
||||||
icon: const Icon(Icons.alt_route_rounded, color: Colors.white, size: 40)),
|
|
||||||
IconButton(onPressed: () {}, icon: const Icon(Icons.notifications_none, color: Colors.white, size: 40)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: -25, left: 30, // Posición según img 2
|
|
||||||
child: Container(
|
|
||||||
width: 85, height: 85,
|
|
||||||
decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle, border: Border.all(color: colorVerde, width: 4)),
|
|
||||||
child: const Icon(Icons.home, color: colorVerde, size: 45),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,39 +1,49 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'rutas.dart';
|
||||||
|
|
||||||
class HorariosView extends StatelessWidget {
|
class HorariosView extends StatelessWidget {
|
||||||
const HorariosView({super.key});
|
const HorariosView({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const color = Color(0xFF0F0D38);
|
|
||||||
|
|
||||||
final List<Map<String, String>> rutas = List.generate(
|
final List<Map<String, String>> rutas = List.generate(
|
||||||
6,
|
6,
|
||||||
(index) => {
|
(index) => {
|
||||||
'colonia': 'Colonia',
|
'colonia': 'Colonia ${index + 1}',
|
||||||
'ruta': 'Ruta',
|
'ruta': 'Ruta ${index + 1}',
|
||||||
'horario': '(horario estimado)',
|
'horario': '${8 + (index % 3)}:${30 * (index % 2)} ${index < 3 ? 'AM' : 'PM'}',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return Scaffold(
|
return Container(
|
||||||
backgroundColor: Colors.white,
|
color: Colors.white,
|
||||||
|
child: SafeArea(
|
||||||
appBar: AppBar(
|
child: Column(
|
||||||
backgroundColor: color,
|
children: [
|
||||||
title: const Text(
|
// 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 Text(
|
||||||
'Horarios',
|
'Horarios',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
centerTitle: true,
|
|
||||||
elevation: 0,
|
|
||||||
),
|
),
|
||||||
|
// Lista de horarios
|
||||||
body: ListView.builder(
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24),
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24),
|
||||||
itemCount: rutas.length,
|
itemCount: rutas.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@@ -46,99 +56,19 @@ class HorariosView extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(item['colonia']!,
|
||||||
item['colonia']!,
|
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||||
style: const TextStyle(
|
Text(item['ruta']!,
|
||||||
fontSize: 22,
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
item['ruta']!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Bloque Derecho: Horario estimado
|
Text(item['horario']!,
|
||||||
Text(
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||||
item['horario']!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
// 3. BARRA INFERIOR (Menú de navegación personalizado)
|
|
||||||
bottomNavigationBar: Container(
|
|
||||||
height: 90,
|
|
||||||
color: colorVerde,
|
|
||||||
child: Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
clipBehavior:
|
|
||||||
Clip.none, // Permite que el botón central sobresalga hacia arriba
|
|
||||||
children: [
|
|
||||||
// Iconos de los lados
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
// Botón de Inicio (Izquierda)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.home_outlined,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 40,
|
|
||||||
),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
// Espacio invisible en medio para que no choque con el botón central grande
|
|
||||||
const SizedBox(width: 80),
|
|
||||||
// Botón de Notificaciones (Derecha)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.notifications_none,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 40,
|
|
||||||
),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// Botón Central Flotante y personalizado (Mapa/Ruta)
|
|
||||||
Positioned(
|
|
||||||
top: -25, // Lo empuja hacia arriba fuera de la barra verde
|
|
||||||
child: Container(
|
|
||||||
width: 85,
|
|
||||||
height: 85,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(color: colorVerde, width: 4),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.3),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.alt_route_rounded, // Icono similar de caminos/puntos
|
|
||||||
color: colorVerde,
|
|
||||||
size: 45,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
114
lib/src/views/login.dart
Normal file
114
lib/src/views/login.dart
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'rutas.dart';
|
||||||
|
import 'main_screen.dart';
|
||||||
|
|
||||||
|
class LoginView extends StatelessWidget {
|
||||||
|
const LoginView({super.key});
|
||||||
|
|
||||||
|
final Color colorAzul = const Color(0xFF0F0D38);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: colorAzul,
|
||||||
|
title: const Text('Iniciar Sesión',
|
||||||
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 28)),
|
||||||
|
centerTitle: true,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back, color: Colors.white, size: 30),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Campo de Correo
|
||||||
|
_buildInput(Icons.email_outlined, 'Correo electrónico', obscureText: false),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
// Campo de Contraseña
|
||||||
|
_buildInput(Icons.lock_outline, 'Contraseña', obscureText: true),
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
// Botones
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
// Botón Iniciar Sesión
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: colorAzul,
|
||||||
|
minimumSize: const Size(double.infinity, 55),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const MainScreen()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Iniciar Sesión',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
// Botón Crear Cuenta
|
||||||
|
OutlinedButton(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
minimumSize: const Size(double.infinity, 55),
|
||||||
|
side: BorderSide(color: colorAzul, width: 2),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Crear Cuenta',
|
||||||
|
style: TextStyle(color: colorAzul, fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInput(IconData icon, String hint, {bool obscureText = false}) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: Colors.black, width: 2),
|
||||||
|
),
|
||||||
|
child: Icon(icon, size: 40, color: Colors.black),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
obscureText: obscureText,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: hint,
|
||||||
|
hintStyle: TextStyle(color: colorAzul.withOpacity(0.5), fontWeight: FontWeight.bold, fontSize: 22),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
borderSide: BorderSide(color: colorAzul, width: 4),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
borderSide: BorderSide(color: colorAzul, width: 4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
lib/src/views/main_screen.dart
Normal file
70
lib/src/views/main_screen.dart
Normal file
@@ -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<MainScreen> createState() => _MainScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainScreenState extends State<MainScreen> {
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
86
lib/src/views/nav_bar.dart
Normal file
86
lib/src/views/nav_bar.dart
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'rutas.dart';
|
||||||
|
|
||||||
|
class CustomNavBar extends StatelessWidget {
|
||||||
|
final int currentIndex;
|
||||||
|
final Function(int) onTap;
|
||||||
|
|
||||||
|
const CustomNavBar({
|
||||||
|
super.key,
|
||||||
|
required this.currentIndex,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
height: 90,
|
||||||
|
color: colorAzul,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
_buildNavButton(
|
||||||
|
index: 0,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
iconNormal: Icons.home_outlined,
|
||||||
|
iconActive: Icons.home,
|
||||||
|
label: 'Domicilios',
|
||||||
|
onTap: onTap,
|
||||||
|
),
|
||||||
|
_buildNavButton(
|
||||||
|
index: 1,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
iconNormal: Icons.alt_route_rounded,
|
||||||
|
iconActive: Icons.alt_route_rounded,
|
||||||
|
label: 'Rutas',
|
||||||
|
onTap: onTap,
|
||||||
|
),
|
||||||
|
_buildNavButton(
|
||||||
|
index: 2,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
iconNormal: Icons.settings_outlined,
|
||||||
|
iconActive: Icons.settings,
|
||||||
|
label: 'Configuración',
|
||||||
|
onTap: onTap,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNavButton({
|
||||||
|
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: () => onTap(index),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
isActive ? iconActive : iconNormal,
|
||||||
|
color: Colors.white,
|
||||||
|
size: isActive ? 55 : 35,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: isActive ? 14 : 12,
|
||||||
|
fontWeight: isActive ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,99 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'domicilios.dart';
|
|
||||||
import 'configuracion.dart';
|
|
||||||
|
|
||||||
const Color colorVerde = Color(0xFF2E4D31);
|
|
||||||
const Color colorAzul = Color(0xFF0F0D38);
|
const Color colorAzul = Color(0xFF0F0D38);
|
||||||
|
const Color colorAzulClaro = Color(0xFF2A2A5E);
|
||||||
class HorariosView extends StatelessWidget {
|
|
||||||
const HorariosView({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final List<Map<String, String>> rutas = List.generate(
|
|
||||||
6,
|
|
||||||
(index) => {
|
|
||||||
'colonia': 'Colonia',
|
|
||||||
'ruta': 'Ruta',
|
|
||||||
'horario': '(horario estimado)',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
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)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(item['horario']!, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
bottomNavigationBar: _customNavBar(context, 1),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Widget reutilizable para la barra inferior de las 3 vistas
|
|
||||||
Widget _customNavBar(BuildContext context, int activeIndex) {
|
|
||||||
return Container(
|
|
||||||
height: 90,
|
|
||||||
color: colorAzul,
|
|
||||||
child: Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.home_outlined, color: Colors.white, size: activeIndex == 0 ? 0 : 40),
|
|
||||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => const DomiciliosView())),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 80),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(activeIndex == 2 ? Icons.settings : Icons.notifications_none, color: Colors.white, size: activeIndex == 2 ? 0 : 40),
|
|
||||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => const ConfiguracionView())),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: -25,
|
|
||||||
child: Container(
|
|
||||||
width: 85, height: 85,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(color: colorVerde, width: 4),
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
activeIndex == 0 ? Icons.home : (activeIndex == 1 ? Icons.alt_route_rounded : Icons.settings),
|
|
||||||
color: colorVerde, size: 45,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user