Skip to content

Commit 30cb67c

Browse files
committed
feat(app_configuration): improve role-specific settings interface
- Replace ListTile with Column to allow conditional rendering - Move daysBetweenViews input field inside CheckboxListTile - Add description for daysBetweenViews input field - Update layout and spacing for better usability
1 parent 81f0aca commit 30cb67c

File tree

1 file changed

+59
-53
lines changed

1 file changed

+59
-53
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,63 +1065,69 @@ class _FeedDecoratorFormState extends State<_FeedDecoratorForm> {
10651065
title: Text(l10n.roleSpecificSettingsTitle),
10661066
children: AppUserRole.values.map((role) {
10671067
final roleConfig = decoratorConfig.visibleTo[role];
1068-
return CheckboxListTile(
1069-
title: Text(role.name),
1070-
value: roleConfig != null,
1071-
onChanged: (value) {
1072-
final newVisibleTo =
1073-
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1074-
decoratorConfig.visibleTo,
1075-
);
1076-
if (value == true) {
1077-
newVisibleTo[role] =
1078-
const FeedDecoratorRoleConfig(daysBetweenViews: 7);
1079-
} else {
1080-
newVisibleTo.remove(role);
1081-
}
1082-
final newDecoratorConfig =
1083-
decoratorConfig.copyWith(visibleTo: newVisibleTo);
1084-
final newFeedDecoratorConfig =
1085-
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1086-
widget.remoteConfig.feedDecoratorConfig,
1087-
)..[widget.decoratorType] = newDecoratorConfig;
1088-
widget.onConfigChanged(
1089-
widget.remoteConfig.copyWith(
1090-
feedDecoratorConfig: newFeedDecoratorConfig,
1091-
),
1092-
);
1093-
},
1094-
secondary: SizedBox(
1095-
width: 100,
1096-
child: widget.buildIntField(
1097-
context,
1098-
label: l10n.daysBetweenViewsLabel,
1099-
description: '',
1100-
value: roleConfig?.daysBetweenViews ?? 0,
1068+
return Column(
1069+
children: [
1070+
CheckboxListTile(
1071+
title: Text(role.name), // Will be localized later
1072+
value: roleConfig != null,
11011073
onChanged: (value) {
1102-
if (roleConfig != null) {
1103-
final newRoleConfig =
1104-
roleConfig.copyWith(daysBetweenViews: value);
1105-
final newVisibleTo =
1106-
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1107-
decoratorConfig.visibleTo,
1108-
)..[role] = newRoleConfig;
1109-
final newDecoratorConfig =
1110-
decoratorConfig.copyWith(visibleTo: newVisibleTo);
1111-
final newFeedDecoratorConfig =
1112-
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1113-
widget.remoteConfig.feedDecoratorConfig,
1114-
)..[widget.decoratorType] = newDecoratorConfig;
1115-
widget.onConfigChanged(
1116-
widget.remoteConfig.copyWith(
1117-
feedDecoratorConfig: newFeedDecoratorConfig,
1118-
),
1119-
);
1074+
final newVisibleTo =
1075+
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1076+
decoratorConfig.visibleTo,
1077+
);
1078+
if (value == true) {
1079+
newVisibleTo[role] =
1080+
const FeedDecoratorRoleConfig(daysBetweenViews: 7);
1081+
} else {
1082+
newVisibleTo.remove(role);
11201083
}
1084+
final newDecoratorConfig =
1085+
decoratorConfig.copyWith(visibleTo: newVisibleTo);
1086+
final newFeedDecoratorConfig =
1087+
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1088+
widget.remoteConfig.feedDecoratorConfig,
1089+
)..[widget.decoratorType] = newDecoratorConfig;
1090+
widget.onConfigChanged(
1091+
widget.remoteConfig.copyWith(
1092+
feedDecoratorConfig: newFeedDecoratorConfig,
1093+
),
1094+
);
11211095
},
1122-
controller: _roleControllers[role],
11231096
),
1124-
),
1097+
if (roleConfig != null)
1098+
Padding(
1099+
padding: const EdgeInsets.symmetric(
1100+
horizontal: AppSpacing.lg,
1101+
vertical: AppSpacing.sm,
1102+
),
1103+
child: widget.buildIntField(
1104+
context,
1105+
label: l10n.daysBetweenViewsLabel,
1106+
description: l10n.daysBetweenViewsDescription,
1107+
value: roleConfig.daysBetweenViews,
1108+
onChanged: (value) {
1109+
final newRoleConfig =
1110+
roleConfig.copyWith(daysBetweenViews: value);
1111+
final newVisibleTo =
1112+
Map<AppUserRole, FeedDecoratorRoleConfig>.from(
1113+
decoratorConfig.visibleTo,
1114+
)..[role] = newRoleConfig;
1115+
final newDecoratorConfig =
1116+
decoratorConfig.copyWith(visibleTo: newVisibleTo);
1117+
final newFeedDecoratorConfig =
1118+
Map<FeedDecoratorType, FeedDecoratorConfig>.from(
1119+
widget.remoteConfig.feedDecoratorConfig,
1120+
)..[widget.decoratorType] = newDecoratorConfig;
1121+
widget.onConfigChanged(
1122+
widget.remoteConfig.copyWith(
1123+
feedDecoratorConfig: newFeedDecoratorConfig,
1124+
),
1125+
);
1126+
},
1127+
controller: _roleControllers[role],
1128+
),
1129+
),
1130+
],
11251131
);
11261132
}).toList(),
11271133
),

0 commit comments

Comments
 (0)