Skip to content

Commit 929df02

Browse files
committed
style: format
1 parent 9a0ff87 commit 929df02

File tree

9 files changed

+208
-134
lines changed

9 files changed

+208
-134
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import 'package:core/core.dart';
21
import 'package:flutter/material.dart';
32
import 'package:flutter_bloc/flutter_bloc.dart';
43
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/l10n/app_localizations.dart';
64
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/advertisements_configuration_tab.dart';
75
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/feed_configuration_tab.dart';
86
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/view/tabs/general_configuration_tab.dart';
9-
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/app_config_form_fields.dart';
10-
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/ad_config_form.dart';
11-
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/feed_decorator_form.dart';
12-
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/user_preference_limits_form.dart';
137
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
148
import 'package:ui_kit/ui_kit.dart';
159

lib/app_configuration/view/tabs/feed_configuration_tab.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'package:core/core.dart';
22
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';
53
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/feed_decorator_form.dart';
64
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/user_preference_limits_form.dart';
75
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
@@ -77,19 +75,25 @@ class FeedConfigurationTab extends StatelessWidget {
7775
decoratorType: decoratorType,
7876
remoteConfig: remoteConfig.copyWith(
7977
feedDecoratorConfig:
80-
Map.from(remoteConfig.feedDecoratorConfig)..putIfAbsent(
78+
Map.from(
79+
remoteConfig.feedDecoratorConfig,
80+
)..putIfAbsent(
8181
decoratorType,
8282
() => FeedDecoratorConfig(
8383
category:
84-
decoratorType == FeedDecoratorType.suggestedTopics ||
85-
decoratorType == FeedDecoratorType.suggestedSources
84+
decoratorType ==
85+
FeedDecoratorType.suggestedTopics ||
86+
decoratorType ==
87+
FeedDecoratorType.suggestedSources
8688
? FeedDecoratorCategory.contentCollection
8789
: FeedDecoratorCategory.callToAction,
8890
enabled: false,
8991
visibleTo: const {},
9092
itemsToDisplay:
91-
decoratorType == FeedDecoratorType.suggestedTopics ||
92-
decoratorType == FeedDecoratorType.suggestedSources
93+
decoratorType ==
94+
FeedDecoratorType.suggestedTopics ||
95+
decoratorType ==
96+
FeedDecoratorType.suggestedSources
9397
? 0
9498
: null,
9599
),

lib/app_configuration/view/tabs/general_configuration_tab.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'package:core/core.dart';
22
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';
53
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/widgets/app_config_form_fields.dart';
64
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
75
import 'package:ui_kit/ui_kit.dart';
@@ -46,7 +44,9 @@ class GeneralConfigurationTab extends StatelessWidget {
4644
Text(
4745
l10n.maintenanceModeDescription,
4846
style: Theme.of(context).textTheme.bodySmall?.copyWith(
49-
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
47+
color: Theme.of(
48+
context,
49+
).colorScheme.onSurface.withOpacity(0.7),
5050
),
5151
),
5252
const SizedBox(height: AppSpacing.lg),
@@ -83,7 +83,9 @@ class GeneralConfigurationTab extends StatelessWidget {
8383
Text(
8484
l10n.forceUpdateDescription,
8585
style: Theme.of(context).textTheme.bodySmall?.copyWith(
86-
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
86+
color: Theme.of(
87+
context,
88+
).colorScheme.onSurface.withOpacity(0.7),
8789
),
8890
),
8991
const SizedBox(height: AppSpacing.lg),

lib/app_configuration/widgets/ad_config_form.dart

Lines changed: 88 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ class AdConfigForm extends StatefulWidget {
3333
class _AdConfigFormState extends State<AdConfigForm> {
3434
AppUserRole _selectedUserRole = AppUserRole.guestUser;
3535
late final Map<AppUserRole, TextEditingController> _adFrequencyControllers;
36-
late final Map<AppUserRole, TextEditingController> _adPlacementIntervalControllers;
3736
late final Map<AppUserRole, TextEditingController>
38-
_articlesToReadBeforeShowingInterstitialAdsControllers;
37+
_adPlacementIntervalControllers;
38+
late final Map<AppUserRole, TextEditingController>
39+
_articlesToReadBeforeShowingInterstitialAdsControllers;
3940

4041
@override
4142
void initState() {
@@ -55,49 +56,64 @@ class _AdConfigFormState extends State<AdConfigForm> {
5556
final adConfig = widget.remoteConfig.adConfig;
5657
_adFrequencyControllers = {
5758
for (final role in AppUserRole.values)
58-
role: TextEditingController(
59-
text: _getAdFrequency(adConfig, role).toString(),
60-
)..selection = TextSelection.collapsed(
61-
offset: _getAdFrequency(adConfig, role).toString().length,
62-
),
59+
role:
60+
TextEditingController(
61+
text: _getAdFrequency(adConfig, role).toString(),
62+
)
63+
..selection = TextSelection.collapsed(
64+
offset: _getAdFrequency(adConfig, role).toString().length,
65+
),
6366
};
6467
_adPlacementIntervalControllers = {
6568
for (final role in AppUserRole.values)
66-
role: TextEditingController(
67-
text: _getAdPlacementInterval(adConfig, role).toString(),
68-
)..selection = TextSelection.collapsed(
69-
offset: _getAdPlacementInterval(adConfig, role).toString().length,
70-
),
69+
role:
70+
TextEditingController(
71+
text: _getAdPlacementInterval(adConfig, role).toString(),
72+
)
73+
..selection = TextSelection.collapsed(
74+
offset: _getAdPlacementInterval(
75+
adConfig,
76+
role,
77+
).toString().length,
78+
),
7179
};
7280
_articlesToReadBeforeShowingInterstitialAdsControllers = {
7381
for (final role in AppUserRole.values)
74-
role: TextEditingController(
75-
text: _getArticlesBeforeInterstitial(adConfig, role).toString(),
76-
)..selection = TextSelection.collapsed(
77-
offset: _getArticlesBeforeInterstitial(adConfig, role)
78-
.toString()
79-
.length,
80-
),
82+
role:
83+
TextEditingController(
84+
text: _getArticlesBeforeInterstitial(adConfig, role).toString(),
85+
)
86+
..selection = TextSelection.collapsed(
87+
offset: _getArticlesBeforeInterstitial(
88+
adConfig,
89+
role,
90+
).toString().length,
91+
),
8192
};
8293
}
8394

8495
void _updateControllers() {
8596
final adConfig = widget.remoteConfig.adConfig;
8697
for (final role in AppUserRole.values) {
87-
_adFrequencyControllers[role]?.text =
88-
_getAdFrequency(adConfig, role).toString();
98+
_adFrequencyControllers[role]?.text = _getAdFrequency(
99+
adConfig,
100+
role,
101+
).toString();
89102
_adFrequencyControllers[role]?.selection = TextSelection.collapsed(
90103
offset: _adFrequencyControllers[role]!.text.length,
91104
);
92-
_adPlacementIntervalControllers[role]?.text =
93-
_getAdPlacementInterval(adConfig, role).toString();
94-
_adPlacementIntervalControllers[role]?.selection = TextSelection.collapsed(
95-
offset: _adPlacementIntervalControllers[role]!.text.length,
96-
);
105+
_adPlacementIntervalControllers[role]?.text = _getAdPlacementInterval(
106+
adConfig,
107+
role,
108+
).toString();
109+
_adPlacementIntervalControllers[role]?.selection =
110+
TextSelection.collapsed(
111+
offset: _adPlacementIntervalControllers[role]!.text.length,
112+
);
97113
_articlesToReadBeforeShowingInterstitialAdsControllers[role]?.text =
98114
_getArticlesBeforeInterstitial(adConfig, role).toString();
99-
_articlesToReadBeforeShowingInterstitialAdsControllers[role]?.selection =
100-
TextSelection.collapsed(
115+
_articlesToReadBeforeShowingInterstitialAdsControllers[role]
116+
?.selection = TextSelection.collapsed(
101117
offset: _articlesToReadBeforeShowingInterstitialAdsControllers[role]!
102118
.text
103119
.length,
@@ -221,11 +237,16 @@ class _AdConfigFormState extends State<AdConfigForm> {
221237
onChanged: (value) {
222238
widget.onConfigChanged(
223239
widget.remoteConfig.copyWith(
224-
adConfig: _updateArticlesBeforeInterstitial(config, value, role),
240+
adConfig: _updateArticlesBeforeInterstitial(
241+
config,
242+
value,
243+
role,
244+
),
225245
),
226246
);
227247
},
228-
controller: _articlesToReadBeforeShowingInterstitialAdsControllers[role],
248+
controller:
249+
_articlesToReadBeforeShowingInterstitialAdsControllers[role],
229250
),
230251
],
231252
);
@@ -236,7 +257,10 @@ class _AdConfigFormState extends State<AdConfigForm> {
236257
case AppUserRole.guestUser:
237258
return config.feedAdConfiguration.frequencyConfig.guestAdFrequency;
238259
case AppUserRole.standardUser:
239-
return config.feedAdConfiguration.frequencyConfig.authenticatedAdFrequency;
260+
return config
261+
.feedAdConfiguration
262+
.frequencyConfig
263+
.authenticatedAdFrequency;
240264
case AppUserRole.premiumUser:
241265
return config.feedAdConfiguration.frequencyConfig.premiumAdFrequency;
242266
}
@@ -245,25 +269,43 @@ class _AdConfigFormState extends State<AdConfigForm> {
245269
int _getAdPlacementInterval(AdConfig config, AppUserRole role) {
246270
switch (role) {
247271
case AppUserRole.guestUser:
248-
return config.feedAdConfiguration.frequencyConfig.guestAdPlacementInterval;
272+
return config
273+
.feedAdConfiguration
274+
.frequencyConfig
275+
.guestAdPlacementInterval;
249276
case AppUserRole.standardUser:
250-
return config.feedAdConfiguration.frequencyConfig.authenticatedAdPlacementInterval;
277+
return config
278+
.feedAdConfiguration
279+
.frequencyConfig
280+
.authenticatedAdPlacementInterval;
251281
case AppUserRole.premiumUser:
252-
return config.feedAdConfiguration.frequencyConfig.premiumAdPlacementInterval;
282+
return config
283+
.feedAdConfiguration
284+
.frequencyConfig
285+
.premiumAdPlacementInterval;
253286
}
254287
}
255288

256289
int _getArticlesBeforeInterstitial(AdConfig config, AppUserRole role) {
257290
switch (role) {
258291
case AppUserRole.guestUser:
259-
return config.articleAdConfiguration.interstitialAdConfiguration
260-
.frequencyConfig.guestArticlesToReadBeforeShowingInterstitialAds;
292+
return config
293+
.articleAdConfiguration
294+
.interstitialAdConfiguration
295+
.frequencyConfig
296+
.guestArticlesToReadBeforeShowingInterstitialAds;
261297
case AppUserRole.standardUser:
262-
return config.articleAdConfiguration.interstitialAdConfiguration
263-
.frequencyConfig.standardUserArticlesToReadBeforeShowingInterstitialAds;
298+
return config
299+
.articleAdConfiguration
300+
.interstitialAdConfiguration
301+
.frequencyConfig
302+
.standardUserArticlesToReadBeforeShowingInterstitialAds;
264303
case AppUserRole.premiumUser:
265-
return config.articleAdConfiguration.interstitialAdConfiguration
266-
.frequencyConfig.premiumUserArticlesToReadBeforeShowingInterstitialAds;
304+
return config
305+
.articleAdConfiguration
306+
.interstitialAdConfiguration
307+
.frequencyConfig
308+
.premiumUserArticlesToReadBeforeShowingInterstitialAds;
267309
}
268310
}
269311

@@ -328,8 +370,10 @@ class _AdConfigFormState extends State<AdConfigForm> {
328370
int value,
329371
AppUserRole role,
330372
) {
331-
final currentFrequencyConfig =
332-
config.articleAdConfiguration.interstitialAdConfiguration.frequencyConfig;
373+
final currentFrequencyConfig = config
374+
.articleAdConfiguration
375+
.interstitialAdConfiguration
376+
.frequencyConfig;
333377

334378
ArticleInterstitialAdFrequencyConfig newFrequencyConfig;
335379

@@ -338,23 +382,21 @@ class _AdConfigFormState extends State<AdConfigForm> {
338382
newFrequencyConfig = currentFrequencyConfig.copyWith(
339383
guestArticlesToReadBeforeShowingInterstitialAds: value,
340384
);
341-
break;
342385
case AppUserRole.standardUser:
343386
newFrequencyConfig = currentFrequencyConfig.copyWith(
344387
standardUserArticlesToReadBeforeShowingInterstitialAds: value,
345388
);
346-
break;
347389
case AppUserRole.premiumUser:
348390
newFrequencyConfig = currentFrequencyConfig.copyWith(
349391
premiumUserArticlesToReadBeforeShowingInterstitialAds: value,
350392
);
351-
break;
352393
}
353394

354395
return config.copyWith(
355396
articleAdConfiguration: config.articleAdConfiguration.copyWith(
356397
interstitialAdConfiguration: config
357-
.articleAdConfiguration.interstitialAdConfiguration
398+
.articleAdConfiguration
399+
.interstitialAdConfiguration
358400
.copyWith(frequencyConfig: newFrequencyConfig),
359401
),
360402
);

lib/app_configuration/widgets/app_config_form_fields.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/constants/app_constants.dart';
43
import 'package:ui_kit/ui_kit.dart';
54

65
/// {@template app_config_int_field}

0 commit comments

Comments
 (0)