Skip to content

Commit 5e45dfb

Browse files
committed
refactor(app_config): Use string instead of enum for user roles
- Replaced AppUserRole enum with string comparisons. - Improved code readability and maintainability. - Fixed potential issues with enum usage. - Simplified switch statement logic. - No functional changes.
1 parent 9d4f14b commit 5e45dfb

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
10121012
return const SizedBox.shrink();
10131013
default:
10141014
return const SizedBox.shrink();
1015+
}
10151016
}
10161017
}
10171018

@@ -1222,8 +1223,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
12221223
Widget build(BuildContext context) {
12231224
final adConfig = widget.remoteConfig.adConfig;
12241225

1225-
switch (AppUserRole.values.byName(widget.userRole)) {
1226-
case AppUserRole.guestUser:
1226+
switch (widget.userRole) {
1227+
case 'guestUser':
12271228
return Column(
12281229
children: [
12291230
widget.buildIntField(
@@ -1281,7 +1282,7 @@ class _AdConfigFormState extends State<_AdConfigForm> {
12811282
),
12821283
],
12831284
);
1284-
case AppUserRole.standardUser:
1285+
case 'standardUser':
12851286
return Column(
12861287
children: [
12871288
widget.buildIntField(
@@ -1343,7 +1344,7 @@ class _AdConfigFormState extends State<_AdConfigForm> {
13431344
),
13441345
],
13451346
);
1346-
case AppUserRole.premiumUser:
1347+
case 'premiumUser':
13471348
return Column(
13481349
children: [
13491350
widget.buildIntField(
@@ -1402,9 +1403,11 @@ class _AdConfigFormState extends State<_AdConfigForm> {
14021403
),
14031404
],
14041405
);
1405-
case AppUserRole.none:
1406-
case AppUserRole.admin:
1407-
case AppUserRole.publisher:
1406+
case 'none':
1407+
case 'admin':
1408+
case 'publisher':
1409+
return const SizedBox.shrink();
1410+
default:
14081411
return const SizedBox.shrink();
14091412
}
14101413
}
@@ -1506,8 +1509,8 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
15061509
Widget build(BuildContext context) {
15071510
final accountActionConfig = widget.remoteConfig.accountActionConfig;
15081511

1509-
switch (AppUserRole.values.byName(widget.userRole)) {
1510-
case AppUserRole.guestUser:
1512+
switch (widget.userRole) {
1513+
case 'guestUser':
15111514
return Column(
15121515
children: [
15131516
widget.buildIntField(
@@ -1534,7 +1537,7 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
15341537
),
15351538
],
15361539
);
1537-
case AppUserRole.standardUser:
1540+
case 'standardUser':
15381541
return Column(
15391542
children: [
15401543
widget.buildIntField(
@@ -1561,9 +1564,11 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
15611564
),
15621565
],
15631566
);
1564-
case AppUserRole.premiumUser:
1565-
case AppUserRole.admin:
1566-
case AppUserRole.publisher:
1567+
case 'premiumUser':
1568+
case 'admin':
1569+
case 'publisher':
1570+
return const SizedBox.shrink();
1571+
default:
15671572
return const SizedBox.shrink();
15681573
}
15691574
}

0 commit comments

Comments
 (0)