Skip to content

Commit 6da0a5a

Browse files
authored
Merge pull request #133 from flutter-news-app-full-source-code/fix/sync-with-remote-config-structure
Fix/sync with remote config structure
2 parents 615e5ba + 6a97efb commit 6da0a5a

22 files changed

+1118
-572
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/bloc/app_configuration_bloc.dart';
4-
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/app_configuration_tab.dart';
54
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/features_configuration_tab.dart';
5+
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/system_configuration_tab.dart';
66
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/user_configuration_tab.dart';
77
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
88
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/widgets/about_icon.dart';
@@ -65,7 +65,7 @@ class _AppConfigurationPageState extends State<AppConfigurationPage>
6565
tabAlignment: TabAlignment.start,
6666
isScrollable: true,
6767
tabs: [
68-
Tab(text: l10n.appTab),
68+
Tab(text: l10n.systemTab),
6969
Tab(text: l10n.featuresTab),
7070
Tab(text: l10n.userTab),
7171
],
@@ -132,7 +132,7 @@ class _AppConfigurationPageState extends State<AppConfigurationPage>
132132
return TabBarView(
133133
controller: _tabController,
134134
children: [
135-
AppConfigurationTab(
135+
SystemConfigurationTab(
136136
remoteConfig: remoteConfig,
137137
onConfigChanged: (newConfig) {
138138
context.read<AppConfigurationBloc>().add(

lib/app_configuration/view/tabs/app_configuration_tab.dart

Lines changed: 0 additions & 119 deletions
This file was deleted.

lib/app_configuration/view/tabs/features_configuration_tab.dart

Lines changed: 108 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuratio
88
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/push_notification_settings_form.dart';
99
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
1010
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/feed_decorator_type_l10n.dart';
11+
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/feed_item_click_behavior_l10n.dart';
1112
import 'package:ui_kit/ui_kit.dart';
1213

1314
/// {@template features_configuration_tab}
@@ -66,6 +67,12 @@ class _FeaturesConfigurationTabState extends State<FeaturesConfigurationTab> {
6667
_expandedTileIndex.value = isExpanded ? tileIndex : null;
6768
},
6869
initiallyExpanded: expandedIndex == tileIndex,
70+
childrenPadding: const EdgeInsetsDirectional.only(
71+
start: AppSpacing.lg,
72+
top: AppSpacing.md,
73+
bottom: AppSpacing.md,
74+
),
75+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
6976
children: [
7077
AdConfigForm(
7178
remoteConfig: widget.remoteConfig,
@@ -104,6 +111,12 @@ class _FeaturesConfigurationTabState extends State<FeaturesConfigurationTab> {
104111
_expandedTileIndex.value = isExpanded ? tileIndex : null;
105112
},
106113
initiallyExpanded: expandedIndex == tileIndex,
114+
childrenPadding: const EdgeInsetsDirectional.only(
115+
start: AppSpacing.lg,
116+
top: AppSpacing.md,
117+
bottom: AppSpacing.md,
118+
),
119+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
107120
children: [
108121
PushNotificationSettingsForm(
109122
remoteConfig: widget.remoteConfig,
@@ -115,54 +128,118 @@ class _FeaturesConfigurationTabState extends State<FeaturesConfigurationTab> {
115128
),
116129
const SizedBox(height: AppSpacing.lg),
117130

118-
// Feed Decorators
131+
// Feed
119132
ValueListenableBuilder<int?>(
120133
valueListenable: _expandedTileIndex,
121134
builder: (context, expandedIndex, child) {
122135
const tileIndex = 2;
123136
return ExpansionTile(
124-
key: ValueKey('feedDecoratorsTile_$expandedIndex'),
125-
title: Text(l10n.feedDecoratorsTitle),
137+
key: ValueKey('feedTile_$expandedIndex'),
138+
title: Text(l10n.feedTab),
139+
onExpansionChanged: (isExpanded) {
140+
_expandedTileIndex.value = isExpanded ? tileIndex : null;
141+
},
142+
initiallyExpanded: expandedIndex == tileIndex,
126143
childrenPadding: const EdgeInsetsDirectional.only(
127144
start: AppSpacing.lg,
128145
top: AppSpacing.md,
129146
bottom: AppSpacing.md,
130147
),
131148
expandedCrossAxisAlignment: CrossAxisAlignment.start,
132-
onExpansionChanged: (isExpanded) {
133-
_expandedTileIndex.value = isExpanded ? tileIndex : null;
134-
},
135-
initiallyExpanded: expandedIndex == tileIndex,
136149
children: [
137-
Text(
138-
l10n.feedDecoratorsDescription,
139-
style: Theme.of(context).textTheme.bodySmall?.copyWith(
140-
color: Theme.of(
141-
context,
142-
).colorScheme.onSurface.withOpacity(0.7),
150+
ExpansionTile(
151+
title: Text(l10n.feedItemClickBehaviorTitle),
152+
childrenPadding: const EdgeInsetsDirectional.only(
153+
start: AppSpacing.lg,
154+
top: AppSpacing.md,
155+
bottom: AppSpacing.md,
143156
),
157+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
158+
children: [
159+
Text(
160+
l10n.feedItemClickBehaviorDescription,
161+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
162+
color: Theme.of(
163+
context,
164+
).colorScheme.onSurface.withOpacity(0.7),
165+
),
166+
),
167+
const SizedBox(height: AppSpacing.lg),
168+
Align(
169+
alignment: AlignmentDirectional.centerStart,
170+
child: SegmentedButton<FeedItemClickBehavior>(
171+
segments: FeedItemClickBehavior.values
172+
.where(
173+
(b) => b != FeedItemClickBehavior.defaultBehavior,
174+
)
175+
.map(
176+
(behavior) =>
177+
ButtonSegment<FeedItemClickBehavior>(
178+
value: behavior,
179+
label: Text(behavior.l10n(context)),
180+
),
181+
)
182+
.toList(),
183+
selected: {
184+
widget.remoteConfig.features.feed.itemClickBehavior,
185+
},
186+
onSelectionChanged: (newSelection) {
187+
widget.onConfigChanged(
188+
widget.remoteConfig.copyWith(
189+
features: widget.remoteConfig.features.copyWith(
190+
feed: widget.remoteConfig.features.feed
191+
.copyWith(
192+
itemClickBehavior: newSelection.first,
193+
),
194+
),
195+
),
196+
);
197+
},
198+
),
199+
),
200+
],
144201
),
145202
const SizedBox(height: AppSpacing.lg),
146-
for (final decoratorType in FeedDecoratorType.values)
147-
Padding(
148-
padding: const EdgeInsets.only(bottom: AppSpacing.md),
149-
child: ExpansionTile(
150-
title: Text(decoratorType.l10n(context)),
151-
childrenPadding: const EdgeInsetsDirectional.only(
152-
start: AppSpacing.xl,
153-
top: AppSpacing.md,
154-
bottom: AppSpacing.md,
203+
ExpansionTile(
204+
title: Text(l10n.feedDecoratorsTitle),
205+
childrenPadding: const EdgeInsetsDirectional.only(
206+
start: AppSpacing.lg,
207+
top: AppSpacing.md,
208+
bottom: AppSpacing.md,
209+
),
210+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
211+
children: [
212+
Text(
213+
l10n.feedDecoratorsDescription,
214+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
215+
color: Theme.of(
216+
context,
217+
).colorScheme.onSurface.withOpacity(0.7),
155218
),
156-
expandedCrossAxisAlignment: CrossAxisAlignment.start,
157-
children: [
158-
FeedDecoratorForm(
159-
decoratorType: decoratorType,
160-
remoteConfig: widget.remoteConfig,
161-
onConfigChanged: widget.onConfigChanged,
162-
),
163-
],
164219
),
165-
),
220+
const SizedBox(height: AppSpacing.lg),
221+
for (final decoratorType in FeedDecoratorType.values)
222+
Padding(
223+
padding: const EdgeInsets.only(bottom: AppSpacing.md),
224+
child: ExpansionTile(
225+
title: Text(decoratorType.l10n(context)),
226+
childrenPadding: const EdgeInsetsDirectional.only(
227+
start: AppSpacing.xl,
228+
top: AppSpacing.md,
229+
bottom: AppSpacing.md,
230+
),
231+
expandedCrossAxisAlignment: CrossAxisAlignment.start,
232+
children: [
233+
FeedDecoratorForm(
234+
decoratorType: decoratorType,
235+
remoteConfig: widget.remoteConfig,
236+
onConfigChanged: widget.onConfigChanged,
237+
),
238+
],
239+
),
240+
),
241+
],
242+
),
166243
],
167244
);
168245
},

0 commit comments

Comments
 (0)