Skip to content

Commit 9fc0361

Browse files
committed
refactor(app_configuration): conditionally show app review settings
- Wrap app review settings in a Padding widget - Display app review settings only if appReviewConfig.enabled is true - Adjust layout structure to improve readability and maintainability
1 parent 9311cf9 commit 9fc0361

File tree

1 file changed

+102
-94
lines changed

1 file changed

+102
-94
lines changed

lib/app_configuration/widgets/app_review_settings_form.dart

Lines changed: 102 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -98,107 +98,115 @@ class _AppReviewSettingsFormState extends State<AppReviewSettingsForm> {
9898
},
9999
),
100100
const SizedBox(height: AppSpacing.lg),
101-
ExpansionTile(
102-
title: Text(l10n.internalPromptLogicTitle),
103-
childrenPadding: const EdgeInsetsDirectional.only(
104-
start: AppSpacing.lg,
105-
top: AppSpacing.md,
106-
bottom: AppSpacing.md,
107-
),
108-
expandedCrossAxisAlignment: CrossAxisAlignment.start,
109-
children: [
110-
AppConfigIntField(
111-
label: l10n.positiveInteractionThresholdLabel,
112-
description: l10n.positiveInteractionThresholdDescription,
113-
value: appReviewConfig.positiveInteractionThreshold,
114-
onChanged: (value) {
115-
final newConfig = communityConfig.copyWith(
116-
appReview: appReviewConfig.copyWith(
117-
positiveInteractionThreshold: value,
101+
if (appReviewConfig.enabled)
102+
Padding(
103+
padding: const EdgeInsetsDirectional.only(start: AppSpacing.lg),
104+
child: Column(
105+
children: [
106+
ExpansionTile(
107+
title: Text(l10n.internalPromptLogicTitle),
108+
childrenPadding: const EdgeInsetsDirectional.only(
109+
start: AppSpacing.lg,
110+
top: AppSpacing.md,
111+
bottom: AppSpacing.md,
118112
),
119-
);
120-
widget.onConfigChanged(
121-
widget.remoteConfig.copyWith(
122-
features: widget.remoteConfig.features.copyWith(
123-
community: newConfig,
113+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
114+
children: [
115+
AppConfigIntField(
116+
label: l10n.positiveInteractionThresholdLabel,
117+
description: l10n.positiveInteractionThresholdDescription,
118+
value: appReviewConfig.positiveInteractionThreshold,
119+
onChanged: (value) {
120+
final newConfig = communityConfig.copyWith(
121+
appReview: appReviewConfig.copyWith(
122+
positiveInteractionThreshold: value,
123+
),
124+
);
125+
widget.onConfigChanged(
126+
widget.remoteConfig.copyWith(
127+
features: widget.remoteConfig.features.copyWith(
128+
community: newConfig,
129+
),
130+
),
131+
);
132+
},
133+
controller: _positiveInteractionThresholdController,
124134
),
125-
),
126-
);
127-
},
128-
controller: _positiveInteractionThresholdController,
129-
),
130-
AppConfigIntField(
131-
label: l10n.initialPromptCooldownLabel,
132-
description: l10n.initialPromptCooldownDescription,
133-
value: appReviewConfig.initialPromptCooldownDays,
134-
onChanged: (value) {
135-
final newConfig = communityConfig.copyWith(
136-
appReview: appReviewConfig.copyWith(
137-
initialPromptCooldownDays: value,
138-
),
139-
);
140-
widget.onConfigChanged(
141-
widget.remoteConfig.copyWith(
142-
features: widget.remoteConfig.features.copyWith(
143-
community: newConfig,
135+
AppConfigIntField(
136+
label: l10n.initialPromptCooldownLabel,
137+
description: l10n.initialPromptCooldownDescription,
138+
value: appReviewConfig.initialPromptCooldownDays,
139+
onChanged: (value) {
140+
final newConfig = communityConfig.copyWith(
141+
appReview: appReviewConfig.copyWith(
142+
initialPromptCooldownDays: value,
143+
),
144+
);
145+
widget.onConfigChanged(
146+
widget.remoteConfig.copyWith(
147+
features: widget.remoteConfig.features.copyWith(
148+
community: newConfig,
149+
),
150+
),
151+
);
152+
},
153+
controller: _initialPromptCooldownController,
144154
),
155+
],
156+
),
157+
const SizedBox(height: AppSpacing.lg),
158+
ExpansionTile(
159+
title: Text(l10n.followUpActionsTitle),
160+
childrenPadding: const EdgeInsetsDirectional.only(
161+
start: AppSpacing.lg,
162+
top: AppSpacing.md,
163+
bottom: AppSpacing.md,
145164
),
146-
);
147-
},
148-
controller: _initialPromptCooldownController,
149-
),
150-
],
151-
),
152-
const SizedBox(height: AppSpacing.lg),
153-
ExpansionTile(
154-
title: Text(l10n.followUpActionsTitle),
155-
childrenPadding: const EdgeInsetsDirectional.only(
156-
start: AppSpacing.lg,
157-
top: AppSpacing.md,
158-
bottom: AppSpacing.md,
159-
),
160-
expandedCrossAxisAlignment: CrossAxisAlignment.start,
161-
children: [
162-
SwitchListTile(
163-
title: Text(l10n.requestStoreReviewLabel),
164-
subtitle: Text(l10n.requestStoreReviewDescription),
165-
value: appReviewConfig.isPositiveFeedbackFollowUpEnabled,
166-
onChanged: (value) {
167-
final newAppReviewConfig = appReviewConfig.copyWith(
168-
isPositiveFeedbackFollowUpEnabled: value,
169-
);
170-
widget.onConfigChanged(
171-
widget.remoteConfig.copyWith(
172-
features: widget.remoteConfig.features.copyWith(
173-
community: communityConfig.copyWith(
174-
appReview: newAppReviewConfig,
175-
),
165+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
166+
children: [
167+
SwitchListTile(
168+
title: Text(l10n.requestStoreReviewLabel),
169+
subtitle: Text(l10n.requestStoreReviewDescription),
170+
value: appReviewConfig.isPositiveFeedbackFollowUpEnabled,
171+
onChanged: (value) {
172+
final newAppReviewConfig = appReviewConfig.copyWith(
173+
isPositiveFeedbackFollowUpEnabled: value,
174+
);
175+
widget.onConfigChanged(
176+
widget.remoteConfig.copyWith(
177+
features: widget.remoteConfig.features.copyWith(
178+
community: communityConfig.copyWith(
179+
appReview: newAppReviewConfig,
180+
),
181+
),
182+
),
183+
);
184+
},
176185
),
177-
),
178-
);
179-
},
180-
),
181-
SwitchListTile(
182-
title: Text(l10n.requestWrittenFeedbackLabel),
183-
subtitle: Text(l10n.requestWrittenFeedbackDescription),
184-
value: appReviewConfig.isNegativeFeedbackFollowUpEnabled,
185-
onChanged: (value) {
186-
final newAppReviewConfig = appReviewConfig.copyWith(
187-
isNegativeFeedbackFollowUpEnabled: value,
188-
);
189-
widget.onConfigChanged(
190-
widget.remoteConfig.copyWith(
191-
features: widget.remoteConfig.features.copyWith(
192-
community: communityConfig.copyWith(
193-
appReview: newAppReviewConfig,
194-
),
186+
SwitchListTile(
187+
title: Text(l10n.requestWrittenFeedbackLabel),
188+
subtitle: Text(l10n.requestWrittenFeedbackDescription),
189+
value: appReviewConfig.isNegativeFeedbackFollowUpEnabled,
190+
onChanged: (value) {
191+
final newAppReviewConfig = appReviewConfig.copyWith(
192+
isNegativeFeedbackFollowUpEnabled: value,
193+
);
194+
widget.onConfigChanged(
195+
widget.remoteConfig.copyWith(
196+
features: widget.remoteConfig.features.copyWith(
197+
community: communityConfig.copyWith(
198+
appReview: newAppReviewConfig,
199+
),
200+
),
201+
),
202+
);
203+
},
195204
),
196-
),
197-
);
198-
},
205+
],
206+
),
207+
],
199208
),
200-
],
201-
),
209+
),
202210
],
203211
);
204212
}

0 commit comments

Comments
 (0)