@@ -202,38 +202,78 @@ class _ArticleAdSettingsFormState extends State<ArticleAdSettingsForm>
202202
203203 return Column (
204204 children: [
205- // Checkbox for each InArticleAdSlotType
206- for (final slotType in InArticleAdSlotType .values)
207- CheckboxListTile (
208- title: Text (slotType.l10n (context)),
209- value: (roleSlots != null && roleSlots[slotType] == true ) &&
210- isEnabled,
211- onChanged: isEnabled
212- ? (value) {
213- final newRoleSlots =
214- Map <InArticleAdSlotType , bool >.from (roleSlots ?? {});
215- if (value ?? false ) {
216- newRoleSlots[slotType] = true ;
217- } else {
218- newRoleSlots.remove (slotType);
219- }
205+ SwitchListTile (
206+ // Changed from CheckboxListTile to SwitchListTile for consistency
207+ title: Text (l10n.enableInArticleAdsForRoleLabel (role.l10n (context))),
208+ value: roleSlots != null && isEnabled,
209+ onChanged: isEnabled
210+ ? (value) {
211+ final newVisibleTo =
212+ Map <AppUserRole , Map <InArticleAdSlotType , bool >>.from (
213+ config.visibleTo,
214+ );
215+ if (value) {
216+ // Default values when enabling for a role
217+ newVisibleTo[role] = {
218+ InArticleAdSlotType .aboveArticleContinueReadingButton: true ,
219+ InArticleAdSlotType .belowArticleContinueReadingButton: true ,
220+ };
221+ } else {
222+ newVisibleTo.remove (role);
223+ }
224+
225+ widget.onConfigChanged (
226+ widget.remoteConfig.copyWith (
227+ adConfig: widget.remoteConfig.adConfig.copyWith (
228+ articleAdConfiguration: config.copyWith (
229+ visibleTo: newVisibleTo,
230+ ),
231+ ),
232+ ),
233+ );
234+ }
235+ : null ,
236+ ),
237+ if (roleSlots != null )
238+ Padding (
239+ padding: const EdgeInsets .symmetric (
240+ horizontal: AppSpacing .lg,
241+ vertical: AppSpacing .sm,
242+ ),
243+ child: Column (
244+ children: [
245+ // SwitchListTile for each InArticleAdSlotType
246+ for (final slotType in InArticleAdSlotType .values)
247+ SwitchListTile (
248+ title: Text (slotType.l10n (context)),
249+ value: roleSlots[slotType] == true ,
250+ onChanged: (value) {
251+ final newRoleSlots =
252+ Map <InArticleAdSlotType , bool >.from (roleSlots);
253+ if (value) {
254+ newRoleSlots[slotType] = true ;
255+ } else {
256+ newRoleSlots.remove (slotType);
257+ }
220258
221- final newVisibleTo =
222- Map <AppUserRole , Map <InArticleAdSlotType , bool >>.from (
223- config.visibleTo,
224- )..[role] = newRoleSlots;
259+ final newVisibleTo =
260+ Map <AppUserRole , Map <InArticleAdSlotType , bool >>.from (
261+ config.visibleTo,
262+ )..[role] = newRoleSlots;
225263
226- widget.onConfigChanged (
227- widget.remoteConfig.copyWith (
228- adConfig: widget.remoteConfig.adConfig.copyWith (
229- articleAdConfiguration: config.copyWith (
230- visibleTo: newVisibleTo,
264+ widget.onConfigChanged (
265+ widget.remoteConfig.copyWith (
266+ adConfig: widget.remoteConfig.adConfig.copyWith (
267+ articleAdConfiguration: config.copyWith (
268+ visibleTo: newVisibleTo,
269+ ),
231270 ),
232271 ),
233- ),
234- );
235- }
236- : null ,
272+ );
273+ },
274+ ),
275+ ],
276+ ),
237277 ),
238278 ],
239279 );
0 commit comments