Skip to content

Commit baaac16

Browse files
committed
refactor(app_configuration): update article ad settings form
- Replace AdType with BannerAdShape for in-article ad type selection - Update localization keys to reflect new banner ad shape selection - Remove unnecessary comments and adjust padding for better readability - Simplify segmented button configuration for banner ad shape
1 parent 53f0231 commit baaac16

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

lib/app_configuration/widgets/article_ad_settings_form.dart

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
4-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/ad_type_l10n.dart';
4+
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/banner_ad_shape_l10n.dart';
55
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/in_article_ad_slot_type_l10n.dart';
66
import 'package:ui_kit/ui_kit.dart';
77

@@ -64,51 +64,47 @@ class _ArticleAdSettingsFormState extends State<ArticleAdSettingsForm>
6464
),
6565
const SizedBox(height: AppSpacing.lg),
6666
ExpansionTile(
67-
title: Text(l10n.defaultInArticleAdTypeSelectionTitle),
67+
title: Text(l10n.bannerAdShapeSelectionTitle),
6868
childrenPadding: const EdgeInsetsDirectional.only(
69-
start: AppSpacing.lg, // Adjusted padding for hierarchy
69+
start: AppSpacing.lg,
7070
top: AppSpacing.md,
7171
bottom: AppSpacing.md,
7272
),
73-
expandedCrossAxisAlignment:
74-
CrossAxisAlignment.start, // Align content to start
73+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
7574
children: [
7675
Text(
77-
l10n.defaultInArticleAdTypeSelectionDescription,
76+
l10n.bannerAdShapeSelectionDescription,
7877
style: Theme.of(context).textTheme.bodySmall?.copyWith(
7978
color: Theme.of(
8079
context,
8180
).colorScheme.onSurface.withOpacity(0.7),
8281
),
83-
textAlign: TextAlign.start, // Ensure text aligns to start
82+
textAlign: TextAlign.start,
8483
),
8584
const SizedBox(height: AppSpacing.lg),
8685
Align(
8786
alignment: AlignmentDirectional.centerStart,
88-
child: SegmentedButton<AdType>(
87+
child: SegmentedButton<BannerAdShape>(
8988
style: SegmentedButton.styleFrom(
9089
shape: const RoundedRectangleBorder(
9190
borderRadius: BorderRadius.zero,
9291
),
9392
),
94-
segments: AdType.values
95-
.where(
96-
(type) => type == AdType.native || type == AdType.banner,
97-
)
93+
segments: BannerAdShape.values
9894
.map(
99-
(type) => ButtonSegment<AdType>(
95+
(type) => ButtonSegment<BannerAdShape>(
10096
value: type,
10197
label: Text(type.l10n(context)),
10298
),
10399
)
104100
.toList(),
105-
selected: {articleAdConfig.defaultInArticleAdType},
101+
selected: {articleAdConfig.bannerAdShape},
106102
onSelectionChanged: (newSelection) {
107103
widget.onConfigChanged(
108104
widget.remoteConfig.copyWith(
109105
adConfig: adConfig.copyWith(
110106
articleAdConfiguration: articleAdConfig.copyWith(
111-
defaultInArticleAdType: newSelection.first,
107+
bannerAdShape: newSelection.first,
112108
),
113109
),
114110
),
@@ -122,12 +118,11 @@ class _ArticleAdSettingsFormState extends State<ArticleAdSettingsForm>
122118
ExpansionTile(
123119
title: Text(l10n.inArticleAdSlotPlacementsTitle),
124120
childrenPadding: const EdgeInsetsDirectional.only(
125-
start: AppSpacing.lg, // Adjusted padding for hierarchy
121+
start: AppSpacing.lg,
126122
top: AppSpacing.md,
127123
bottom: AppSpacing.md,
128124
),
129-
expandedCrossAxisAlignment:
130-
CrossAxisAlignment.start, // Align content to start
125+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
131126
children: [
132127
Text(
133128
l10n.inArticleAdSlotPlacementsDescription,
@@ -136,7 +131,7 @@ class _ArticleAdSettingsFormState extends State<ArticleAdSettingsForm>
136131
context,
137132
).colorScheme.onSurface.withOpacity(0.7),
138133
),
139-
textAlign: TextAlign.start, // Ensure text aligns to start
134+
textAlign: TextAlign.start,
140135
),
141136
const SizedBox(height: AppSpacing.lg),
142137
...articleAdConfig.inArticleAdSlotConfigurations.map(

0 commit comments

Comments
 (0)