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? 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? 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 get props => [ title, author, genre, annotation, coverUrl, pages, language, publishedYear, rating, status, progress, isFavorite, prefilledData, submittedBook, isSubmitted, isLoading, errorMessage, ]; }