modificaciones en el sistema
This commit is contained in:
@@ -2,16 +2,20 @@ import 'package:flutter/material.dart';
|
||||
import 'tarjetaeta.dart';
|
||||
import 'configuraciondomicilio.dart';
|
||||
import 'notificaciones_service.dart';
|
||||
import 'ruta_exclusiva.dart';
|
||||
import 'guia_separacion.dart';
|
||||
|
||||
class Domicilio {
|
||||
final String id;
|
||||
final String etiqueta;
|
||||
final String direccion;
|
||||
final String colonia; // ← NUEVO
|
||||
|
||||
Domicilio({
|
||||
required this.id,
|
||||
required this.etiqueta,
|
||||
required this.direccion,
|
||||
required this.colonia, // ← NUEVO
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,11 +35,13 @@ class _GestionDomiciliosScreenState
|
||||
id: '1',
|
||||
etiqueta: 'Casa',
|
||||
direccion: 'Av. Reforma 222, CDMX',
|
||||
colonia: 'Zona Centro', // ← NUEVO
|
||||
),
|
||||
Domicilio(
|
||||
id: '2',
|
||||
etiqueta: 'Trabajo',
|
||||
direccion: 'Benito Juárez 45',
|
||||
colonia: 'Las Arboledas', // ← NUEVO
|
||||
),
|
||||
];
|
||||
|
||||
@@ -57,13 +63,15 @@ class _GestionDomiciliosScreenState
|
||||
notificarInicioRuta: _notificarInicioRuta,
|
||||
notificarAproximacion: _notificarAproximacion,
|
||||
notificarRetrasosFallas: _notificarRetrasosFallas,
|
||||
onDomicilioGuardado: (String etiqueta, String direccion) {
|
||||
// ← ahora recibe también colonia
|
||||
onDomicilioGuardado: (String etiqueta, String direccion, String colonia) {
|
||||
setState(() {
|
||||
_misDomicilios.add(
|
||||
Domicilio(
|
||||
id: DateTime.now().toString(),
|
||||
etiqueta: etiqueta,
|
||||
direccion: direccion,
|
||||
colonia: colonia, // ← NUEVO
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -108,112 +116,390 @@ class _GestionDomiciliosScreenState
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
|
||||
appBar: AppBar(
|
||||
title: const Text('Mis Domicilios'),
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.notifications_outlined),
|
||||
tooltip: 'Alertas y Notificaciones',
|
||||
onPressed: () async {
|
||||
final resultado = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AlertasNotificacionesScreen(
|
||||
notificarInicioRuta: _notificarInicioRuta,
|
||||
notificarAproximacion: _notificarAproximacion,
|
||||
notificarRetrasosFallas: _notificarRetrasosFallas,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (resultado != null) {
|
||||
setState(() {
|
||||
_notificarInicioRuta = resultado['inicio'];
|
||||
_notificarAproximacion = resultado['aproximacion'];
|
||||
_notificarRetrasosFallas = resultado['retrasos'];
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
body: Column(
|
||||
body: Stack(
|
||||
children: [
|
||||
|
||||
// ← TARJETA ETA corregida
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: TarjetaEtaWidget(), // ← child bien cerrado aquí
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
color: const Color(0xFF5BB8E8),
|
||||
),
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'Lugares Registrados',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
Positioned(
|
||||
top: 80,
|
||||
left: -40,
|
||||
right: -40,
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.75,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF4AA8D8).withValues(alpha: 0.5),
|
||||
borderRadius: BorderRadius.circular(200),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 80,
|
||||
right: -10,
|
||||
child: CustomPaint(
|
||||
size: const Size(160, 130),
|
||||
painter: _MountainPainter(color: const Color(0xFF2E7D32)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 80,
|
||||
right: 60,
|
||||
child: CustomPaint(
|
||||
size: const Size(120, 100),
|
||||
painter: _MountainPainter(color: const Color(0xFF388E3C)),
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 0, left: 0, right: 0,
|
||||
child: Container(height: 90, color: const Color(0xFF4CAF50)),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 30, left: 0, right: 0,
|
||||
child: Container(
|
||||
height: 18,
|
||||
color: const Color(0xFF424242),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: List.generate(
|
||||
12,
|
||||
(_) => Container(width: 20, height: 3, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
Positioned(bottom: 45, left: 20,
|
||||
child: _buildHouse(const Color(0xFF90A4AE), 40)),
|
||||
Positioned(bottom: 45, left: 80,
|
||||
child: _buildHouse(const Color(0xFF795548), 35)),
|
||||
Positioned(bottom: 45, right: 20,
|
||||
child: _buildHouse(const Color(0xFFFFCC80), 45)),
|
||||
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: _misDomicilios.length,
|
||||
itemBuilder: (context, index) {
|
||||
final domicilio = _misDomicilios[index];
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
Positioned(bottom: 33, left: 110,
|
||||
child: _buildTruck(const Color(0xFFE53935))),
|
||||
Positioned(bottom: 33, right: 80,
|
||||
child: _buildTruck(const Color(0xFFE53935))),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
|
||||
Column(
|
||||
children: [
|
||||
Container(height: 10, color: const Color(0xFFE8534A)),
|
||||
Container(height: 8, color: const Color(0xFFF5A623)),
|
||||
Container(height: 8, color: const Color(0xFFFFD700)),
|
||||
Container(height: 8, color: const Color(0xFF4CAF50)),
|
||||
],
|
||||
),
|
||||
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
const Text(
|
||||
'ECOUBICEL.',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.black87,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.recycling, color: Color(0xFF2E7D32), size: 28),
|
||||
const Spacer(),
|
||||
|
||||
// ── Botón notificaciones ──
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF4CAF50),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.notifications_outlined, color: Colors.white),
|
||||
tooltip: 'Alertas y Notificaciones',
|
||||
onPressed: () async {
|
||||
final resultado = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AlertasNotificacionesScreen(
|
||||
notificarInicioRuta: _notificarInicioRuta,
|
||||
notificarAproximacion: _notificarAproximacion,
|
||||
notificarRetrasosFallas: _notificarRetrasosFallas,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (resultado != null) {
|
||||
setState(() {
|
||||
_notificarInicioRuta = resultado['inicio'];
|
||||
_notificarAproximacion = resultado['aproximacion'];
|
||||
_notificarRetrasosFallas = resultado['retrasos'];
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// ── Botón Mi Ruta ──
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1E88E5),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.map_outlined, color: Colors.white),
|
||||
tooltip: 'Mi Ruta',
|
||||
onPressed: () {
|
||||
// ← usa colonia real del primer domicilio
|
||||
final domicilio = _misDomicilios.isNotEmpty
|
||||
? _misDomicilios[0]
|
||||
: null;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RutaExclusivaScreen(
|
||||
direccionUsuario: domicilio?.direccion ?? 'Sin dirección',
|
||||
coloniaUsuario: domicilio?.colonia ?? '', // ← CAMBIADO
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF558B2F),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.eco_outlined, color: Colors.white),
|
||||
tooltip: 'Guía de Separación',
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const GuiaSeparacionScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.green[100],
|
||||
child: Icon(
|
||||
_obtenerIcono(domicilio.etiqueta),
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TarjetaEtaWidget(),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 5,
|
||||
height: 22,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF4CAF50),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
title: Text(domicilio.etiqueta),
|
||||
subtitle: Text(domicilio.direccion),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.red),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_misDomicilios.removeAt(index);
|
||||
});
|
||||
},
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'Lugares Registrados',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(bottom: 100),
|
||||
itemCount: _misDomicilios.length,
|
||||
itemBuilder: (context, index) {
|
||||
final domicilio = _misDomicilios[index];
|
||||
final cardColors = [
|
||||
const Color(0xFF4CAF50),
|
||||
const Color(0xFF1E88E5),
|
||||
const Color(0xFFE65100),
|
||||
];
|
||||
final cardColor = cardColors[index % cardColors.length];
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: cardColor,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: cardColor.withValues(alpha: 0.4),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 4),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.white.withValues(alpha: 0.3),
|
||||
child: Icon(
|
||||
_obtenerIcono(domicilio.etiqueta),
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
domicilio.etiqueta,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
// ← muestra colonia como subtítulo
|
||||
subtitle: Text(
|
||||
'${domicilio.direccion} • ${domicilio.colonia}',
|
||||
style: const TextStyle(color: Colors.white70),
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.white),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_misDomicilios.removeAt(index);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: _mostrarFormularioAgregar,
|
||||
backgroundColor: Colors.green,
|
||||
backgroundColor: const Color(0xFFE65100),
|
||||
foregroundColor: Colors.white,
|
||||
shape: const StadiumBorder(),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Agregar'),
|
||||
label: const Text(
|
||||
'Agregar',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHouse(Color color, double size) {
|
||||
return CustomPaint(
|
||||
size: Size(size, size * 0.9),
|
||||
painter: _HousePainter(color: color),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTruck(Color color) {
|
||||
return Container(
|
||||
width: 36,
|
||||
height: 18,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
width: 12,
|
||||
height: 14,
|
||||
margin: const EdgeInsets.only(right: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.7),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(3),
|
||||
topLeft: Radius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MountainPainter extends CustomPainter {
|
||||
final Color color;
|
||||
_MountainPainter({required this.color});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()..color = color;
|
||||
final path = Path()
|
||||
..moveTo(0, size.height)
|
||||
..lineTo(size.width / 2, 0)
|
||||
..lineTo(size.width, size.height)
|
||||
..close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_) => false;
|
||||
}
|
||||
|
||||
class _HousePainter extends CustomPainter {
|
||||
final Color color;
|
||||
_HousePainter({required this.color});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()..color = color;
|
||||
canvas.drawRect(
|
||||
Rect.fromLTWH(0, size.height * 0.4, size.width, size.height * 0.6),
|
||||
paint,
|
||||
);
|
||||
final roof = Paint()..color = const Color(0xFFB71C1C);
|
||||
final path = Path()
|
||||
..moveTo(0, size.height * 0.4)
|
||||
..lineTo(size.width / 2, 0)
|
||||
..lineTo(size.width, size.height * 0.4)
|
||||
..close();
|
||||
canvas.drawPath(path, roof);
|
||||
canvas.drawRect(
|
||||
Rect.fromLTWH(size.width * 0.25, size.height * 0.55,
|
||||
size.width * 0.2, size.height * 0.2),
|
||||
Paint()..color = const Color(0xFFB3E5FC),
|
||||
);
|
||||
canvas.drawRect(
|
||||
Rect.fromLTWH(size.width * 0.55, size.height * 0.65,
|
||||
size.width * 0.2, size.height * 0.35),
|
||||
Paint()..color = const Color(0xFF5D4037),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user