Skip to content

Commit 69df48c

Browse files
committed
feat(app_configuration): add general configuration tab
- Implement GeneralConfigurationTab widget for App Configuration page - Add maintenance mode and force update settings sections - Include SwitchListTile and text input for configuration options - Use ExpansionTile for collapsible sections - Implement localization support for all UI elements
1 parent f027d74 commit 69df48c

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import 'package:core/core.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/bloc/app_configuration_bloc.dart';
5+
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/app_config_form_fields.dart';
6+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
7+
import 'package:ui_kit/ui_kit.dart';
8+
9+
/// {@template general_configuration_tab}
10+
/// A widget representing the "General" tab in the App Configuration page.
11+
///
12+
/// This tab allows configuration of maintenance mode and force update settings.
13+
/// {@endtemplate}
14+
class GeneralConfigurationTab extends StatelessWidget {
15+
/// {@macro general_configuration_tab}
16+
const GeneralConfigurationTab({
17+
required this.remoteConfig,
18+
required this.onConfigChanged,
19+
super.key,
20+
});
21+
22+
/// The current [RemoteConfig] object.
23+
final RemoteConfig remoteConfig;
24+
25+
/// Callback to notify parent of changes to the [RemoteConfig].
26+
final ValueChanged<RemoteConfig> onConfigChanged;
27+
28+
@override
29+
Widget build(BuildContext context) {
30+
final l10n = AppLocalizationsX(context).l10n;
31+
32+
return ListView(
33+
padding: const EdgeInsets.all(AppSpacing.lg),
34+
children: [
35+
// Top-level ExpansionTile for Maintenance Section
36+
ExpansionTile(
37+
title: Text(l10n.maintenanceModeTitle),
38+
childrenPadding: const EdgeInsets.symmetric(
39+
horizontal: AppSpacing.xxl,
40+
vertical: AppSpacing.md,
41+
),
42+
children: [
43+
Column(
44+
crossAxisAlignment: CrossAxisAlignment.start,
45+
children: [
46+
Text(
47+
l10n.maintenanceModeDescription,
48+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
49+
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
50+
),
51+
),
52+
const SizedBox(height: AppSpacing.lg),
53+
SwitchListTile(
54+
title: Text(l10n.isUnderMaintenanceLabel),
55+
subtitle: Text(l10n.isUnderMaintenanceDescription),
56+
value: remoteConfig.appStatus.isUnderMaintenance,
57+
onChanged: (value) {
58+
onConfigChanged(
59+
remoteConfig.copyWith(
60+
appStatus: remoteConfig.appStatus.copyWith(
61+
isUnderMaintenance: value,
62+
),
63+
),
64+
);
65+
},
66+
),
67+
],
68+
),
69+
],
70+
),
71+
const SizedBox(height: AppSpacing.lg),
72+
// Top-level ExpansionTile for Force Update Section
73+
ExpansionTile(
74+
title: Text(l10n.forceUpdateTitle),
75+
childrenPadding: const EdgeInsets.symmetric(
76+
horizontal: AppSpacing.xxl,
77+
vertical: AppSpacing.md,
78+
),
79+
children: [
80+
Column(
81+
crossAxisAlignment: CrossAxisAlignment.start,
82+
children: [
83+
Text(
84+
l10n.forceUpdateDescription,
85+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
86+
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
87+
),
88+
),
89+
const SizedBox(height: AppSpacing.lg),
90+
AppConfigTextField(
91+
label: l10n.latestAppVersionLabel,
92+
description: l10n.latestAppVersionDescription,
93+
value: remoteConfig.appStatus.latestAppVersion,
94+
onChanged: (value) {
95+
onConfigChanged(
96+
remoteConfig.copyWith(
97+
appStatus: remoteConfig.appStatus.copyWith(
98+
latestAppVersion: value,
99+
),
100+
),
101+
);
102+
},
103+
),
104+
SwitchListTile(
105+
title: Text(l10n.isLatestVersionOnlyLabel),
106+
subtitle: Text(l10n.isLatestVersionOnlyDescription),
107+
value: remoteConfig.appStatus.isLatestVersionOnly,
108+
onChanged: (value) {
109+
onConfigChanged(
110+
remoteConfig.copyWith(
111+
appStatus: remoteConfig.appStatus.copyWith(
112+
isLatestVersionOnly: value,
113+
),
114+
),
115+
);
116+
},
117+
),
118+
AppConfigTextField(
119+
label: l10n.iosUpdateUrlLabel,
120+
description: l10n.iosUpdateUrlDescription,
121+
value: remoteConfig.appStatus.iosUpdateUrl,
122+
onChanged: (value) {
123+
onConfigChanged(
124+
remoteConfig.copyWith(
125+
appStatus: remoteConfig.appStatus.copyWith(
126+
iosUpdateUrl: value,
127+
),
128+
),
129+
);
130+
},
131+
),
132+
AppConfigTextField(
133+
label: l10n.androidUpdateUrlLabel,
134+
description: l10n.androidUpdateUrlDescription,
135+
value: remoteConfig.appStatus.androidUpdateUrl,
136+
onChanged: (value) {
137+
onConfigChanged(
138+
remoteConfig.copyWith(
139+
appStatus: remoteConfig.appStatus.copyWith(
140+
androidUpdateUrl: value,
141+
),
142+
),
143+
);
144+
},
145+
),
146+
],
147+
),
148+
],
149+
),
150+
],
151+
);
152+
}
153+
}

0 commit comments

Comments
 (0)