|
1 | 1 | part of 'archived_headlines_bloc.dart';
|
2 | 2 |
|
3 |
| -sealed class ArchivedHeadlinesState extends Equatable { |
4 |
| - const ArchivedHeadlinesState(); |
5 |
| - |
6 |
| - @override |
7 |
| - List<Object> get props => []; |
| 3 | +/// Represents the status of archived content operations. |
| 4 | +enum ArchivedHeadlinesStatus { |
| 5 | + initial, |
| 6 | + loading, |
| 7 | + success, |
| 8 | + failure, |
8 | 9 | }
|
9 | 10 |
|
10 |
| -final class ArchivedHeadlinesInitial extends ArchivedHeadlinesState {} |
| 11 | +/// The state for the archived content feature. |
| 12 | +class ArchivedHeadlinesState extends Equatable { |
| 13 | + const ArchivedHeadlinesState({ |
| 14 | + this.status = ArchivedHeadlinesStatus.initial, |
| 15 | + this.headlines = const [], |
| 16 | + this.cursor, |
| 17 | + this.hasMore = false, |
| 18 | + this.exception, |
| 19 | + }); |
| 20 | + |
| 21 | + final ArchivedHeadlinesStatus status; |
| 22 | + final List<Headline> headlines; |
| 23 | + final String? cursor; |
| 24 | + final bool hasMore; |
| 25 | + final HttpException? exception; |
| 26 | + |
| 27 | + ArchivedHeadlinesState copyWith({ |
| 28 | + ArchivedHeadlinesStatus? status, |
| 29 | + List<Headline>? headlines, |
| 30 | + String? cursor, |
| 31 | + bool? hasMore, |
| 32 | + HttpException? exception, |
| 33 | + }) { |
| 34 | + return ArchivedHeadlinesState( |
| 35 | + status: status ?? this.status, |
| 36 | + headlines: headlines ?? this.headlines, |
| 37 | + cursor: cursor ?? this.cursor, |
| 38 | + hasMore: hasMore ?? this.hasMore, |
| 39 | + exception: exception ?? this.exception, |
| 40 | + ); |
| 41 | + } |
| 42 | + |
| 43 | + @override |
| 44 | + List<Object?> get props => [ |
| 45 | + status, |
| 46 | + headlines, |
| 47 | + cursor, |
| 48 | + hasMore, |
| 49 | + exception, |
| 50 | + ]; |
| 51 | +} |
0 commit comments