101 lines
3.0 KiB
Dart
101 lines
3.0 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import '../../models/my_postcard_model.dart';
|
|
|
|
abstract class MyPostCardState extends Equatable {
|
|
const MyPostCardState();
|
|
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
/// Initial state
|
|
class MyPostCardInitial extends MyPostCardState {
|
|
const MyPostCardInitial();
|
|
}
|
|
|
|
/// State to check login status
|
|
class MyPostCardCheckingLogin extends MyPostCardState {
|
|
const MyPostCardCheckingLogin();
|
|
}
|
|
|
|
/// State when user is not logged in
|
|
class MyPostCardNotLoggedIn extends MyPostCardState {
|
|
const MyPostCardNotLoggedIn();
|
|
}
|
|
|
|
/// Combined state that holds both drafts and orders
|
|
class MyPostCardLoaded extends MyPostCardState {
|
|
final List<MyPostCard> draftPostCards;
|
|
final List<MyPostCard> orderPostCards;
|
|
final bool isDraftLoading;
|
|
final bool isOrderLoading;
|
|
final bool isDeleteLoading;
|
|
|
|
// Search related properties
|
|
final List<MyPostCard> allDraftPostCards; // Store original unfiltered drafts
|
|
final List<MyPostCard> allOrderPostCards; // Store original unfiltered orders
|
|
final String draftSearchQuery;
|
|
final String orderSearchQuery;
|
|
|
|
const MyPostCardLoaded({
|
|
required this.draftPostCards,
|
|
required this.orderPostCards,
|
|
this.isDraftLoading = false,
|
|
this.isOrderLoading = false,
|
|
this.isDeleteLoading = false,
|
|
List<MyPostCard>? allDraftPostCards,
|
|
List<MyPostCard>? allOrderPostCards,
|
|
this.draftSearchQuery = '',
|
|
this.orderSearchQuery = '',
|
|
}) : allDraftPostCards = allDraftPostCards ?? draftPostCards,
|
|
allOrderPostCards = allOrderPostCards ?? orderPostCards;
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
draftPostCards,
|
|
orderPostCards,
|
|
isDraftLoading,
|
|
isOrderLoading,
|
|
isDeleteLoading,
|
|
allDraftPostCards,
|
|
allOrderPostCards,
|
|
draftSearchQuery,
|
|
orderSearchQuery,
|
|
];
|
|
|
|
/// Helper method to create a copy with updated values
|
|
MyPostCardLoaded copyWith({
|
|
List<MyPostCard>? draftPostCards,
|
|
List<MyPostCard>? orderPostCards,
|
|
bool? isDraftLoading,
|
|
bool? isOrderLoading,
|
|
bool? isDeleteLoading,
|
|
List<MyPostCard>? allDraftPostCards,
|
|
List<MyPostCard>? allOrderPostCards,
|
|
String? draftSearchQuery,
|
|
String? orderSearchQuery,
|
|
}) {
|
|
return MyPostCardLoaded(
|
|
draftPostCards: draftPostCards ?? this.draftPostCards,
|
|
orderPostCards: orderPostCards ?? this.orderPostCards,
|
|
isDraftLoading: isDraftLoading ?? this.isDraftLoading,
|
|
isOrderLoading: isOrderLoading ?? this.isOrderLoading,
|
|
isDeleteLoading: isDeleteLoading ?? this.isDeleteLoading,
|
|
allDraftPostCards: allDraftPostCards ?? this.allDraftPostCards,
|
|
allOrderPostCards: allOrderPostCards ?? this.allOrderPostCards,
|
|
draftSearchQuery: draftSearchQuery ?? this.draftSearchQuery,
|
|
orderSearchQuery: orderSearchQuery ?? this.orderSearchQuery,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Error state
|
|
class MyPostCardError extends MyPostCardState {
|
|
final String errorMessage;
|
|
final String errorType; // 'draft' or 'order'
|
|
|
|
const MyPostCardError({required this.errorMessage, required this.errorType});
|
|
|
|
@override
|
|
List<Object?> get props => [errorMessage, errorType];
|
|
} |