64 lines
1.4 KiB
Dart
64 lines
1.4 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import 'package:finlytic_app/features/news/models/news_article_model.dart';
|
|
|
|
abstract class NewsState extends Equatable {
|
|
const NewsState();
|
|
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
class NewsInitial extends NewsState {}
|
|
|
|
class NewsLoading extends NewsState {}
|
|
|
|
class NewsLoaded extends NewsState {
|
|
final List<NewsArticleModel> articles;
|
|
final bool hasReachedMax;
|
|
final int currentPage;
|
|
|
|
// Filter state preservation
|
|
final String? symbol;
|
|
final String? isin;
|
|
final String? date;
|
|
|
|
const NewsLoaded({
|
|
required this.articles,
|
|
this.hasReachedMax = false,
|
|
this.currentPage = 1,
|
|
this.symbol,
|
|
this.isin,
|
|
this.date,
|
|
});
|
|
|
|
NewsLoaded copyWith({
|
|
List<NewsArticleModel>? articles,
|
|
bool? hasReachedMax,
|
|
int? currentPage,
|
|
String? symbol,
|
|
String? isin,
|
|
String? date,
|
|
}) {
|
|
return NewsLoaded(
|
|
articles: articles ?? this.articles,
|
|
hasReachedMax: hasReachedMax ?? this.hasReachedMax,
|
|
currentPage: currentPage ?? this.currentPage,
|
|
symbol: symbol ?? this.symbol,
|
|
isin: isin ?? this.isin,
|
|
date: date ?? this.date,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [articles, hasReachedMax, currentPage, symbol, isin, date];
|
|
}
|
|
|
|
class NewsError extends NewsState {
|
|
final String message;
|
|
|
|
const NewsError(this.message);
|
|
|
|
@override
|
|
List<Object?> get props => [message];
|
|
}
|