mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-23 01:29:40 +02:00
More fixes to prev commit
This commit is contained in:
@@ -8,14 +8,12 @@ class GeneratedFormModal extends StatefulWidget {
|
|||||||
{super.key,
|
{super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.items,
|
required this.items,
|
||||||
required this.defaultValues,
|
|
||||||
this.initValid = false,
|
this.initValid = false,
|
||||||
this.message = ''});
|
this.message = ''});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final String message;
|
final String message;
|
||||||
final List<List<GeneratedFormItem>> items;
|
final List<List<GeneratedFormItem>> items;
|
||||||
final Map<String, String> defaultValues;
|
|
||||||
final bool initValid;
|
final bool initValid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,9 +27,6 @@ class _GeneratedFormModalState extends State<GeneratedFormModal> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
widget.defaultValues.forEach((key, value) {
|
|
||||||
values[key] = value;
|
|
||||||
});
|
|
||||||
valid = widget.initValid || widget.items.isEmpty;
|
valid = widget.initValid || widget.items.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,6 @@ class _AddAppPageState extends State<AddAppPage> {
|
|||||||
: tr('app')
|
: tr('app')
|
||||||
]),
|
]),
|
||||||
items: const [],
|
items: const [],
|
||||||
defaultValues: const {},
|
|
||||||
message:
|
message:
|
||||||
'${pickedSource!.enforceTrackOnly ? tr('appsFromSourceAreTrackOnly') : tr('youPickedTrackOnly')}\n\n${tr('trackOnlyAppDescription')}',
|
'${pickedSource!.enforceTrackOnly ? tr('appsFromSourceAreTrackOnly') : tr('youPickedTrackOnly')}\n\n${tr('trackOnlyAppDescription')}',
|
||||||
);
|
);
|
||||||
@@ -99,7 +98,6 @@ class _AddAppPageState extends State<AddAppPage> {
|
|||||||
return const GeneratedFormModal(
|
return const GeneratedFormModal(
|
||||||
title: 'Disable Version Detection', // TODO
|
title: 'Disable Version Detection', // TODO
|
||||||
items: [],
|
items: [],
|
||||||
defaultValues: {},
|
|
||||||
message: 'TODO',
|
message: 'TODO',
|
||||||
);
|
);
|
||||||
}) ==
|
}) ==
|
||||||
|
@@ -214,12 +214,7 @@ class _AppPageState extends State<AppPage> {
|
|||||||
return GeneratedFormModal(
|
return GeneratedFormModal(
|
||||||
title: 'Additional Options',
|
title: 'Additional Options',
|
||||||
items: source
|
items: source
|
||||||
.additionalSourceAppSpecificFormItems,
|
.additionalSourceAppSpecificFormItems);
|
||||||
defaultValues: app != null
|
|
||||||
? app.app.additionalData
|
|
||||||
: getDefaultValuesFromFormItems(
|
|
||||||
source
|
|
||||||
.additionalSourceAppSpecificFormItems));
|
|
||||||
}).then((values) {
|
}).then((values) {
|
||||||
if (app != null && values != null) {
|
if (app != null && values != null) {
|
||||||
var changedApp = app.app;
|
var changedApp = app.app;
|
||||||
|
@@ -349,7 +349,6 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
return GeneratedFormModal(
|
return GeneratedFormModal(
|
||||||
title: tr('removeSelectedAppsQuestion'),
|
title: tr('removeSelectedAppsQuestion'),
|
||||||
items: const [],
|
items: const [],
|
||||||
defaultValues: const {},
|
|
||||||
initValid: true,
|
initValid: true,
|
||||||
message: tr(
|
message: tr(
|
||||||
'xWillBeRemovedButRemainInstalled',
|
'xWillBeRemovedButRemainInstalled',
|
||||||
@@ -376,36 +375,40 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
HapticFeedback.heavyImpact();
|
HapticFeedback.heavyImpact();
|
||||||
List<GeneratedFormItem> formInputs = [];
|
List<GeneratedFormItem> formItems = [];
|
||||||
Map<String, String> defaultValues = {};
|
|
||||||
if (existingUpdateIdsAllOrSelected.isNotEmpty) {
|
if (existingUpdateIdsAllOrSelected.isNotEmpty) {
|
||||||
formInputs.add(GeneratedFormItem('updates',
|
formItems.add(GeneratedFormItem('updates',
|
||||||
label: tr('updateX', args: [
|
label: tr('updateX', args: [
|
||||||
plural('apps',
|
plural('apps',
|
||||||
existingUpdateIdsAllOrSelected.length)
|
existingUpdateIdsAllOrSelected.length)
|
||||||
]),
|
]),
|
||||||
type: FormItemType.bool));
|
type: FormItemType.bool,
|
||||||
defaultValues['updates'] = 'true';
|
defaultValue: 'true'));
|
||||||
}
|
}
|
||||||
if (newInstallIdsAllOrSelected.isNotEmpty) {
|
if (newInstallIdsAllOrSelected.isNotEmpty) {
|
||||||
formInputs.add(GeneratedFormItem('installs',
|
formItems.add(GeneratedFormItem('installs',
|
||||||
label: tr('installX', args: [
|
label: tr('installX', args: [
|
||||||
plural('apps',
|
plural('apps',
|
||||||
newInstallIdsAllOrSelected.length)
|
newInstallIdsAllOrSelected.length)
|
||||||
]),
|
]),
|
||||||
type: FormItemType.bool));
|
type: FormItemType.bool,
|
||||||
defaultValues['installs'] =
|
defaultValue:
|
||||||
defaultValues.isEmpty ? 'true' : '';
|
existingUpdateIdsAllOrSelected.isNotEmpty
|
||||||
|
? 'true'
|
||||||
|
: ''));
|
||||||
}
|
}
|
||||||
if (trackOnlyUpdateIdsAllOrSelected.isNotEmpty) {
|
if (trackOnlyUpdateIdsAllOrSelected.isNotEmpty) {
|
||||||
formInputs.add(GeneratedFormItem('trackonlies',
|
formItems.add(GeneratedFormItem('trackonlies',
|
||||||
label: tr('markXTrackOnlyAsUpdated', args: [
|
label: tr('markXTrackOnlyAsUpdated', args: [
|
||||||
plural('apps',
|
plural('apps',
|
||||||
trackOnlyUpdateIdsAllOrSelected.length)
|
trackOnlyUpdateIdsAllOrSelected.length)
|
||||||
]),
|
]),
|
||||||
type: FormItemType.bool));
|
type: FormItemType.bool,
|
||||||
defaultValues['trackonlies'] =
|
defaultValue: existingUpdateIdsAllOrSelected
|
||||||
defaultValues.isEmpty ? 'true' : '';
|
.isNotEmpty ||
|
||||||
|
newInstallIdsAllOrSelected.isNotEmpty
|
||||||
|
? 'true'
|
||||||
|
: ''));
|
||||||
}
|
}
|
||||||
showDialog<Map<String, String>?>(
|
showDialog<Map<String, String>?>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -417,14 +420,14 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
return GeneratedFormModal(
|
return GeneratedFormModal(
|
||||||
title: tr('changeX',
|
title: tr('changeX',
|
||||||
args: [plural('apps', totalApps)]),
|
args: [plural('apps', totalApps)]),
|
||||||
items: formInputs.map((e) => [e]).toList(),
|
items: formItems.map((e) => [e]).toList(),
|
||||||
defaultValues: defaultValues,
|
|
||||||
initValid: true,
|
initValid: true,
|
||||||
);
|
);
|
||||||
}).then((values) {
|
}).then((values) {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
if (values.isEmpty) {
|
if (values.isEmpty) {
|
||||||
values = defaultValues;
|
values = getDefaultValuesFromFormItems(
|
||||||
|
[formItems]);
|
||||||
}
|
}
|
||||||
bool shouldInstallUpdates =
|
bool shouldInstallUpdates =
|
||||||
values['updates'] == 'true';
|
values['updates'] == 'true';
|
||||||
@@ -604,7 +607,6 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
title: tr(
|
title: tr(
|
||||||
'resetInstallStatusForSelectedAppsQuestion'),
|
'resetInstallStatusForSelectedAppsQuestion'),
|
||||||
items: const [],
|
items: const [],
|
||||||
defaultValues: const {},
|
|
||||||
initValid: true,
|
initValid: true,
|
||||||
message: tr(
|
message: tr(
|
||||||
'installStatusOfXWillBeResetExplanation',
|
'installStatusOfXWillBeResetExplanation',
|
||||||
@@ -677,29 +679,35 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
showDialog<Map<String, String>?>(
|
showDialog<Map<String, String>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext ctx) {
|
builder: (BuildContext ctx) {
|
||||||
|
var vals = filter == null
|
||||||
|
? AppsFilter().toValuesMap()
|
||||||
|
: filter!.toValuesMap();
|
||||||
return GeneratedFormModal(
|
return GeneratedFormModal(
|
||||||
title: tr('filterApps'),
|
title: tr('filterApps'),
|
||||||
items: [
|
items: [
|
||||||
[
|
[
|
||||||
GeneratedFormItem('appName',
|
GeneratedFormItem('appName',
|
||||||
label: tr('appName'), required: false),
|
label: tr('appName'),
|
||||||
|
required: false,
|
||||||
|
defaultValue: vals['appName']),
|
||||||
GeneratedFormItem('author',
|
GeneratedFormItem('author',
|
||||||
label: tr('author'), required: false)
|
label: tr('author'),
|
||||||
|
required: false,
|
||||||
|
defaultValue: vals['author'])
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
GeneratedFormItem('upToDateApps',
|
GeneratedFormItem('upToDateApps',
|
||||||
label: tr('upToDateApps'),
|
label: tr('upToDateApps'),
|
||||||
type: FormItemType.bool)
|
type: FormItemType.bool,
|
||||||
|
defaultValue: vals['upToDateApps'])
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
GeneratedFormItem('nonInstalledApps',
|
GeneratedFormItem('nonInstalledApps',
|
||||||
label: tr('nonInstalledApps'),
|
label: tr('nonInstalledApps'),
|
||||||
type: FormItemType.bool)
|
type: FormItemType.bool,
|
||||||
|
defaultValue: vals['nonInstalledApps'])
|
||||||
]
|
]
|
||||||
],
|
]);
|
||||||
defaultValues: filter == null
|
|
||||||
? AppsFilter().toValuesMap()
|
|
||||||
: filter!.toValuesMap());
|
|
||||||
}).then((values) {
|
}).then((values) {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@@ -172,7 +172,6 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
])
|
])
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
defaultValues: const {},
|
|
||||||
);
|
);
|
||||||
}).then((values) {
|
}).then((values) {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
@@ -242,7 +241,6 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
'searchQuery'))
|
'searchQuery'))
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
defaultValues: const {},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (values != null &&
|
if (values != null &&
|
||||||
@@ -351,7 +349,6 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
label: e)
|
label: e)
|
||||||
])
|
])
|
||||||
.toList(),
|
.toList(),
|
||||||
defaultValues: const {},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
|
@@ -141,8 +141,9 @@ List<String> getLinksFromParsedHTML(
|
|||||||
.map((e) => '$prependToLinks${e.attributes['href']!}')
|
.map((e) => '$prependToLinks${e.attributes['href']!}')
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
getDefaultValuesFromFormItems(List<List<GeneratedFormItem>> items) {
|
Map<String, String> getDefaultValuesFromFormItems(
|
||||||
Map.fromEntries(items
|
List<List<GeneratedFormItem>> items) {
|
||||||
|
return Map.fromEntries(items
|
||||||
.map((row) => row.map((el) => MapEntry(el.key, el.defaultValue ?? '')))
|
.map((row) => row.map((el) => MapEntry(el.key, el.defaultValue ?? '')))
|
||||||
.reduce((value, element) => [...value, ...element]));
|
.reduce((value, element) => [...value, ...element]));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user