refactor: create separate BLoCs for each screen with comprehensive tests
- Created 8 separate BLoCs (Home, Library, BookDetails, AddBook, Scanner, Categories, Wishlist, Settings) - Each BLoC has its own event, state, and bloc files - Added 70 comprehensive tests covering all BLoC functionality - All tests passing (70/70) - Fixed linting issues and updated deprecated APIs - Improved code organization and maintainability
This commit is contained in:
42
bookshelf_flutter/lib/bloc/scanner/scanner_state.dart
Normal file
42
bookshelf_flutter/lib/bloc/scanner/scanner_state.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ScannerState extends Equatable {
|
||||
final bool isScanning;
|
||||
final bool isProcessing;
|
||||
final Map<String, dynamic>? detectedBookData;
|
||||
final String? errorMessage;
|
||||
|
||||
const ScannerState({
|
||||
this.isScanning = false,
|
||||
this.isProcessing = false,
|
||||
this.detectedBookData,
|
||||
this.errorMessage,
|
||||
});
|
||||
|
||||
factory ScannerState.initial() {
|
||||
return const ScannerState();
|
||||
}
|
||||
|
||||
ScannerState copyWith({
|
||||
bool? isScanning,
|
||||
bool? isProcessing,
|
||||
Map<String, dynamic>? detectedBookData,
|
||||
String? errorMessage,
|
||||
bool clearDetectedBookData = false,
|
||||
}) {
|
||||
return ScannerState(
|
||||
isScanning: isScanning ?? this.isScanning,
|
||||
isProcessing: isProcessing ?? this.isProcessing,
|
||||
detectedBookData: clearDetectedBookData ? null : (detectedBookData ?? this.detectedBookData),
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
isScanning,
|
||||
isProcessing,
|
||||
detectedBookData,
|
||||
errorMessage,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user