Compare commits
9 Commits
dev
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8df86daf25 | ||
|
|
7cf5f13d88 | ||
|
|
04d56e18c6 | ||
|
|
fa60bb0dcc | ||
|
|
f24087b134 | ||
|
|
28b7820641 | ||
|
|
bdde457b45 | ||
|
|
df7b74063b | ||
|
|
6012674aa5 |
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(grep -E \"^d|\\\\.dart$|\\\\.py$|pubspec|requirements\")",
|
||||
"Bash(rm -rf basura_app/lib/features/data)",
|
||||
"Bash(rm -rf basura_app/lib/features/domain)",
|
||||
"Bash(rm -rf basura_app/lib/features/presentation)",
|
||||
"Bash(rm -rf basura_app/lib/core)",
|
||||
"Bash(rm -rf lib/src)",
|
||||
"Bash(cp -r basura_app/lib/* lib/)",
|
||||
"Bash(git checkout *)",
|
||||
"Bash(git add *)",
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push *)",
|
||||
"mcp__ide__getDiagnostics",
|
||||
"Read(//mnt/c/Users/Wallt/StudioProjects/**)",
|
||||
"Bash(flutter pub *)",
|
||||
"Bash(flutter analyze *)"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// lib/features/recycling_guide/data/datasources/recycling_local_datasource.dart
|
||||
// Único archivo que sabe que los datos vienen de un JSON en assets.
|
||||
// Funciona sin conexión a internet.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../domain/entities/recycling_category.dart';
|
||||
|
||||
class RecyclingLocalDatasource {
|
||||
static const _assetPath = 'assets/recycling_guide.json';
|
||||
|
||||
// Cache en memoria — se carga una sola vez durante la sesión
|
||||
List<RecyclingCategory>? _cache;
|
||||
|
||||
Future<List<RecyclingCategory>> cargarCategorias() async {
|
||||
if (_cache != null) return _cache!;
|
||||
|
||||
final raw = await rootBundle.loadString(_assetPath);
|
||||
final List<dynamic> json = jsonDecode(raw);
|
||||
|
||||
_cache = json.map(_mapearCategoria).toList();
|
||||
return _cache!;
|
||||
}
|
||||
|
||||
RecyclingCategory _mapearCategoria(dynamic json) {
|
||||
final items = (json['items'] as List)
|
||||
.map(
|
||||
(i) => RecyclingItem(
|
||||
nombre: i['nombre'] as String,
|
||||
ejemplos: i['ejemplos'] as String,
|
||||
acepta: i['acepta'] as bool,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
return RecyclingCategory(
|
||||
id: json['id'] as String,
|
||||
nombre: json['nombre'] as String,
|
||||
descripcion: json['descripcion'] as String,
|
||||
colorHex: json['color'] as String,
|
||||
icono: json['icono'] as String,
|
||||
consejo: json['consejo'] as String,
|
||||
items: items,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// lib/features/recycling_guide/data/repositories/recycling_repository.dart
|
||||
|
||||
import '../datasources/recycling_local_datasource.dart';
|
||||
import '../../domain/entities/recycling_category.dart';
|
||||
|
||||
class RecyclingRepository {
|
||||
final RecyclingLocalDatasource _datasource;
|
||||
|
||||
RecyclingRepository({RecyclingLocalDatasource? datasource})
|
||||
: _datasource = datasource ?? RecyclingLocalDatasource();
|
||||
|
||||
Future<List<RecyclingCategory>> obtenerCategorias() =>
|
||||
_datasource.cargarCategorias();
|
||||
|
||||
/// Busca en nombres y ejemplos de todos los items de todas las categorías.
|
||||
/// Devuelve pares (categoría, item) para que la UI sepa dónde mostrar el resultado.
|
||||
Future<List<SearchResult>> buscar(String query) async {
|
||||
if (query.trim().isEmpty) return [];
|
||||
|
||||
final q = query.toLowerCase();
|
||||
final categorias = await obtenerCategorias();
|
||||
final resultados = <SearchResult>[];
|
||||
|
||||
for (final cat in categorias) {
|
||||
for (final item in cat.items) {
|
||||
final coincide = item.nombre.toLowerCase().contains(q) ||
|
||||
item.ejemplos.toLowerCase().contains(q);
|
||||
if (coincide) {
|
||||
resultados.add(SearchResult(categoria: cat, item: item));
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultados;
|
||||
}
|
||||
}
|
||||
|
||||
class SearchResult {
|
||||
final RecyclingCategory categoria;
|
||||
final RecyclingItem item;
|
||||
|
||||
const SearchResult({required this.categoria, required this.item});
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// lib/features/recycling_guide/domain/entities/recycling_category.dart
|
||||
// Capa de dominio — cero dependencias de Flutter o paquetes externos.
|
||||
|
||||
class RecyclingItem {
|
||||
final String nombre;
|
||||
final String ejemplos;
|
||||
final bool acepta; // true = sí va aquí, false = NO va aquí
|
||||
|
||||
const RecyclingItem({
|
||||
required this.nombre,
|
||||
required this.ejemplos,
|
||||
required this.acepta,
|
||||
});
|
||||
}
|
||||
|
||||
class RecyclingCategory {
|
||||
final String id;
|
||||
final String nombre;
|
||||
final String descripcion;
|
||||
final String colorHex;
|
||||
final String icono;
|
||||
final String consejo;
|
||||
final List<RecyclingItem> items;
|
||||
|
||||
const RecyclingCategory({
|
||||
required this.id,
|
||||
required this.nombre,
|
||||
required this.descripcion,
|
||||
required this.colorHex,
|
||||
required this.icono,
|
||||
required this.consejo,
|
||||
required this.items,
|
||||
});
|
||||
|
||||
/// Items que SÍ van en esta categoría
|
||||
List<RecyclingItem> get itemsAceptados =>
|
||||
items.where((i) => i.acepta).toList();
|
||||
|
||||
/// Items que NO van en esta categoría
|
||||
List<RecyclingItem> get itemsRechazados =>
|
||||
items.where((i) => !i.acepta).toList();
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// lib/features/recycling_guide/presentation/providers/recycling_provider.dart
|
||||
// Riverpod — compatible con lo que usa Persona C en el resto de la app.
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../data/repositories/recycling_repository.dart';
|
||||
import '../../domain/entities/recycling_category.dart';
|
||||
|
||||
// ── Repositorio singleton ────────────────────────────────────────────
|
||||
final recyclingRepositoryProvider = Provider<RecyclingRepository>(
|
||||
(ref) => RecyclingRepository(),
|
||||
);
|
||||
|
||||
// ── Categorías (carga inicial desde JSON) ────────────────────────────
|
||||
final recyclingCategoriesProvider =
|
||||
FutureProvider<List<RecyclingCategory>>((ref) {
|
||||
return ref.watch(recyclingRepositoryProvider).obtenerCategorias();
|
||||
});
|
||||
|
||||
// ── Estado del buscador ──────────────────────────────────────────────
|
||||
class RecyclingSearchNotifier extends StateNotifier<RecyclingSearchState> {
|
||||
final RecyclingRepository _repo;
|
||||
|
||||
RecyclingSearchNotifier(this._repo)
|
||||
: super(const RecyclingSearchState.idle());
|
||||
|
||||
Future<void> buscar(String query) async {
|
||||
if (query.trim().isEmpty) {
|
||||
state = const RecyclingSearchState.idle();
|
||||
return;
|
||||
}
|
||||
state = const RecyclingSearchState.loading();
|
||||
final resultados = await _repo.buscar(query);
|
||||
state = RecyclingSearchState.done(resultados);
|
||||
}
|
||||
|
||||
void limpiar() => state = const RecyclingSearchState.idle();
|
||||
}
|
||||
|
||||
final recyclingSearchProvider =
|
||||
StateNotifierProvider<RecyclingSearchNotifier, RecyclingSearchState>((ref) {
|
||||
return RecyclingSearchNotifier(ref.watch(recyclingRepositoryProvider));
|
||||
});
|
||||
|
||||
// ── Estado sellado del buscador ──────────────────────────────────────
|
||||
sealed class RecyclingSearchState {
|
||||
const RecyclingSearchState();
|
||||
|
||||
const factory RecyclingSearchState.idle() = Idle;
|
||||
const factory RecyclingSearchState.loading() = Loading;
|
||||
const factory RecyclingSearchState.done(List<SearchResult> results) = Done;
|
||||
}
|
||||
|
||||
class Idle extends RecyclingSearchState {
|
||||
const Idle();
|
||||
}
|
||||
|
||||
class Loading extends RecyclingSearchState {
|
||||
const Loading();
|
||||
}
|
||||
|
||||
class Done extends RecyclingSearchState {
|
||||
final List<SearchResult> results;
|
||||
const Done(this.results);
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
// lib/features/recycling_guide/presentation/screens/category_detail_screen.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../domain/entities/recycling_category.dart';
|
||||
|
||||
class CategoryDetailScreen extends StatelessWidget {
|
||||
final RecyclingCategory categoria;
|
||||
|
||||
const CategoryDetailScreen({super.key, required this.categoria});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = _parseColor(categoria.colorHex);
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// ── Header expandible ──────────────────────────────────
|
||||
SliverAppBar(
|
||||
expandedHeight: 180,
|
||||
pinned: true,
|
||||
backgroundColor: color,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: Text(
|
||||
categoria.nombre,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
background: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [color, color.withOpacity(0.7)],
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
_iconoDesdeNombre(categoria.icono),
|
||||
size: 80,
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Descripción
|
||||
Text(
|
||||
categoria.descripcion,
|
||||
style: TextStyle(fontSize: 15, color: Colors.grey[700]),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Consejo destacado
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color.withOpacity(0.3)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.tips_and_updates, color: color, size: 20),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
categoria.consejo,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Sección: SÍ van aquí
|
||||
if (categoria.itemsAceptados.isNotEmpty) ...[
|
||||
_SectionHeader(
|
||||
label: 'Sí van aquí',
|
||||
icon: Icons.check_circle,
|
||||
color: Colors.green,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
...categoria.itemsAceptados.map(
|
||||
(item) => _ItemTile(item: item, acepta: true),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// Sección: NO van aquí
|
||||
if (categoria.itemsRechazados.isNotEmpty) ...[
|
||||
_SectionHeader(
|
||||
label: 'No van aquí',
|
||||
icon: Icons.cancel,
|
||||
color: Colors.red,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
...categoria.itemsRechazados.map(
|
||||
(item) => _ItemTile(item: item, acepta: false),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _parseColor(String hex) {
|
||||
final h = hex.replaceFirst('#', '');
|
||||
return Color(int.parse('FF$h', radix: 16));
|
||||
}
|
||||
|
||||
IconData _iconoDesdeNombre(String nombre) {
|
||||
return switch (nombre) {
|
||||
'eco' => Icons.eco,
|
||||
'recycling' => Icons.recycling,
|
||||
'masks' => Icons.masks,
|
||||
'warning_amber' => Icons.warning_amber,
|
||||
_ => Icons.category,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class _SectionHeader extends StatelessWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
|
||||
const _SectionHeader({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, color: color, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ItemTile extends StatelessWidget {
|
||||
final RecyclingItem item;
|
||||
final bool acepta;
|
||||
|
||||
const _ItemTile({required this.item, required this.acepta});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
acepta ? Icons.check : Icons.close,
|
||||
size: 16,
|
||||
color: acepta ? Colors.green : Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.nombre,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item.ejemplos,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
// lib/features/recycling_guide/presentation/screens/recycling_guide_screen.dart
|
||||
// Pantalla principal — Persona C la agrega al router así:
|
||||
// GoRoute(path: '/guia', builder: (_, __) => const RecyclingGuideScreen())
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../providers/recycling_provider.dart';
|
||||
import '../widgets/category_card.dart';
|
||||
import '../widgets/search_result_tile.dart';
|
||||
import 'category_detail_screen.dart';
|
||||
|
||||
class RecyclingGuideScreen extends ConsumerStatefulWidget {
|
||||
const RecyclingGuideScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<RecyclingGuideScreen> createState() =>
|
||||
_RecyclingGuideScreenState();
|
||||
}
|
||||
|
||||
class _RecyclingGuideScreenState extends ConsumerState<RecyclingGuideScreen> {
|
||||
final _searchCtrl = TextEditingController();
|
||||
bool _buscando = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onSearchChanged(String query) {
|
||||
setState(() => _buscando = query.trim().isNotEmpty);
|
||||
ref.read(recyclingSearchProvider.notifier).buscar(query);
|
||||
}
|
||||
|
||||
void _limpiarBusqueda() {
|
||||
_searchCtrl.clear();
|
||||
setState(() => _buscando = false);
|
||||
ref.read(recyclingSearchProvider.notifier).limpiar();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Guía de separación'),
|
||||
actions: [
|
||||
// Badge offline — refuerza que funciona sin internet
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.offline_bolt, size: 14, color: Colors.white),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'sin internet',
|
||||
style: TextStyle(fontSize: 11, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// ── Buscador ────────────────────────────────────────────
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
||||
child: TextField(
|
||||
controller: _searchCtrl,
|
||||
onChanged: _onSearchChanged,
|
||||
decoration: InputDecoration(
|
||||
hintText: '¿Dónde va el aceite? ¿y la pila?',
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: _buscando
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: _limpiarBusqueda,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ── Contenido dinámico ──────────────────────────────────
|
||||
Expanded(
|
||||
child: _buscando
|
||||
? _SearchResults()
|
||||
: _CategoryList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Lista de categorías ──────────────────────────────────────────────
|
||||
|
||||
class _CategoryList extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final async = ref.watch(recyclingCategoriesProvider);
|
||||
|
||||
return async.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (e, _) => Center(child: Text('Error: $e')),
|
||||
data: (categorias) => ListView.separated(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
||||
itemCount: categorias.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, i) => CategoryCard(
|
||||
categoria: categorias[i],
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
CategoryDetailScreen(categoria: categorias[i]),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Resultados de búsqueda ───────────────────────────────────────────
|
||||
|
||||
class _SearchResults extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final estado = ref.watch(recyclingSearchProvider);
|
||||
|
||||
if (estado is Idle) {
|
||||
return const SizedBox.shrink();
|
||||
} else if (estado is Loading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (estado is Done) {
|
||||
if (estado.results.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.search_off, size: 48, color: Colors.grey[400]),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'No encontramos ese residuo.',
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: estado.results.length,
|
||||
itemBuilder: (_, i) => SearchResultTile(resultado: estado.results[i]),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
// lib/features/recycling_guide/presentation/widgets/category_card.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../domain/entities/recycling_category.dart';
|
||||
|
||||
class CategoryCard extends StatelessWidget {
|
||||
final RecyclingCategory categoria;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const CategoryCard({
|
||||
super.key,
|
||||
required this.categoria,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = _parseColor(categoria.colorHex);
|
||||
|
||||
return Card(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
// Ícono con fondo coloreado
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
_iconoDesdeNombre(categoria.icono),
|
||||
color: color,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Texto
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
categoria.nombre,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
categoria.descripcion,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Chip contador de items
|
||||
Row(
|
||||
children: [
|
||||
_CountChip(
|
||||
count: categoria.itemsAceptados.length,
|
||||
label: 'van aquí',
|
||||
color: Colors.green,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_CountChip(
|
||||
count: categoria.itemsRechazados.length,
|
||||
label: 'no van',
|
||||
color: Colors.red,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, color: Colors.grey[400]),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _parseColor(String hex) {
|
||||
final h = hex.replaceFirst('#', '');
|
||||
return Color(int.parse('FF$h', radix: 16));
|
||||
}
|
||||
|
||||
IconData _iconoDesdeNombre(String nombre) {
|
||||
return switch (nombre) {
|
||||
'eco' => Icons.eco,
|
||||
'recycling' => Icons.recycling,
|
||||
'masks' => Icons.masks,
|
||||
'warning_amber'=> Icons.warning_amber,
|
||||
_ => Icons.category,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class _CountChip extends StatelessWidget {
|
||||
final int count;
|
||||
final String label;
|
||||
final Color color;
|
||||
|
||||
const _CountChip({
|
||||
required this.count,
|
||||
required this.label,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
'$count $label',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// lib/features/recycling_guide/presentation/widgets/search_result_tile.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../data/repositories/recycling_repository.dart';
|
||||
|
||||
class SearchResultTile extends StatelessWidget {
|
||||
final SearchResult resultado;
|
||||
|
||||
const SearchResultTile({super.key, required this.resultado});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = _parseColor(resultado.categoria.colorHex);
|
||||
final acepta = resultado.item.acepta;
|
||||
|
||||
return ListTile(
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
acepta ? Icons.check_circle : Icons.cancel,
|
||||
color: acepta ? Colors.green : Colors.red,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
resultado.item.nombre,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
|
||||
),
|
||||
subtitle: Text(
|
||||
resultado.item.ejemplos,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
trailing: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
resultado.categoria.nombre,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _parseColor(String hex) {
|
||||
final h = hex.replaceFirst('#', '');
|
||||
return Color(int.parse('FF$h', radix: 16));
|
||||
}
|
||||
}
|
||||
114
lib/main.dart
114
lib/main.dart
@@ -1,6 +1,8 @@
|
||||
// main.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'features/recycling_guide/presentation/screens/recycling_guide_screen.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
import 'src/views/rutas.dart';
|
||||
import 'src/views/main_screen.dart';
|
||||
import 'src/views/login.dart'; // Importar LoginView
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@@ -13,9 +15,111 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Basura App',
|
||||
theme: AppTheme.lightTheme,
|
||||
home: const RecyclingGuideScreen(),
|
||||
title: 'Hackaton App',
|
||||
theme: ThemeData(
|
||||
fontFamily: 'Roboto',
|
||||
scaffoldBackgroundColor: colorAzul,
|
||||
),
|
||||
home: const RegistroView(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RegistroView extends StatelessWidget {
|
||||
const RegistroView({super.key});
|
||||
|
||||
final Color colorAzul = const Color(0xFF0F0D38);
|
||||
final Color colorVerde = const Color(0xFF2E4D31);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
backgroundColor: colorAzul,
|
||||
title: const Text('Registro',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 28)),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(30.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
_buildInput(Icons.person_outline, 'Nombre Completo'),
|
||||
_buildInput(Icons.email_outlined, 'Correo'),
|
||||
_buildInput(Icons.lock_outline, 'Contraseña'),
|
||||
const SizedBox(height: 50),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colorAzul,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
||||
),
|
||||
onPressed: () {
|
||||
// Navegar a MainScreen (app principal)
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const MainScreen()),
|
||||
);
|
||||
},
|
||||
child: const Text('Registrar', style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colorAzul,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
|
||||
),
|
||||
onPressed: () {
|
||||
// Navegar a LoginView
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const LoginView()),
|
||||
);
|
||||
},
|
||||
child: const Text('¿Tienes cuenta?', style: TextStyle(color: Colors.white, fontSize: 18)),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInput(IconData icon, String hint) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
child: 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(
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(color: colorVerde.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: colorVerde, width: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
239
lib/src/views/configuracion.dart
Normal file
239
lib/src/views/configuracion.dart
Normal file
@@ -0,0 +1,239 @@
|
||||
// configuracion.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'rutas.dart';
|
||||
|
||||
class ConfiguracionView extends StatefulWidget {
|
||||
const ConfiguracionView({super.key});
|
||||
|
||||
@override
|
||||
State<ConfiguracionView> createState() => _ConfiguracionViewState();
|
||||
}
|
||||
|
||||
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,
|
||||
duration: const Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
}
|
||||
} 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),
|
||||
child: Column(
|
||||
children: [
|
||||
// Selector de notificaciones
|
||||
GestureDetector(
|
||||
onTap: _mostrarSelector,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black, width: 4),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.notifications_active_outlined, size: 60),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
selectedOption,
|
||||
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),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.info_outline, color: colorAzul, size: 30),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Recibirás notificaciones cada ${opcionesMap[selectedOption]}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: colorAzul,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
432
lib/src/views/domicilios.dart
Normal file
432
lib/src/views/domicilios.dart
Normal file
@@ -0,0 +1,432 @@
|
||||
// domicilios.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'rutas.dart';
|
||||
import '../models/domicilio_model.dart';
|
||||
import 'dart:math';
|
||||
|
||||
class DomiciliosView extends StatefulWidget {
|
||||
const DomiciliosView({super.key});
|
||||
|
||||
@override
|
||||
State<DomiciliosView> createState() => _DomiciliosViewState();
|
||||
}
|
||||
|
||||
class _DomiciliosViewState extends State<DomiciliosView> {
|
||||
List<Domicilio> domicilios = [];
|
||||
bool _isLoading = 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,
|
||||
),
|
||||
),
|
||||
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(
|
||||
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(
|
||||
'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),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black, width: 4),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.home_outlined, size: 60),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
domicilio.nombre,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
domicilio.direccionCompleta,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
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,
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
color: colorAzul,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: const Icon(Icons.add, color: Colors.white, size: 80),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
78
lib/src/views/horarios.dart
Normal file
78
lib/src/views/horarios.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'rutas.dart';
|
||||
|
||||
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 ${index + 1}',
|
||||
'ruta': 'Ruta ${index + 1}',
|
||||
'horario': '${8 + (index % 3)}:${30 * (index % 2)} ${index < 3 ? 'AM' : 'PM'}',
|
||||
},
|
||||
);
|
||||
|
||||
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(
|
||||
'Horarios',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
// Lista de horarios
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24),
|
||||
itemCount: rutas.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = rutas[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item['colonia']!,
|
||||
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||
Text(item['ruta']!,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
Text(item['horario']!,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
4
lib/src/views/rutas.dart
Normal file
4
lib/src/views/rutas.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const Color colorAzul = Color(0xFF0F0D38);
|
||||
const Color colorAzulClaro = Color(0xFF2A2A5E);
|
||||
@@ -1,78 +0,0 @@
|
||||
// lib/core/theme/app_theme.dart
|
||||
// Persona C importa este archivo también.
|
||||
// Un solo lugar para colores, tipografía y estilos.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTheme {
|
||||
AppTheme._();
|
||||
|
||||
// ── Paleta de categorías ─────────────────────────────────────────
|
||||
static const organicosColor = Color(0xFF4CAF50);
|
||||
static const reciclabesColor = Color(0xFF2196F3);
|
||||
static const sanitariosColor = Color(0xFFFF5722);
|
||||
static const especialesColor = Color(0xFFFF9800);
|
||||
|
||||
// ── Paleta general ───────────────────────────────────────────────
|
||||
static const primaryColor = Color(0xFF1B5E20); // verde oscuro
|
||||
static const secondaryColor = Color(0xFF2E7D32);
|
||||
static const backgroundColor = Color(0xFFF5F5F5);
|
||||
static const surfaceColor = Color(0xFFFFFFFF);
|
||||
static const errorColor = Color(0xFFD32F2F);
|
||||
|
||||
static ThemeData get lightTheme => ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: primaryColor,
|
||||
surface: surfaceColor,
|
||||
error: errorColor,
|
||||
),
|
||||
scaffoldBackgroundColor: backgroundColor,
|
||||
appBarTheme: const AppBarTheme(
|
||||
backgroundColor: primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
cardTheme: CardThemeData(
|
||||
color: surfaceColor,
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
chipTheme: ChipThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: surfaceColor,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// ── Colores por id de categoría ──────────────────────────────────
|
||||
static Color colorDeCategoriaId(String id) {
|
||||
return switch (id) {
|
||||
'organicos' => organicosColor,
|
||||
'reciclables' => reciclabesColor,
|
||||
'sanitarios' => sanitariosColor,
|
||||
'especiales' => especialesColor,
|
||||
_ => primaryColor,
|
||||
};
|
||||
}
|
||||
}
|
||||
24
pubspec.lock
24
pubspec.lock
@@ -70,14 +70,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
flutter_riverpod:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_riverpod
|
||||
sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -147,14 +139,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
riverpod:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: riverpod
|
||||
sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -176,14 +160,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.12.1"
|
||||
state_notifier:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: state_notifier
|
||||
sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -34,7 +34,6 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter_riverpod: ^2.4.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user