Skip to content

Commit bccd8f3

Browse files
committed
feat(entity_details): enhance feed decoration with image style and theme
- Inject ads with headline image style and theme for entity details - Use default theme for pagination if not provided - Make feed decoration process asynchronous
1 parent f78e97c commit bccd8f3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/entity_details/bloc/entity_details_bloc.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:bloc/bloc.dart';
66
import 'package:core/core.dart';
77
import 'package:data_repository/data_repository.dart';
88
import 'package:equatable/equatable.dart';
9+
import 'package:flutter/material.dart';
910
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
1011
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
1112
import 'package:flutter_news_app_mobile_client_full_source_code/shared/services/feed_decorator_service.dart';
@@ -108,10 +109,12 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
108109
}
109110

110111
// For entity details, only inject ads.
111-
final processedFeedItems = _feedDecoratorService.injectAds(
112+
final processedFeedItems = await _feedDecoratorService.injectAds(
112113
feedItems: headlineResponse.items,
113114
user: currentUser,
114115
adConfig: remoteConfig.adConfig,
116+
imageStyle: _appBloc.state.settings.feedPreferences.headlineImageStyle,
117+
theme: event.theme,
115118
);
116119

117120
// 3. Determine isFollowing status
@@ -208,10 +211,14 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
208211
}
209212

210213
// For entity details pagination, only inject ads.
211-
final newProcessedFeedItems = _feedDecoratorService.injectAds(
214+
final newProcessedFeedItems = await _feedDecoratorService.injectAds(
212215
feedItems: headlineResponse.items,
213216
user: currentUser,
214217
adConfig: remoteConfig.adConfig,
218+
imageStyle: _appBloc.state.settings.feedPreferences.headlineImageStyle,
219+
theme: _appBloc.state.themeMode == ThemeMode.dark
220+
? ThemeData.dark()
221+
: ThemeData.light(), // Use a default theme for pagination if not passed
215222
// Calculate the count of actual content items (headlines) already in the
216223
// feed. This is crucial for the FeedDecoratorService to correctly apply
217224
// ad placement rules across paginated loads.

0 commit comments

Comments
 (0)