|
| 1 | +part of 'archived_content_bloc.dart'; |
| 2 | + |
| 3 | +/// Defines the tabs available in the archived content section. |
| 4 | +enum ArchivedContentTab { |
| 5 | + /// Represents the Headlines tab. |
| 6 | + headlines, |
| 7 | + |
| 8 | + /// Represents the Topics tab. |
| 9 | + topics, |
| 10 | + |
| 11 | + /// Represents the Sources tab. |
| 12 | + sources, |
| 13 | +} |
| 14 | + |
| 15 | +/// Represents the status of archived content operations. |
| 16 | +enum ArchivedContentStatus { |
| 17 | + initial, |
| 18 | + loading, |
| 19 | + success, |
| 20 | + failure, |
| 21 | +} |
| 22 | + |
| 23 | +/// The state for the archived content feature. |
| 24 | +class ArchivedContentState extends Equatable { |
| 25 | + const ArchivedContentState({ |
| 26 | + this.activeTab = ArchivedContentTab.headlines, |
| 27 | + this.headlinesStatus = ArchivedContentStatus.initial, |
| 28 | + this.headlines = const [], |
| 29 | + this.headlinesCursor, |
| 30 | + this.headlinesHasMore = false, |
| 31 | + this.topicsStatus = ArchivedContentStatus.initial, |
| 32 | + this.topics = const [], |
| 33 | + this.topicsCursor, |
| 34 | + this.topicsHasMore = false, |
| 35 | + this.sourcesStatus = ArchivedContentStatus.initial, |
| 36 | + this.sources = const [], |
| 37 | + this.sourcesCursor, |
| 38 | + this.sourcesHasMore = false, |
| 39 | + this.exception, |
| 40 | + }); |
| 41 | + |
| 42 | + final ArchivedContentTab activeTab; |
| 43 | + final ArchivedContentStatus headlinesStatus; |
| 44 | + final List<Headline> headlines; |
| 45 | + final String? headlinesCursor; |
| 46 | + final bool headlinesHasMore; |
| 47 | + final ArchivedContentStatus topicsStatus; |
| 48 | + final List<Topic> topics; |
| 49 | + final String? topicsCursor; |
| 50 | + final bool topicsHasMore; |
| 51 | + final ArchivedContentStatus sourcesStatus; |
| 52 | + final List<Source> sources; |
| 53 | + final String? sourcesCursor; |
| 54 | + final bool sourcesHasMore; |
| 55 | + final HttpException? exception; |
| 56 | + |
| 57 | + ArchivedContentState copyWith({ |
| 58 | + ArchivedContentTab? activeTab, |
| 59 | + ArchivedContentStatus? headlinesStatus, |
| 60 | + List<Headline>? headlines, |
| 61 | + String? headlinesCursor, |
| 62 | + bool? headlinesHasMore, |
| 63 | + ArchivedContentStatus? topicsStatus, |
| 64 | + List<Topic>? topics, |
| 65 | + String? topicsCursor, |
| 66 | + bool? topicsHasMore, |
| 67 | + ArchivedContentStatus? sourcesStatus, |
| 68 | + List<Source>? sources, |
| 69 | + String? sourcesCursor, |
| 70 | + bool? sourcesHasMore, |
| 71 | + HttpException? exception, |
| 72 | + }) { |
| 73 | + return ArchivedContentState( |
| 74 | + activeTab: activeTab ?? this.activeTab, |
| 75 | + headlinesStatus: headlinesStatus ?? this.headlinesStatus, |
| 76 | + headlines: headlines ?? this.headlines, |
| 77 | + headlinesCursor: headlinesCursor ?? this.headlinesCursor, |
| 78 | + headlinesHasMore: headlinesHasMore ?? this.headlinesHasMore, |
| 79 | + topicsStatus: topicsStatus ?? this.topicsStatus, |
| 80 | + topics: topics ?? this.topics, |
| 81 | + topicsCursor: topicsCursor ?? this.topicsCursor, |
| 82 | + topicsHasMore: topicsHasMore ?? this.topicsHasMore, |
| 83 | + sourcesStatus: sourcesStatus ?? this.sourcesStatus, |
| 84 | + sources: sources ?? this.sources, |
| 85 | + sourcesCursor: sourcesCursor ?? this.sourcesCursor, |
| 86 | + sourcesHasMore: sourcesHasMore ?? this.sourcesHasMore, |
| 87 | + exception: exception ?? this.exception, |
| 88 | + ); |
| 89 | + } |
| 90 | + |
| 91 | + @override |
| 92 | + List<Object?> get props => [ |
| 93 | + activeTab, |
| 94 | + headlinesStatus, |
| 95 | + headlines, |
| 96 | + headlinesCursor, |
| 97 | + headlinesHasMore, |
| 98 | + topicsStatus, |
| 99 | + topics, |
| 100 | + topicsCursor, |
| 101 | + topicsHasMore, |
| 102 | + sourcesStatus, |
| 103 | + sources, |
| 104 | + sourcesCursor, |
| 105 | + sourcesHasMore, |
| 106 | + exception, |
| 107 | + ]; |
| 108 | +} |
0 commit comments