Skip to content

Commit 431ae16

Browse files
committed
refactor(app_configuration): remove unused _AccountActionConfigForm widget
- Delete the entire _AccountActionConfigForm StatefulWidget and its associated _AccountActionConfigFormState class - This widget was likely unused and not contributing to the functionality of the app
1 parent 239a758 commit 431ae16

File tree

1 file changed

+0
-128
lines changed

1 file changed

+0
-128
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,131 +1138,3 @@ class _AdConfigFormState extends State<_AdConfigForm> {
11381138
}
11391139
}
11401140
}
1141-
1142-
class _AccountActionConfigForm extends StatefulWidget {
1143-
const _AccountActionConfigForm({
1144-
required this.userRole,
1145-
required this.remoteConfig,
1146-
required this.onConfigChanged,
1147-
required this.buildIntField,
1148-
});
1149-
1150-
final AppUserRole userRole;
1151-
final RemoteConfig remoteConfig;
1152-
final ValueChanged<RemoteConfig> onConfigChanged;
1153-
final Widget Function(
1154-
BuildContext context, {
1155-
required String label,
1156-
required String description,
1157-
required int value,
1158-
required ValueChanged<int> onChanged,
1159-
TextEditingController? controller,
1160-
})
1161-
buildIntField;
1162-
1163-
@override
1164-
State<_AccountActionConfigForm> createState() =>
1165-
_AccountActionConfigFormState();
1166-
}
1167-
1168-
class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
1169-
late final Map<FeedActionType, TextEditingController> _controllers;
1170-
1171-
@override
1172-
void initState() {
1173-
super.initState();
1174-
_controllers = _initializeControllers();
1175-
}
1176-
1177-
@override
1178-
void didUpdateWidget(covariant _AccountActionConfigForm oldWidget) {
1179-
super.didUpdateWidget(oldWidget);
1180-
if (widget.remoteConfig.accountActionConfig !=
1181-
oldWidget.remoteConfig.accountActionConfig) {
1182-
_updateControllers();
1183-
}
1184-
}
1185-
1186-
Map<FeedActionType, TextEditingController> _initializeControllers() {
1187-
final config = widget.remoteConfig.accountActionConfig;
1188-
final daysMap = _getDaysMap(config);
1189-
return {
1190-
for (final type in FeedActionType.values)
1191-
type: TextEditingController(text: (daysMap[type] ?? 0).toString()),
1192-
};
1193-
}
1194-
1195-
void _updateControllers() {
1196-
final config = widget.remoteConfig.accountActionConfig;
1197-
final daysMap = _getDaysMap(config);
1198-
for (final type in FeedActionType.values) {
1199-
_controllers[type]?.text = (daysMap[type] ?? 0).toString();
1200-
}
1201-
}
1202-
1203-
Map<FeedActionType, int> _getDaysMap(AccountActionConfig config) {
1204-
switch (widget.userRole) {
1205-
case AppUserRole.guestUser:
1206-
return config.guestDaysBetweenActions;
1207-
case AppUserRole.standardUser:
1208-
return config.standardUserDaysBetweenActions;
1209-
case AppUserRole.premiumUser:
1210-
return {};
1211-
}
1212-
}
1213-
1214-
@override
1215-
void dispose() {
1216-
for (final controller in _controllers.values) {
1217-
controller.dispose();
1218-
}
1219-
super.dispose();
1220-
}
1221-
1222-
@override
1223-
Widget build(BuildContext context) {
1224-
final accountActionConfig = widget.remoteConfig.accountActionConfig;
1225-
final relevantActionTypes = _getDaysMap(accountActionConfig).keys.toList();
1226-
final l10n = AppLocalizationsX(context).l10n;
1227-
1228-
return Column(
1229-
children: relevantActionTypes.map((actionType) {
1230-
final localizedActionType = switch (actionType) {
1231-
FeedActionType.linkAccount => l10n.feedActionTypeLinkAccount,
1232-
FeedActionType.rateApp => l10n.feedActionTypeRateApp,
1233-
FeedActionType.followTopics => l10n.feedActionTypeFollowTopics,
1234-
FeedActionType.followSources => l10n.feedActionTypeFollowSources,
1235-
FeedActionType.upgrade => l10n.feedActionTypeUpgrade,
1236-
FeedActionType.enableNotifications =>
1237-
l10n.feedActionTypeEnableNotifications,
1238-
};
1239-
return widget.buildIntField(
1240-
context,
1241-
label: '$localizedActionType ${l10n.daysSuffix}',
1242-
description: l10n.daysBetweenPromptDescription(localizedActionType),
1243-
value: _getDaysMap(accountActionConfig)[actionType] ?? 0,
1244-
onChanged: (value) {
1245-
final currentMap = Map<FeedActionType, int>.from(
1246-
_getDaysMap(accountActionConfig),
1247-
);
1248-
final updatedMap = Map<FeedActionType, int>.from(currentMap)
1249-
..[actionType] = value;
1250-
1251-
final newConfig = widget.userRole == AppUserRole.guestUser
1252-
? accountActionConfig.copyWith(
1253-
guestDaysBetweenActions: updatedMap,
1254-
)
1255-
: accountActionConfig.copyWith(
1256-
standardUserDaysBetweenActions: updatedMap,
1257-
);
1258-
1259-
widget.onConfigChanged(
1260-
widget.remoteConfig.copyWith(accountActionConfig: newConfig),
1261-
);
1262-
},
1263-
controller: _controllers[actionType],
1264-
);
1265-
}).toList(),
1266-
);
1267-
}
1268-
}

0 commit comments

Comments
 (0)