Skip to content

Commit 8572ab2

Browse files
committed
refactor(app_configuration): improve notification fields layout
- Add separate TabController for notification subscription tabs - Rearrange notification fields layout to be more user-friendly - Increase height of headline filter form to accommodate new layout - Update tab bar to use scrollable design for better space utilization
1 parent 2514fc9 commit 8572ab2

File tree

1 file changed

+63
-14
lines changed

1 file changed

+63
-14
lines changed

lib/app_configuration/widgets/saved_filter_limits_form.dart

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SavedFilterLimitsForm extends StatefulWidget {
4141
}
4242

4343
class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
44-
with SingleTickerProviderStateMixin {
44+
with TickerProviderStateMixin {
4545
late TabController _tabController;
4646

4747
// A nested map to hold controllers: Role -> Field -> Controller
@@ -54,6 +54,10 @@ class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
5454
length: AppUserRole.values.length,
5555
vsync: this,
5656
);
57+
_notificationTabController = TabController(
58+
length: PushNotificationSubscriptionDeliveryType.values.length,
59+
vsync: this,
60+
);
5761
_initializeControllers();
5862
}
5963

@@ -125,6 +129,7 @@ class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
125129
@override
126130
void dispose() {
127131
_tabController.dispose();
132+
_notificationTabController.dispose();
128133
for (final roleControllers in _controllers.values) {
129134
for (final controller in roleControllers.values) {
130135
controller.dispose();
@@ -215,7 +220,7 @@ class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
215220
),
216221
const SizedBox(height: AppSpacing.lg),
217222
SizedBox(
218-
height: isHeadlineFilter ? 400 : 250,
223+
height: isHeadlineFilter ? 500 : 250,
219224
child: TabBarView(
220225
controller: _tabController,
221226
children: AppUserRole.values.map((role) {
@@ -244,7 +249,7 @@ class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
244249
controller: _controllers[role]!['pinned'],
245250
),
246251
if (isHeadlineFilter)
247-
..._buildNotificationFields(l10n, role, limits),
252+
_buildNotificationFields(l10n, role, limits),
248253
],
249254
),
250255
);
@@ -255,20 +260,64 @@ class _SavedFilterLimitsFormState extends State<SavedFilterLimitsForm>
255260
);
256261
}
257262

258-
List<Widget> _buildNotificationFields(
263+
late final TabController _notificationTabController;
264+
265+
Widget _buildNotificationFields(
259266
AppLocalizations l10n,
260267
AppUserRole role,
261268
SavedFilterLimits limits,
262269
) {
263-
return PushNotificationSubscriptionDeliveryType.values.map((type) {
264-
final value = limits.notificationSubscriptions?[type] ?? 0;
265-
return AppConfigIntField(
266-
label: l10n.notificationSubscriptionLimitLabel,
267-
description: type.l10n(context),
268-
value: value,
269-
onChanged: (newValue) => _onValueChanged(role, type.name, newValue),
270-
controller: _controllers[role]!['notification_${type.name}'],
271-
);
272-
}).toList();
270+
return Column(
271+
crossAxisAlignment: CrossAxisAlignment.start,
272+
children: [
273+
const SizedBox(height: AppSpacing.lg),
274+
Text(
275+
l10n.notificationSubscriptionLimitLabel,
276+
style: Theme.of(context).textTheme.titleMedium,
277+
),
278+
const SizedBox(height: AppSpacing.xs),
279+
Text(
280+
l10n.notificationSubscriptionLimitDescription,
281+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
282+
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
283+
),
284+
),
285+
const SizedBox(height: AppSpacing.md),
286+
Align(
287+
alignment: AlignmentDirectional.centerStart,
288+
child: SizedBox(
289+
height: kTextTabBarHeight,
290+
child: TabBar(
291+
controller: _notificationTabController,
292+
tabAlignment: TabAlignment.start,
293+
isScrollable: true,
294+
tabs: PushNotificationSubscriptionDeliveryType.values
295+
.map((type) => Tab(text: type.l10n(context)))
296+
.toList(),
297+
),
298+
),
299+
),
300+
const SizedBox(height: AppSpacing.lg),
301+
SizedBox(
302+
height: 150,
303+
child: TabBarView(
304+
controller: _notificationTabController,
305+
children: PushNotificationSubscriptionDeliveryType.values.map(
306+
(type) {
307+
final value = limits.notificationSubscriptions?[type] ?? 0;
308+
return AppConfigIntField(
309+
label: '',
310+
description: '',
311+
value: value,
312+
onChanged: (newValue) =>
313+
_onValueChanged(role, type.name, newValue),
314+
controller: _controllers[role]!['notification_${type.name}'],
315+
);
316+
},
317+
).toList(),
318+
),
319+
),
320+
],
321+
);
273322
}
274323
}

0 commit comments

Comments
 (0)