build + feat: imlementacion de estrucutras de interfaz grafica, construccion del proyecto. Pendiente de arreglar: errores en interfaces
This commit is contained in:
69
lib/features/auth/data/models/auth_user_model.dart
Normal file
69
lib/features/auth/data/models/auth_user_model.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import '../../domain/entities/auth_user.dart';
|
||||
|
||||
/// Modelo de datos que extiende la entidad [AuthUser].
|
||||
/// Responsable de serialización/deserialización JSON.
|
||||
/// En la fase MVP el token se simula localmente (sin llamada real a backend).
|
||||
class AuthUserModel extends AuthUser {
|
||||
const AuthUserModel({
|
||||
required super.token,
|
||||
required super.email,
|
||||
required super.role,
|
||||
required super.issuedAt,
|
||||
required super.expiresAt,
|
||||
});
|
||||
|
||||
factory AuthUserModel.fromJson(Map<String, dynamic> json) {
|
||||
return AuthUserModel(
|
||||
token: json['token'] as String,
|
||||
email: json['email'] as String,
|
||||
role: json['role'] as String? ?? 'citizen',
|
||||
issuedAt: DateTime.parse(json['issued_at'] as String),
|
||||
expiresAt: DateTime.parse(json['expires_at'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'token': token,
|
||||
'email': email,
|
||||
'role': role,
|
||||
'issued_at': issuedAt.toIso8601String(),
|
||||
'expires_at': expiresAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Crea un token JWT simulado para la fase MVP.
|
||||
/// En producción este token vendría del backend con firma RS256.
|
||||
factory AuthUserModel.simulatedJwt({
|
||||
required String email,
|
||||
required String role,
|
||||
}) {
|
||||
final now = DateTime.now();
|
||||
// Header.Payload.Signature — simulado con base64 simple
|
||||
final header = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9';
|
||||
final payloadRaw =
|
||||
'{"sub":"usr_${email.hashCode.abs()}","email":"$email","role":"$role",'
|
||||
'"iat":${now.millisecondsSinceEpoch},'
|
||||
'"exp":${now.add(const Duration(hours: 8)).millisecondsSinceEpoch},'
|
||||
'"iss":"waste-notify-mvp"}';
|
||||
// ignore: deprecated_member_use
|
||||
final payload = _base64UrlEncode(payloadRaw);
|
||||
const signature = 'SIMULATED_SIGNATURE_MVP';
|
||||
|
||||
return AuthUserModel(
|
||||
token: '$header.$payload.$signature',
|
||||
email: email,
|
||||
role: role,
|
||||
issuedAt: now,
|
||||
expiresAt: now.add(const Duration(hours: 8)),
|
||||
);
|
||||
}
|
||||
|
||||
static String _base64UrlEncode(String input) {
|
||||
final bytes = input.codeUnits;
|
||||
final encoded = bytes
|
||||
.map((b) => b.toRadixString(16).padLeft(2, '0'))
|
||||
.join();
|
||||
return encoded.substring(0, encoded.length > 64 ? 64 : encoded.length);
|
||||
}
|
||||
}
|
||||
406
lib/features/auth/data/models/mock_waste_data.dart
Normal file
406
lib/features/auth/data/models/mock_waste_data.dart
Normal file
@@ -0,0 +1,406 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
// Modelo 1: Reglas de Notificaciones Push (JSON Parte 1)
|
||||
class NotificationRule {
|
||||
final String triggerEvent;
|
||||
final String condition;
|
||||
final String title;
|
||||
final String body;
|
||||
|
||||
NotificationRule({
|
||||
required this.triggerEvent,
|
||||
required this.condition,
|
||||
required this.title,
|
||||
required this.body,
|
||||
});
|
||||
}
|
||||
|
||||
// Modelo 2: Catálogo de Colonias y Horarios (JSON Parte 2)
|
||||
class ZoneSchedule {
|
||||
final String colonia;
|
||||
final String routeId;
|
||||
final String horarioEstimado;
|
||||
|
||||
ZoneSchedule({
|
||||
required this.colonia,
|
||||
required this.routeId,
|
||||
required this.horarioEstimado,
|
||||
});
|
||||
}
|
||||
|
||||
// Modelo 3: Geometría Perimetral de la Ruta (JSON Parte 3 de tus Imágenes)
|
||||
class RouteTelemetry {
|
||||
final String routeId;
|
||||
final String name;
|
||||
final int truckId;
|
||||
final String status;
|
||||
final List<LatLng> boundaryPoints;
|
||||
|
||||
RouteTelemetry({
|
||||
required this.routeId,
|
||||
required this.name,
|
||||
required this.truckId,
|
||||
required this.status,
|
||||
required this.boundaryPoints,
|
||||
});
|
||||
}
|
||||
|
||||
class MockWasteData {
|
||||
// Datos reales cargados de tu JSON Parte 1
|
||||
static final List<NotificationRule> alerts = [
|
||||
NotificationRule(
|
||||
triggerEvent: 'ROUTE_START',
|
||||
condition: 'Cuando positionId cambia de 1 a 2',
|
||||
title: '¡Ruta Iniciada!',
|
||||
body:
|
||||
'El camión recolector ha salido del Relleno Sanitario rumbo a tu sector. Asegúrate de tener listos tus residuos.',
|
||||
),
|
||||
NotificationRule(
|
||||
triggerEvent: 'TRUCK_PROXIMITY',
|
||||
condition: 'Cuando positionId llega a 4 (punto previo al destino)',
|
||||
title: 'Camión Cercano 🚚',
|
||||
body:
|
||||
'El camión está a menos de 15 minutos de tu domicilio. Es momento de sacar tus bolsas a la acera.',
|
||||
),
|
||||
NotificationRule(
|
||||
triggerEvent: 'ROUTE_COMPLETED',
|
||||
condition: 'Cuando positionId llega a 8 (retorno al basurero)',
|
||||
title: 'Servicio Finalizado',
|
||||
body:
|
||||
'El camión de tu sector ha concluido su jornada de recolección diaria.',
|
||||
),
|
||||
];
|
||||
|
||||
// Datos reales cargados de tu JSON Parte 2 (Expandido para dar soporte a más rutas)
|
||||
static final List<ZoneSchedule> schedules = [
|
||||
ZoneSchedule(
|
||||
colonia: 'Zona Centro',
|
||||
routeId: 'RUTA-01',
|
||||
horarioEstimado: 'Matutino (06:30 - 07:15)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Las Arboledas',
|
||||
routeId: 'RUTA-01',
|
||||
horarioEstimado: 'Matutino (07:00 - 07:30)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'San Juanico',
|
||||
routeId: 'RUTA-03',
|
||||
horarioEstimado: 'Matutino (06:45 - 07:15)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Los Olivos',
|
||||
routeId: 'RUTA-04',
|
||||
horarioEstimado: 'Matutino (07:00 - 07:40)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Rancho Seco',
|
||||
routeId: 'RUTA-05',
|
||||
horarioEstimado: 'Vespertino (14:15 - 15:00)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Las Insurgentes',
|
||||
routeId: 'RUTA-12',
|
||||
horarioEstimado: 'Matutino (06:35 - 07:10)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Trojes',
|
||||
routeId: 'RUTA-13',
|
||||
horarioEstimado: 'Matutino (06:40 - 07:10)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Tecnológico',
|
||||
routeId: 'RUTA-02',
|
||||
horarioEstimado: 'Matutino (07:15 - 08:00)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Rumbos de Roque',
|
||||
routeId: 'RUTA-06',
|
||||
horarioEstimado: 'Matutino (08:30 - 09:15)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Ciudad Industrial',
|
||||
routeId: 'RUTA-07',
|
||||
horarioEstimado: 'Vespertino (15:00 - 16:00)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Universidad Latina',
|
||||
routeId: 'RUTA-08',
|
||||
horarioEstimado: 'Matutino (07:45 - 08:30)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Hospital General',
|
||||
routeId: 'RUTA-09',
|
||||
horarioEstimado: 'Vespertino (13:30 - 14:15)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Eje Juan Pablo II',
|
||||
routeId: 'RUTA-10',
|
||||
horarioEstimado: 'Nocturno (19:00 - 20:00)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'Torres Landa',
|
||||
routeId: 'RUTA-11',
|
||||
horarioEstimado: 'Matutino (06:50 - 07:30)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'La Toscana',
|
||||
routeId: 'RUTA-14',
|
||||
horarioEstimado: 'Nocturno (20:15 - 21:00)'),
|
||||
ZoneSchedule(
|
||||
colonia: 'San José de Celaya',
|
||||
routeId: 'RUTA-15',
|
||||
horarioEstimado: 'Vespertino (16:30 - 17:15)'),
|
||||
];
|
||||
|
||||
// Base de datos de Geometría extraída de tus capturas (Mapeo RUTA-01 a RUTA-15)
|
||||
static final Map<String, RouteTelemetry> boundaries = {
|
||||
'RUTA-01': RouteTelemetry(
|
||||
routeId: 'RUTA-01',
|
||||
name: 'Zona Centro - Las Arboledas',
|
||||
truckId: 101,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5185, -100.8450),
|
||||
LatLng(20.5215, -100.8142),
|
||||
LatLng(20.5212, -100.8175),
|
||||
LatLng(20.5210, -100.8210),
|
||||
LatLng(20.5235, -100.8212),
|
||||
LatLng(20.5260, -100.8215),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-02': RouteTelemetry(
|
||||
routeId: 'RUTA-02',
|
||||
name: 'Sector Norte - Av. Tecnológico',
|
||||
truckId: 102,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5280, -100.8135),
|
||||
LatLng(20.5410, -100.8130),
|
||||
LatLng(20.5445, -100.8132),
|
||||
LatLng(20.5480, -100.8135),
|
||||
LatLng(20.5515, -100.8160),
|
||||
LatLng(20.5540, -100.8110),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-03': RouteTelemetry(
|
||||
routeId: 'RUTA-03',
|
||||
name: 'Sector Poniente - San Juanico',
|
||||
truckId: 103,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5185, -100.8510),
|
||||
LatLng(20.5290, -100.8320),
|
||||
LatLng(20.5315, -100.8355),
|
||||
LatLng(20.5340, -100.8390),
|
||||
LatLng(20.5362, -100.8425),
|
||||
LatLng(20.5330, -100.8430),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-04': RouteTelemetry(
|
||||
routeId: 'RUTA-04',
|
||||
name: 'Oriente - Los Olivos',
|
||||
truckId: 104,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5260, -100.8010),
|
||||
LatLng(20.5295, -100.7890),
|
||||
LatLng(20.5320, -100.7850),
|
||||
LatLng(20.5350, -100.7790),
|
||||
LatLng(20.5310, -100.7760),
|
||||
LatLng(20.5270, -100.7820),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-05': RouteTelemetry(
|
||||
routeId: 'RUTA-05',
|
||||
name: 'Sector Sur - Rancho Seco',
|
||||
truckId: 105,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5050, -100.8620),
|
||||
LatLng(20.5020, -100.8350),
|
||||
LatLng(20.4995, -100.8210),
|
||||
LatLng(20.4970, -100.8150),
|
||||
LatLng(20.5010, -100.8120),
|
||||
LatLng(20.5060, -100.8160),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-06': RouteTelemetry(
|
||||
routeId: 'RUTA-06',
|
||||
name: 'Norte Extremo - Rumbos de Roque',
|
||||
truckId: 106,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5380, -100.8380),
|
||||
LatLng(20.5610, -100.8370),
|
||||
LatLng(20.5750, -100.8360),
|
||||
LatLng(20.5820, -100.8350),
|
||||
LatLng(20.5780, -100.8310),
|
||||
LatLng(20.5650, -100.8320),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-07': RouteTelemetry(
|
||||
routeId: 'RUTA-07',
|
||||
name: 'Nororiente - Ciudad Industrial',
|
||||
truckId: 107,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5350, -100.8050),
|
||||
LatLng(20.5450, -100.7950),
|
||||
LatLng(20.5480, -100.7850),
|
||||
LatLng(20.5510, -100.7750),
|
||||
LatLng(20.5460, -100.7720),
|
||||
LatLng(20.5390, -100.7820),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-08': RouteTelemetry(
|
||||
routeId: 'RUTA-08',
|
||||
name: 'Suroriente - Universidad Latina',
|
||||
truckId: 108,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5180, -100.8310),
|
||||
LatLng(20.5245, -100.7980),
|
||||
LatLng(20.5210, -100.7995),
|
||||
LatLng(20.5175, -100.8010),
|
||||
LatLng(20.5140, -100.8030),
|
||||
LatLng(20.5110, -100.8055),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-09': RouteTelemetry(
|
||||
routeId: 'RUTA-09',
|
||||
name: 'Poniente - Hospital General',
|
||||
truckId: 109,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5210, -100.8650),
|
||||
LatLng(20.5260, -100.8520),
|
||||
LatLng(20.5275, -100.8490),
|
||||
LatLng(20.5285, -100.8460),
|
||||
LatLng(20.5250, -100.8470),
|
||||
LatLng(20.5220, -100.8550),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-10': RouteTelemetry(
|
||||
routeId: 'RUTA-10',
|
||||
name: 'Eje Juan Pablo II - Sede UG Sur',
|
||||
truckId: 110,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5015, -100.8520),
|
||||
LatLng(20.4990, -100.8390),
|
||||
LatLng(20.4950, -100.8320),
|
||||
LatLng(20.4920, -100.8280),
|
||||
LatLng(20.4945, -100.8240),
|
||||
LatLng(20.4980, -100.8300),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-11': RouteTelemetry(
|
||||
routeId: 'RUTA-11',
|
||||
name: 'Zona de Oro - Torres Landa',
|
||||
truckId: 111,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5240, -100.8350),
|
||||
LatLng(20.5280, -100.8250),
|
||||
LatLng(20.5295, -100.8210),
|
||||
LatLng(20.5310, -100.8170),
|
||||
LatLng(20.5290, -100.8140),
|
||||
LatLng(20.5260, -100.8200),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-12': RouteTelemetry(
|
||||
routeId: 'RUTA-12',
|
||||
name: 'Nororiente - Las Insurgentes',
|
||||
truckId: 112,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5280, -100.8080),
|
||||
LatLng(20.5320, -100.7980),
|
||||
LatLng(20.5340, -100.7940),
|
||||
LatLng(20.5360, -100.7900),
|
||||
LatLng(20.5310, -100.7920),
|
||||
LatLng(20.5270, -100.8020),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-13': RouteTelemetry(
|
||||
routeId: 'RUTA-13',
|
||||
name: 'Sector Norte - Trojes e Irrigación',
|
||||
truckId: 113,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5360, -100.8190),
|
||||
LatLng(20.5420, -100.8080),
|
||||
LatLng(20.5440, -100.8040),
|
||||
LatLng(20.5460, -100.8000),
|
||||
LatLng(20.5410, -100.8020),
|
||||
LatLng(20.5370, -100.8120),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-14': RouteTelemetry(
|
||||
routeId: 'RUTA-14',
|
||||
name: 'Sur Poniente - La Toscana',
|
||||
truckId: 114,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5150, -100.8580),
|
||||
LatLng(20.5140, -100.8390),
|
||||
LatLng(20.5125, -100.8310),
|
||||
LatLng(20.5110, -100.8250),
|
||||
LatLng(20.5135, -100.8280),
|
||||
LatLng(20.5160, -100.8420),
|
||||
LatLng(20.5111, -100.9037)
|
||||
],
|
||||
),
|
||||
'RUTA-15': RouteTelemetry(
|
||||
routeId: 'RUTA-15',
|
||||
name: 'Norponiente - Camino a San José de Celaya',
|
||||
truckId: 115,
|
||||
status: 'EN_RUTA',
|
||||
boundaryPoints: [
|
||||
LatLng(20.5111, -100.9037),
|
||||
LatLng(20.5320, -100.8590),
|
||||
LatLng(20.5390, -100.8480),
|
||||
LatLng(20.5420, -100.8440),
|
||||
LatLng(20.5450, -100.8410),
|
||||
LatLng(20.5410, -100.8430),
|
||||
LatLng(20.5360, -100.8520),
|
||||
LatLng(20.5111, -100.9037),
|
||||
],
|
||||
),
|
||||
}; // 🔒 AQUÍ SE CIERRA EL MAPA DE BOUNDARIES
|
||||
} // 🔒 AQUÍ SE CIERRA LA CLASE MOCKWASTEDATA
|
||||
|
||||
// 📍 LA CLASE DE OPTIMIZACIÓN DE COSTOS DEBE IR TOTALMENTE AQUÍ AFUERA:
|
||||
class SpatialAnalysisService {
|
||||
|
||||
// Simula la fórmula matemática de Haversine para calcular distancias en el Backend
|
||||
// Esto evita hacer llamadas de pago a la Distance Matrix API de Google Maps
|
||||
static double calcularDistanciaEntrePuntos(LatLng p1, LatLng p2) {
|
||||
// El Backend resuelve esto de forma interna con PostGIS o librerías del lenguaje
|
||||
return const Distance().as(LengthUnit.Meter, p1, p2);
|
||||
}
|
||||
|
||||
// Simula la consulta única a OpenStreetMap Nominatim en el registro
|
||||
static Future<LatLng> geocodificarDomicilioUnicaVez(String direccion, String colonia) async {
|
||||
final schedule = MockWasteData.schedules.firstWhere(
|
||||
(e) => e.colonia.toLowerCase() == colonia.toLowerCase(),
|
||||
orElse: () => MockWasteData.schedules.first,
|
||||
);
|
||||
final telemetry = MockWasteData.boundaries[schedule.routeId]!;
|
||||
return telemetry.boundaryPoints.first; // Retorna la coordenada almacenada
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../domain/entities/auth_user.dart';
|
||||
import '../../domain/repositories/auth_repository.dart';
|
||||
import '../models/auth_user_model.dart';
|
||||
|
||||
/// Implementación concreta del repositorio de autenticación.
|
||||
///
|
||||
/// FASE MVP: Simula un servidor de autenticación localmente.
|
||||
/// El token JWT generado tiene estructura real pero firma simulada.
|
||||
///
|
||||
/// PRODUCCIÓN (futura): Reemplazar [_simulateNetworkCall] con llamada HTTP
|
||||
/// real al endpoint POST /auth/login usando Dio o http package.
|
||||
class AuthRepositoryImpl implements AuthRepository {
|
||||
static const String _sessionKey = 'waste_notify_session';
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
AuthRepositoryImpl(this._prefs);
|
||||
|
||||
@override
|
||||
Future<AuthUser> login({
|
||||
required String identifier,
|
||||
required String password,
|
||||
}) async {
|
||||
// Simula latencia de red para UX realista
|
||||
await _simulateNetworkCall();
|
||||
|
||||
// FASE MVP: Credenciales hardcoded para demostración
|
||||
// PRODUCCIÓN: POST /api/v1/auth/login con body {identifier, password}
|
||||
final validCredentials = {
|
||||
'ciudadano@ejemplo.com': ('password123', 'citizen'),
|
||||
'operador@ejemplo.com': ('operador456', 'operator'),
|
||||
'5551234567': ('pass1234', 'citizen'),
|
||||
};
|
||||
|
||||
final entry = validCredentials[identifier];
|
||||
if (entry == null || entry.$1 != password) {
|
||||
throw AuthException(
|
||||
code: 'INVALID_CREDENTIALS',
|
||||
message: 'Correo/teléfono o contraseña incorrectos.',
|
||||
);
|
||||
}
|
||||
|
||||
final user = AuthUserModel.simulatedJwt(
|
||||
email: identifier,
|
||||
role: entry.$2,
|
||||
);
|
||||
|
||||
// Persiste sesión localmente (token cifrado en producción con flutter_secure_storage)
|
||||
await _saveSession(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> logout() async {
|
||||
await _prefs.remove(_sessionKey);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<AuthUser?> getStoredSession() async {
|
||||
final raw = _prefs.getString(_sessionKey);
|
||||
if (raw == null) return null;
|
||||
|
||||
try {
|
||||
final json = jsonDecode(raw) as Map<String, dynamic>;
|
||||
final user = AuthUserModel.fromJson(json);
|
||||
if (user.isExpired) {
|
||||
await _prefs.remove(_sessionKey);
|
||||
return null;
|
||||
}
|
||||
return user;
|
||||
} catch (_) {
|
||||
await _prefs.remove(_sessionKey);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _saveSession(AuthUserModel user) async {
|
||||
await _prefs.setString(_sessionKey, jsonEncode(user.toJson()));
|
||||
}
|
||||
|
||||
Future<void> _simulateNetworkCall() async {
|
||||
await Future.delayed(const Duration(milliseconds: 1200));
|
||||
}
|
||||
}
|
||||
|
||||
/// Excepción tipada para errores de autenticación.
|
||||
class AuthException implements Exception {
|
||||
final String code;
|
||||
final String message;
|
||||
|
||||
const AuthException({required this.code, required this.message});
|
||||
|
||||
@override
|
||||
String toString() => 'AuthException[$code]: $message';
|
||||
}
|
||||
27
lib/features/auth/domain/entities/auth_user.dart
Normal file
27
lib/features/auth/domain/entities/auth_user.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Entidad de dominio que representa un usuario autenticado.
|
||||
/// Almacena únicamente el token (simulado JWT) y el rol,
|
||||
/// sin datos de ubicación o rastreo.
|
||||
class AuthUser extends Equatable {
|
||||
final String token;
|
||||
final String email;
|
||||
final String role; // 'citizen' | 'operator'
|
||||
final DateTime issuedAt;
|
||||
final DateTime expiresAt;
|
||||
|
||||
const AuthUser({
|
||||
required this.token,
|
||||
required this.email,
|
||||
required this.role,
|
||||
required this.issuedAt,
|
||||
required this.expiresAt,
|
||||
});
|
||||
|
||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||
|
||||
bool get isValid => token.isNotEmpty && !isExpired;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [token, email, role, issuedAt, expiresAt];
|
||||
}
|
||||
18
lib/features/auth/domain/repositories/auth_repository.dart
Normal file
18
lib/features/auth/domain/repositories/auth_repository.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import '../entities/auth_user.dart';
|
||||
|
||||
/// Contrato abstracto del repositorio de autenticación.
|
||||
/// El dominio no conoce la implementación concreta (Clean Architecture).
|
||||
abstract class AuthRepository {
|
||||
/// Autentica al usuario con email/teléfono y contraseña.
|
||||
/// Retorna un [AuthUser] con token JWT simulado en esta fase.
|
||||
Future<AuthUser> login({
|
||||
required String identifier,
|
||||
required String password,
|
||||
});
|
||||
|
||||
/// Cierra la sesión del usuario actual.
|
||||
Future<void> logout();
|
||||
|
||||
/// Verifica si existe una sesión activa guardada localmente.
|
||||
Future<AuthUser?> getStoredSession();
|
||||
}
|
||||
2
lib/features/auth/domain/repositories/desktop.ini
Normal file
2
lib/features/auth/domain/repositories/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[LocalizedFileNames]
|
||||
auth_repository.dart=@auth_repository,0
|
||||
44
lib/features/auth/domain/usecases/auth_usecases.dart
Normal file
44
lib/features/auth/domain/usecases/auth_usecases.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import '../entities/auth_user.dart';
|
||||
import '../repositories/auth_repository.dart';
|
||||
|
||||
/// Caso de uso: Iniciar sesión.
|
||||
/// Encapsula la lógica de negocio para autenticar un usuario.
|
||||
class LoginUseCase {
|
||||
final AuthRepository _repository;
|
||||
|
||||
const LoginUseCase(this._repository);
|
||||
|
||||
Future<AuthUser> execute({
|
||||
required String identifier,
|
||||
required String password,
|
||||
}) async {
|
||||
if (identifier.trim().isEmpty) {
|
||||
throw ArgumentError('El correo o teléfono no puede estar vacío.');
|
||||
}
|
||||
if (password.length < 6) {
|
||||
throw ArgumentError('La contraseña debe tener al menos 6 caracteres.');
|
||||
}
|
||||
return _repository.login(
|
||||
identifier: identifier.trim(),
|
||||
password: password,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Caso de uso: Cerrar sesión.
|
||||
class LogoutUseCase {
|
||||
final AuthRepository _repository;
|
||||
|
||||
const LogoutUseCase(this._repository);
|
||||
|
||||
Future<void> execute() => _repository.logout();
|
||||
}
|
||||
|
||||
/// Caso de uso: Recuperar sesión almacenada.
|
||||
class GetStoredSessionUseCase {
|
||||
final AuthRepository _repository;
|
||||
|
||||
const GetStoredSessionUseCase(this._repository);
|
||||
|
||||
Future<AuthUser?> execute() => _repository.getStoredSession();
|
||||
}
|
||||
2
lib/features/auth/domain/usecases/desktop.ini
Normal file
2
lib/features/auth/domain/usecases/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[LocalizedFileNames]
|
||||
auth_usecases.dart=@auth_usecases,0
|
||||
88
lib/features/auth/presentation/bloc/auth_bloc.dart
Normal file
88
lib/features/auth/presentation/bloc/auth_bloc.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../data/repositories/auth_repository_impl.dart';
|
||||
import '../../domain/usecases/auth_usecases.dart';
|
||||
import 'auth_event.dart';
|
||||
import 'auth_state.dart';
|
||||
|
||||
/// BLoC principal de autenticación.
|
||||
///
|
||||
/// Gestiona el ciclo de vida completo de la identidad del usuario:
|
||||
/// verificación de sesión persistida → login → sesión activa → logout.
|
||||
///
|
||||
/// El token JWT simulado se almacena en el estado [AuthAuthenticated]
|
||||
/// y estará disponible para inyectarse en headers HTTP en fases futuras.
|
||||
class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
final LoginUseCase _loginUseCase;
|
||||
final LogoutUseCase _logoutUseCase;
|
||||
final GetStoredSessionUseCase _getStoredSessionUseCase;
|
||||
|
||||
AuthBloc({
|
||||
required LoginUseCase loginUseCase,
|
||||
required LogoutUseCase logoutUseCase,
|
||||
required GetStoredSessionUseCase getStoredSessionUseCase,
|
||||
}) : _loginUseCase = loginUseCase,
|
||||
_logoutUseCase = logoutUseCase,
|
||||
_getStoredSessionUseCase = getStoredSessionUseCase,
|
||||
super(const AuthInitial()) {
|
||||
on<AuthSessionCheckRequested>(_onSessionCheckRequested);
|
||||
on<AuthLoginRequested>(_onLoginRequested);
|
||||
on<AuthLogoutRequested>(_onLogoutRequested);
|
||||
}
|
||||
|
||||
/// Verifica si hay sesión activa al iniciar la app.
|
||||
Future<void> _onSessionCheckRequested(
|
||||
AuthSessionCheckRequested event,
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
emit(const AuthCheckingSession());
|
||||
try {
|
||||
final user = await _getStoredSessionUseCase.execute();
|
||||
if (user != null) {
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(const AuthUnauthenticated());
|
||||
}
|
||||
} catch (_) {
|
||||
emit(const AuthUnauthenticated());
|
||||
}
|
||||
}
|
||||
|
||||
/// Procesa la solicitud de login con las credenciales del usuario.
|
||||
Future<void> _onLoginRequested(
|
||||
AuthLoginRequested event,
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
emit(const AuthLoading());
|
||||
try {
|
||||
final user = await _loginUseCase.execute(
|
||||
identifier: event.identifier,
|
||||
password: event.password,
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} on AuthException catch (e) {
|
||||
emit(AuthFailure(message: e.message, errorCode: e.code));
|
||||
} on ArgumentError catch (e) {
|
||||
emit(AuthFailure(message: e.message.toString()));
|
||||
} catch (e) {
|
||||
emit(const AuthFailure(
|
||||
message: 'Error inesperado. Por favor intenta de nuevo.',
|
||||
errorCode: 'UNKNOWN',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Cierra la sesión y limpia el estado local.
|
||||
Future<void> _onLogoutRequested(
|
||||
AuthLogoutRequested event,
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
emit(const AuthLoading());
|
||||
try {
|
||||
await _logoutUseCase.execute();
|
||||
} finally {
|
||||
// Siempre transiciona a no autenticado, incluso si falla la limpieza
|
||||
emit(const AuthUnauthenticated());
|
||||
}
|
||||
}
|
||||
}
|
||||
34
lib/features/auth/presentation/bloc/auth_event.dart
Normal file
34
lib/features/auth/presentation/bloc/auth_event.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Eventos que puede recibir el [AuthBloc].
|
||||
/// Cada evento representa una intención del usuario o del sistema.
|
||||
sealed class AuthEvent extends Equatable {
|
||||
const AuthEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// El usuario solicita iniciar sesión con sus credenciales.
|
||||
final class AuthLoginRequested extends AuthEvent {
|
||||
final String identifier;
|
||||
final String password;
|
||||
|
||||
const AuthLoginRequested({
|
||||
required this.identifier,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [identifier, password];
|
||||
}
|
||||
|
||||
/// El usuario solicita cerrar sesión.
|
||||
final class AuthLogoutRequested extends AuthEvent {
|
||||
const AuthLogoutRequested();
|
||||
}
|
||||
|
||||
/// La app verifica si existe una sesión guardada al inicio.
|
||||
final class AuthSessionCheckRequested extends AuthEvent {
|
||||
const AuthSessionCheckRequested();
|
||||
}
|
||||
56
lib/features/auth/presentation/bloc/auth_state.dart
Normal file
56
lib/features/auth/presentation/bloc/auth_state.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import '../../domain/entities/auth_user.dart';
|
||||
|
||||
/// Estados posibles del [AuthBloc].
|
||||
/// Usando sealed class para exhaustividad en switch expressions (Dart 3+).
|
||||
sealed class AuthState extends Equatable {
|
||||
const AuthState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// Estado inicial antes de cualquier verificación.
|
||||
final class AuthInitial extends AuthState {
|
||||
const AuthInitial();
|
||||
}
|
||||
|
||||
/// Verificando si existe sesión almacenada (al inicio de la app).
|
||||
final class AuthCheckingSession extends AuthState {
|
||||
const AuthCheckingSession();
|
||||
}
|
||||
|
||||
/// Proceso de login o logout en curso.
|
||||
final class AuthLoading extends AuthState {
|
||||
const AuthLoading();
|
||||
}
|
||||
|
||||
/// Usuario autenticado exitosamente. Contiene el usuario y su token JWT.
|
||||
final class AuthAuthenticated extends AuthState {
|
||||
final AuthUser user;
|
||||
|
||||
const AuthAuthenticated({required this.user});
|
||||
|
||||
/// Expone el token para su uso en headers HTTP futuros.
|
||||
String get bearerToken => 'Bearer ${user.token}';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [user];
|
||||
}
|
||||
|
||||
/// No autenticado (estado limpio, sin sesión).
|
||||
final class AuthUnauthenticated extends AuthState {
|
||||
const AuthUnauthenticated();
|
||||
}
|
||||
|
||||
/// Error durante la autenticación.
|
||||
final class AuthFailure extends AuthState {
|
||||
final String message;
|
||||
final String? errorCode;
|
||||
|
||||
const AuthFailure({required this.message, this.errorCode});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, errorCode];
|
||||
}
|
||||
@@ -0,0 +1,533 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
import '../bloc/auth_event.dart';
|
||||
import '../bloc/auth_state.dart';
|
||||
|
||||
/// Pantalla principal post-login — MVP WasteNotify.
|
||||
///
|
||||
/// Cascarón de la pantalla de inicio. En fases futuras contendrá:
|
||||
/// - ETA de llegada del camión (sin mapa, solo tiempo estimado)
|
||||
/// - Notificaciones programadas
|
||||
/// - Historial de recolecciones
|
||||
/// - Panel de operador (si role == 'operator')
|
||||
///
|
||||
/// RESTRICCIÓN DE PRIVACIDAD: Esta pantalla NO mostrará mapas de rutas
|
||||
/// ni la posición GPS del vehículo. Solo tiempo estimado de llegada.
|
||||
class HomeScreenPlaceholder extends StatelessWidget {
|
||||
const HomeScreenPlaceholder({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
final user = state is AuthAuthenticated ? state.user : null;
|
||||
final isOperator = user?.role == 'operator';
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.warmWhite,
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.recycling_rounded,
|
||||
color: AppTheme.leafGreen, size: 22),
|
||||
const SizedBox(width: 8),
|
||||
RichText(
|
||||
text: const TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppTheme.charcoal,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: 'Waste'),
|
||||
TextSpan(
|
||||
text: 'Notify',
|
||||
style: TextStyle(color: AppTheme.leafGreen),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout_rounded),
|
||||
tooltip: 'Cerrar sesión',
|
||||
onPressed: () {
|
||||
context.read<AuthBloc>().add(const AuthLogoutRequested());
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
// --- Bienvenida ---
|
||||
_WelcomeCard(user: user),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- ETA Principal (cascarón) ---
|
||||
const _EtaCard(),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- Mensaje preventivo ---
|
||||
const _PreventiveMessageCard(),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- Próximas funcionalidades ---
|
||||
_UpcomingFeatures(isOperator: isOperator),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- Info de sesión (debug MVP) ---
|
||||
if (user != null) _SessionDebugCard(user: user),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sub-widgets de la pantalla home
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class _WelcomeCard extends StatelessWidget {
|
||||
final dynamic user;
|
||||
|
||||
const _WelcomeCard({required this.user});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final roleLabel = user?.role == 'operator' ? 'Operador' : 'Ciudadano';
|
||||
final identifier = user?.email ?? '';
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [AppTheme.leafGreen, AppTheme.forestGreen],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppTheme.leafGreen.withOpacity(0.3),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 52,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(13),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.person_rounded,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'¡Bienvenido!',
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
identifier,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
roleLabel,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EtaCard extends StatelessWidget {
|
||||
const _EtaCard();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightMint,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.schedule_rounded,
|
||||
color: AppTheme.leafGreen,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Tiempo estimado de llegada',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppTheme.charcoal,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 110,
|
||||
height: 110,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: AppTheme.lightMint,
|
||||
width: 6,
|
||||
),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.hourglass_empty_rounded,
|
||||
color: AppTheme.midGray,
|
||||
size: 28,
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
'— min',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppTheme.midGray,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Text(
|
||||
'Notificaciones activas próximamente',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.midGray,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightMint,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: const Text(
|
||||
'Fase 2 — En desarrollo',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: AppTheme.leafGreen,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PreventiveMessageCard extends StatelessWidget {
|
||||
const _PreventiveMessageCard();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.alertAmber.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
color: AppTheme.alertAmber.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Row(
|
||||
children: [
|
||||
Icon(Icons.campaign_outlined,
|
||||
color: AppTheme.alertAmber, size: 18),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'Recuerda siempre',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
color: AppTheme.earthBrown,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_ReminderItem(
|
||||
'🚮',
|
||||
'Saca la basura SOLO cuando recibas la alerta de "próxima llegada".',
|
||||
),
|
||||
_ReminderItem(
|
||||
'🚫',
|
||||
'Nunca persigas ni te acerques al camión. El sistema te avisará a tiempo.',
|
||||
),
|
||||
_ReminderItem(
|
||||
'🌱',
|
||||
'Separar tus residuos hace más eficiente la recolección. ¡Gracias!',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ReminderItem extends StatelessWidget {
|
||||
final String emoji;
|
||||
final String text;
|
||||
|
||||
const _ReminderItem(this.emoji, this.text);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(emoji, style: const TextStyle(fontSize: 14)),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: AppTheme.earthBrown,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _UpcomingFeatures extends StatelessWidget {
|
||||
final bool isOperator;
|
||||
|
||||
const _UpcomingFeatures({required this.isOperator});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final features = [
|
||||
(Icons.notifications_active_outlined, 'Alertas push de recolección',
|
||||
'Fase 2'),
|
||||
(Icons.history_rounded, 'Historial de notificaciones', 'Fase 2'),
|
||||
(Icons.settings_outlined, 'Configurar zona y horario', 'Fase 3'),
|
||||
if (isOperator) ...[
|
||||
(Icons.bar_chart_rounded, 'Panel de rutas completadas', 'Fase 3'),
|
||||
(Icons.group_outlined, 'Gestión de sectores', 'Fase 4'),
|
||||
],
|
||||
];
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Próximamente en WasteNotify',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppTheme.charcoal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
...features.map((f) => _FeatureRow(
|
||||
icon: f.$1,
|
||||
label: f.$2,
|
||||
phase: f.$3,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FeatureRow extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String phase;
|
||||
|
||||
const _FeatureRow({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.phase,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: AppTheme.mintGreen),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 13, color: AppTheme.charcoal),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightGray,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
phase,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppTheme.midGray,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SessionDebugCard extends StatelessWidget {
|
||||
final dynamic user;
|
||||
|
||||
const _SessionDebugCard({required this.user});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final token = user?.token ?? '';
|
||||
final tokenPreview =
|
||||
token.length > 40 ? '${token.substring(0, 40)}…' : token;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF3E5F5),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFFCE93D8), width: 1),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Row(
|
||||
children: [
|
||||
Icon(Icons.developer_mode_rounded,
|
||||
size: 14, color: Color(0xFF7B1FA2)),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'Debug — Sesión JWT (solo MVP)',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF7B1FA2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Token: $tokenPreview',
|
||||
style: const TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontFamily: 'monospace',
|
||||
color: Color(0xFF4A148C),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Role: ${user?.role} | Expira: ${user?.expiresAt?.toLocal().toString().substring(0, 16)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontFamily: 'monospace',
|
||||
color: Color(0xFF4A148C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
263
lib/features/auth/presentation/screens/login_screen.dart
Normal file
263
lib/features/auth/presentation/screens/login_screen.dart
Normal file
@@ -0,0 +1,263 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
import '../bloc/auth_event.dart';
|
||||
import '../bloc/auth_state.dart';
|
||||
import '../widgets/privacy_notice_card.dart';
|
||||
|
||||
/// Pantalla de inicio de sesión — MVP WasteNotify.
|
||||
///
|
||||
/// Diseño: Limpio, institucional, con paleta verde-tierra.
|
||||
/// Incluye mensajería preventiva integrada de forma no intrusiva.
|
||||
///
|
||||
/// Credenciales de demo:
|
||||
/// Ciudadano: ciudadano@ejemplo.com / password123
|
||||
/// Operador: operador@ejemplo.com / operador456
|
||||
/// Teléfono: 5551234567 / pass1234
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _identifierController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
bool _obscurePassword = true;
|
||||
late final AnimationController _animController;
|
||||
late final Animation<double> _fadeAnim;
|
||||
late final Animation<Offset> _slideAnim;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 700),
|
||||
);
|
||||
_fadeAnim = CurvedAnimation(
|
||||
parent: _animController,
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
_slideAnim = Tween<Offset>(
|
||||
begin: const Offset(0, 0.06),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: _animController,
|
||||
curve: Curves.easeOutCubic,
|
||||
));
|
||||
_animController.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animController.dispose();
|
||||
_identifierController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _submit(BuildContext context) {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
context.read<AuthBloc>().add(
|
||||
AuthLoginRequested(
|
||||
identifier: _identifierController.text,
|
||||
password: _passwordController.text,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<AuthBloc, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthFailure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.white, size: 18),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(state.message)),
|
||||
],
|
||||
),
|
||||
backgroundColor: AppTheme.errorRed,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppTheme.warmWhite,
|
||||
body: SafeArea(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: FadeTransition(
|
||||
opacity: _fadeAnim,
|
||||
child: SlideTransition(
|
||||
position: _slideAnim,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 48),
|
||||
_buildHeader(),
|
||||
const SizedBox(height: 32),
|
||||
const ScheduleWarningBanner(),
|
||||
const SizedBox(height: 32),
|
||||
_buildForm(context),
|
||||
const SizedBox(height: 24),
|
||||
const PrivacyNoticeCard(),
|
||||
const SizedBox(height: 32),
|
||||
_buildDemoHint(),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
), const SizedBox(height: 8),
|
||||
Text(
|
||||
'Sistema Municipal de Recolección Residencial\nCelaya, Guanajuato',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: Colors.grey.shade600, height: 1.3),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// --- CAMPO: EMAIL / IDENTIFICADOR ---
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Correo Electrónico o Teléfono',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||
),
|
||||
validator: (value) =>
|
||||
(value == null || value.trim().isEmpty)
|
||||
? 'Por favor, ingresa tus datos de acceso'
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- CAMPO: CONTRASENA ---
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Contraseña de Acceso',
|
||||
prefixIcon: Icon(Icons.lock_outline_rounded),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||
),
|
||||
validator: (value) => (value == null || value.isEmpty)
|
||||
? 'Por favor, introduce tu contraseña'
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// --- CONTENEDOR REACTIVO DE BOTONES (LOGIN & REGISTER) ---
|
||||
// --- CONTENEDOR REACTIVO DE BOTONES (LOGIN & REGISTER) ---
|
||||
BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
final isLoading = state is AuthLoading;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: isLoading
|
||||
? []
|
||||
: [
|
||||
BoxShadow(
|
||||
color: AppTheme.leafGreen
|
||||
.withOpacity(0.3),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ElevatedButton(
|
||||
onPressed:
|
||||
isLoading ? null : () => _submit(context),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: isLoading
|
||||
? AppTheme.mintGreen.withOpacity(0.7)
|
||||
: AppTheme.leafGreen,
|
||||
disabledBackgroundColor:
|
||||
AppTheme.mintGreen.withOpacity(0.6),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 22,
|
||||
width: 22,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5,
|
||||
valueColor: AlwaysStoppedAnimation(
|
||||
Colors.white),
|
||||
),
|
||||
)
|
||||
: const Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.login_rounded,
|
||||
size: 20, color: Colors.white),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
'Ingresar de forma segura',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 📍 ENLACE DE REDIRECCIÓN AL REGISTRO CIUDADANO
|
||||
const SizedBox(height: 20),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// 🚀 Forzamos la navegación limpia usando la ruta de texto directo
|
||||
context.push('/register');
|
||||
},
|
||||
child: const Text(
|
||||
'¿No tienes una cuenta ciudadana? Regístrate aquí',
|
||||
style: TextStyle(
|
||||
color: AppTheme.leafGreen,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
)
|
||||
]);
|
||||
},
|
||||
),
|
||||
], // Fin children de la Column
|
||||
), // Fin Column
|
||||
), // Fin Form
|
||||
), // Fin SingleChildScrollView
|
||||
), // Fin SafeArea
|
||||
), // Fin BlocListener
|
||||
); // Fin Scaffold (Asegúrate de que tenga el punto y coma aquí)
|
||||
|
||||
100
lib/features/auth/presentation/screens/register_screen.dart
Normal file
100
lib/features/auth/presentation/screens/register_screen.dart
Normal file
@@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter_application_1/features/auth/data/models/mock_waste_data.dart';
|
||||
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
String _selectedColonia = 'Centro';
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Crear Cuenta Ciudadana')),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Icon(Icons.assignment_ind_outlined, size: 80, color: Colors.green),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Regístrate para recibir avisos de recolección en tu zona',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(labelText: 'Nombre Completo', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.isEmpty ? 'Ingresa tu nombre' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(labelText: 'Correo o Teléfono', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.isEmpty ? 'Ingresa tus datos' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Contraseña', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.length < 6 ? 'Mínimo 6 caracteres' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Dropdown para seleccionar la Colonia (Requisito MVP)
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedColonia,
|
||||
decoration: const InputDecoration(labelText: 'Selecciona tu Colonia / Domicilio', border: OutlineInputBorder()),
|
||||
items: MockWasteData.schedules.map((zone) {
|
||||
return DropdownMenuItem(value: zone.colonia, child: Text(zone.colonia));
|
||||
}).toList(),
|
||||
onChanged: (val) => setState(() => _selectedColonia = val!),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Mensajería Preventiva Legal
|
||||
Card(
|
||||
color: Colors.amber.shade50,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Text(
|
||||
'🔒 Privacidad Garantizada:\nAl registrar tu domicilio, tu cuenta operará bajo el principio de "Visión de Túnel". Solo verás alertas de tu sector. Está prohibido el rastreo de flotillas.',
|
||||
style: TextStyle(color: Colors.amber.shade900, fontSize: 13, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: Colors.green),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Simulación de Registro Exitoso: Navega al Home enviando la colonia elegida
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Cuenta creada con éxito (Modo Simulación)')),
|
||||
);
|
||||
context.go('/home?colonia=$_selectedColonia');
|
||||
}
|
||||
},
|
||||
child: const Text('Registrarse', style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
138
lib/features/auth/presentation/widgets/privacy_notice_card.dart
Normal file
138
lib/features/auth/presentation/widgets/privacy_notice_card.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
|
||||
/// Widget de aviso de privacidad con mensajería preventiva.
|
||||
///
|
||||
/// Comunica de forma elegante las garantías de privacidad del sistema
|
||||
/// y desincentiva comportamientos peligrosos como perseguir el camión.
|
||||
class PrivacyNoticeCard extends StatelessWidget {
|
||||
const PrivacyNoticeCard({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.lightMint,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppTheme.mintGreen.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.shield_outlined,
|
||||
size: 18,
|
||||
color: AppTheme.leafGreen,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Tu seguridad, nuestra prioridad',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppTheme.forestGreen,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_PrivacyPoint(
|
||||
icon: Icons.location_off_outlined,
|
||||
text:
|
||||
'Nunca mostraremos mapas en tiempo real ni la ubicación exacta del camión.',
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_PrivacyPoint(
|
||||
icon: Icons.directions_run_outlined,
|
||||
text:
|
||||
'No necesitas perseguir al camión — recibirás una alerta con tiempo suficiente.',
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_PrivacyPoint(
|
||||
icon: Icons.lock_outline,
|
||||
text:
|
||||
'Tu sesión usa cifrado JWT. Nunca compartimos tus datos con terceros.',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PrivacyPoint extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String text;
|
||||
|
||||
const _PrivacyPoint({required this.icon, required this.text});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(icon, size: 15, color: AppTheme.mintGreen),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppTheme.forestGreen.withOpacity(0.85),
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Banner de horario preventivo — aparece en la pantalla de login
|
||||
/// para desincentivar sacar basura fuera de horario.
|
||||
class ScheduleWarningBanner extends StatelessWidget {
|
||||
const ScheduleWarningBanner({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.alertAmber.withOpacity(0.10),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: AppTheme.alertAmber.withOpacity(0.35),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.wb_twilight_outlined,
|
||||
size: 16,
|
||||
color: AppTheme.alertAmber,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Saca tu basura solo en el horario indicado. '
|
||||
'Hacerlo antes contamina y genera multas.',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: AppTheme.earthBrown,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user