Skip to content

Commit 69f3e30

Browse files
committed
refactor(app_configuration): simplify push notification settings form
- Remove nested ExpansionTile for system status section - Replace with a single SwitchListTile at the top level - Adjust padding and layout for primary provider and delivery types sections - Remove unnecessary containers and adjust alignments
1 parent 7958d2f commit 69f3e30

File tree

1 file changed

+43
-76
lines changed

1 file changed

+43
-76
lines changed

lib/app_configuration/widgets/push_notification_settings_form.dart

Lines changed: 43 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -33,75 +33,38 @@ class PushNotificationSettingsForm extends StatelessWidget {
3333
child: Column(
3434
crossAxisAlignment: CrossAxisAlignment.start,
3535
children: [
36-
ExpansionTile(
37-
initiallyExpanded: true,
38-
title: Text(l10n.pushNotificationSettingsTitle),
39-
childrenPadding: const EdgeInsetsDirectional.only(
40-
start: AppSpacing.lg,
41-
top: AppSpacing.md,
42-
bottom: AppSpacing.md,
43-
),
44-
expandedCrossAxisAlignment: CrossAxisAlignment.start,
45-
children: [
46-
Text(
47-
l10n.pushNotificationSettingsDescription,
48-
style: Theme.of(context).textTheme.bodySmall?.copyWith(
49-
color: Theme.of(
50-
context,
51-
).colorScheme.onSurface.withOpacity(0.7),
36+
SwitchListTile(
37+
title: Text(l10n.pushNotificationSystemStatusTitle),
38+
subtitle: Text(l10n.pushNotificationSystemStatusDescription),
39+
value: pushConfig.enabled,
40+
onChanged: (value) {
41+
onConfigChanged(
42+
remoteConfig.copyWith(
43+
pushNotificationConfig: pushConfig.copyWith(enabled: value),
5244
),
53-
),
54-
const SizedBox(height: AppSpacing.lg),
55-
_buildSystemStatusSection(context, l10n, pushConfig),
56-
const SizedBox(height: AppSpacing.lg),
57-
_buildPrimaryProviderSection(context, l10n, pushConfig),
58-
const SizedBox(height: AppSpacing.lg),
59-
_buildDeliveryTypesSection(context, l10n, pushConfig),
60-
],
45+
);
46+
},
6147
),
48+
const SizedBox(height: AppSpacing.lg),
49+
_buildPrimaryProviderSection(context, l10n, pushConfig),
50+
const SizedBox(height: AppSpacing.lg),
51+
_buildDeliveryTypesSection(context, l10n, pushConfig),
6252
],
6353
),
6454
);
6555
}
6656

67-
Widget _buildSystemStatusSection(
68-
BuildContext context,
69-
AppLocalizations l10n,
70-
PushNotificationConfig pushConfig,
71-
) {
72-
return ExpansionTile(
73-
title: Text(l10n.pushNotificationSystemStatusTitle),
74-
childrenPadding: const EdgeInsets.symmetric(
75-
horizontal: AppSpacing.lg,
76-
vertical: AppSpacing.md,
77-
),
78-
children: [
79-
SwitchListTile(
80-
title: Text(l10n.enabledLabel),
81-
subtitle: Text(l10n.pushNotificationSystemStatusDescription),
82-
value: pushConfig.enabled,
83-
onChanged: (value) {
84-
onConfigChanged(
85-
remoteConfig.copyWith(
86-
pushNotificationConfig: pushConfig.copyWith(enabled: value),
87-
),
88-
);
89-
},
90-
),
91-
],
92-
);
93-
}
94-
9557
Widget _buildPrimaryProviderSection(
9658
BuildContext context,
9759
AppLocalizations l10n,
9860
PushNotificationConfig pushConfig,
9961
) {
10062
return ExpansionTile(
10163
title: Text(l10n.pushNotificationPrimaryProviderTitle),
102-
childrenPadding: const EdgeInsets.symmetric(
103-
horizontal: AppSpacing.lg,
104-
vertical: AppSpacing.md,
64+
childrenPadding: const EdgeInsetsDirectional.only(
65+
start: AppSpacing.lg,
66+
top: AppSpacing.md,
67+
bottom: AppSpacing.md,
10568
),
10669
expandedCrossAxisAlignment: CrossAxisAlignment.start,
10770
children: [
@@ -112,25 +75,28 @@ class PushNotificationSettingsForm extends StatelessWidget {
11275
),
11376
),
11477
const SizedBox(height: AppSpacing.lg),
115-
SegmentedButton<PushNotificationProvider>(
116-
segments: PushNotificationProvider.values
117-
.map(
118-
(provider) => ButtonSegment<PushNotificationProvider>(
119-
value: provider,
120-
label: Text(provider.l10n(context)),
78+
Align(
79+
alignment: AlignmentDirectional.centerStart,
80+
child: SegmentedButton<PushNotificationProvider>(
81+
segments: PushNotificationProvider.values
82+
.map(
83+
(provider) => ButtonSegment<PushNotificationProvider>(
84+
value: provider,
85+
label: Text(provider.l10n(context)),
86+
),
87+
)
88+
.toList(),
89+
selected: {pushConfig.primaryProvider},
90+
onSelectionChanged: (newSelection) {
91+
onConfigChanged(
92+
remoteConfig.copyWith(
93+
pushNotificationConfig: pushConfig.copyWith(
94+
primaryProvider: newSelection.first,
95+
),
12196
),
122-
)
123-
.toList(),
124-
selected: {pushConfig.primaryProvider},
125-
onSelectionChanged: (newSelection) {
126-
onConfigChanged(
127-
remoteConfig.copyWith(
128-
pushNotificationConfig: pushConfig.copyWith(
129-
primaryProvider: newSelection.first,
130-
),
131-
),
132-
);
133-
},
97+
);
98+
},
99+
),
134100
),
135101
],
136102
);
@@ -143,9 +109,10 @@ class PushNotificationSettingsForm extends StatelessWidget {
143109
) {
144110
return ExpansionTile(
145111
title: Text(l10n.pushNotificationDeliveryTypesTitle),
146-
childrenPadding: const EdgeInsets.symmetric(
147-
horizontal: AppSpacing.lg,
148-
vertical: AppSpacing.md,
112+
childrenPadding: const EdgeInsetsDirectional.only(
113+
start: AppSpacing.lg,
114+
top: AppSpacing.md,
115+
bottom: AppSpacing.md,
149116
),
150117
expandedCrossAxisAlignment: CrossAxisAlignment.start,
151118
children: [

0 commit comments

Comments
 (0)