- 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
109 lines
2.6 KiB
Dart
109 lines
2.6 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import '../../models/models.dart';
|
|
|
|
class AddBookState extends Equatable {
|
|
final String title;
|
|
final String author;
|
|
final String genre;
|
|
final String annotation;
|
|
final String coverUrl;
|
|
final int? pages;
|
|
final String language;
|
|
final int? publishedYear;
|
|
final double? rating;
|
|
final BookStatus status;
|
|
final int? progress;
|
|
final bool isFavorite;
|
|
final Map<String, dynamic>? prefilledData;
|
|
final Book? submittedBook;
|
|
final bool isSubmitted;
|
|
final bool isLoading;
|
|
final String? errorMessage;
|
|
|
|
const AddBookState({
|
|
this.title = '',
|
|
this.author = '',
|
|
this.genre = '',
|
|
this.annotation = '',
|
|
this.coverUrl = '',
|
|
this.pages,
|
|
this.language = '',
|
|
this.publishedYear,
|
|
this.rating,
|
|
this.status = BookStatus.wantToRead,
|
|
this.progress,
|
|
this.isFavorite = false,
|
|
this.prefilledData,
|
|
this.submittedBook,
|
|
this.isSubmitted = false,
|
|
this.isLoading = false,
|
|
this.errorMessage,
|
|
});
|
|
|
|
factory AddBookState.initial() {
|
|
return const AddBookState(
|
|
isLoading: false,
|
|
);
|
|
}
|
|
|
|
AddBookState copyWith({
|
|
String? title,
|
|
String? author,
|
|
String? genre,
|
|
String? annotation,
|
|
String? coverUrl,
|
|
int? pages,
|
|
String? language,
|
|
int? publishedYear,
|
|
double? rating,
|
|
BookStatus? status,
|
|
int? progress,
|
|
bool? isFavorite,
|
|
Map<String, dynamic>? prefilledData,
|
|
Book? submittedBook,
|
|
bool? isSubmitted,
|
|
bool? isLoading,
|
|
String? errorMessage,
|
|
}) {
|
|
return AddBookState(
|
|
title: title ?? this.title,
|
|
author: author ?? this.author,
|
|
genre: genre ?? this.genre,
|
|
annotation: annotation ?? this.annotation,
|
|
coverUrl: coverUrl ?? this.coverUrl,
|
|
pages: pages ?? this.pages,
|
|
language: language ?? this.language,
|
|
publishedYear: publishedYear ?? this.publishedYear,
|
|
rating: rating ?? this.rating,
|
|
status: status ?? this.status,
|
|
progress: progress ?? this.progress,
|
|
isFavorite: isFavorite ?? this.isFavorite,
|
|
prefilledData: prefilledData ?? this.prefilledData,
|
|
submittedBook: submittedBook ?? this.submittedBook,
|
|
isSubmitted: isSubmitted ?? this.isSubmitted,
|
|
isLoading: isLoading ?? this.isLoading,
|
|
errorMessage: errorMessage ?? this.errorMessage,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
title,
|
|
author,
|
|
genre,
|
|
annotation,
|
|
coverUrl,
|
|
pages,
|
|
language,
|
|
publishedYear,
|
|
rating,
|
|
status,
|
|
progress,
|
|
isFavorite,
|
|
prefilledData,
|
|
submittedBook,
|
|
isSubmitted,
|
|
isLoading,
|
|
errorMessage,
|
|
];
|
|
} |