64 lines
1.6 KiB
Dart
64 lines
1.6 KiB
Dart
|
|
import 'package:equatable/equatable.dart';
|
||
|
|
import '../../../domain/entities/contenedor.dart';
|
||
|
|
import '../../../domain/entities/archivo_adjunto.dart';
|
||
|
|
import '../../../domain/entities/gps_location.dart';
|
||
|
|
|
||
|
|
enum CapturaStatus { idle, capturing, sending, success, error }
|
||
|
|
|
||
|
|
class CapturaState extends Equatable {
|
||
|
|
final Contenedor contenedor;
|
||
|
|
final CapturaStatus status;
|
||
|
|
final String? errorMessage;
|
||
|
|
final bool isRecording;
|
||
|
|
|
||
|
|
const CapturaState({
|
||
|
|
required this.contenedor,
|
||
|
|
this.status = CapturaStatus.idle,
|
||
|
|
this.errorMessage,
|
||
|
|
this.isRecording = false,
|
||
|
|
});
|
||
|
|
|
||
|
|
CapturaState copyWith({
|
||
|
|
Contenedor? contenedor,
|
||
|
|
CapturaStatus? status,
|
||
|
|
String? errorMessage,
|
||
|
|
bool? isRecording,
|
||
|
|
}) =>
|
||
|
|
CapturaState(
|
||
|
|
contenedor: contenedor ?? this.contenedor,
|
||
|
|
status: status ?? this.status,
|
||
|
|
errorMessage: errorMessage,
|
||
|
|
isRecording: isRecording ?? this.isRecording,
|
||
|
|
);
|
||
|
|
|
||
|
|
CapturaState addArchivo(ArchivoAdjunto archivo) {
|
||
|
|
return copyWith(
|
||
|
|
contenedor: contenedor.copyWith(
|
||
|
|
archivos: [...contenedor.archivos, archivo],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
CapturaState removeArchivo(int index) {
|
||
|
|
final archivos = [...contenedor.archivos]..removeAt(index);
|
||
|
|
return copyWith(
|
||
|
|
contenedor: contenedor.copyWith(archivos: archivos),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
CapturaState setGps(GpsLocation? gps) {
|
||
|
|
return copyWith(
|
||
|
|
contenedor: contenedor.copyWith(gps: gps),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
CapturaState setEtiquetas(List<String> etiquetas) {
|
||
|
|
return copyWith(
|
||
|
|
contenedor: contenedor.copyWith(etiquetas: etiquetas),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
List<Object?> get props => [contenedor, status, errorMessage, isRecording];
|
||
|
|
}
|