PACKET v1.0.0 - Initial release
App móvil Flutter para capturar contenido multimedia, etiquetarlo con hashes y enviarlo a backends configurables. Features: - Captura de fotos, audio, video y archivos - Sistema de etiquetas con bibliotecas externas (HST) - Packs de etiquetas predefinidos - Cola de reintentos (hasta 20 contenedores) - Soporte GPS - Hash SHA-256 auto-generado por contenedor - Persistencia SQLite local - Múltiples destinos configurables Stack: Flutter 3.38.5, flutter_bloc, sqflite, dio 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
66
lib/presentation/bloc/pendientes/pendientes_cubit.dart
Normal file
66
lib/presentation/bloc/pendientes/pendientes_cubit.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../../data/repositories/contenedor_repository.dart';
|
||||
import '../../../domain/entities/pendiente.dart';
|
||||
import '../../../domain/entities/destino.dart';
|
||||
|
||||
class PendientesState extends Equatable {
|
||||
final List<Pendiente> pendientes;
|
||||
final bool isLoading;
|
||||
final bool queueFull;
|
||||
|
||||
const PendientesState({
|
||||
this.pendientes = const [],
|
||||
this.isLoading = false,
|
||||
this.queueFull = false,
|
||||
});
|
||||
|
||||
PendientesState copyWith({
|
||||
List<Pendiente>? pendientes,
|
||||
bool? isLoading,
|
||||
bool? queueFull,
|
||||
}) =>
|
||||
PendientesState(
|
||||
pendientes: pendientes ?? this.pendientes,
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
queueFull: queueFull ?? this.queueFull,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [pendientes, isLoading, queueFull];
|
||||
}
|
||||
|
||||
class PendientesCubit extends Cubit<PendientesState> {
|
||||
final ContenedorRepository _repo = ContenedorRepository();
|
||||
|
||||
PendientesCubit() : super(const PendientesState());
|
||||
|
||||
Future<void> load() async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final pendientes = await _repo.getPendientes();
|
||||
emit(state.copyWith(
|
||||
pendientes: pendientes,
|
||||
isLoading: false,
|
||||
queueFull: pendientes.length >= 20,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> reintentar(Pendiente pendiente, Destino destino) async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
await _repo.reintentar(pendiente, destino);
|
||||
await load();
|
||||
}
|
||||
|
||||
Future<void> eliminar(String hash) async {
|
||||
await _repo.eliminarPendiente(hash);
|
||||
await load();
|
||||
}
|
||||
|
||||
Future<void> reintentarTodos(Destino destino) async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
for (final p in state.pendientes.where((p) => p.puedeReintentar)) {
|
||||
await _repo.reintentar(p, destino);
|
||||
}
|
||||
await load();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user