mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-21 05:29:29 +02:00
Add "de/select all" button to multi-select menus (#2401)
This commit is contained in:
@@ -396,9 +396,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: outlineButtonStyle,
|
style: outlineButtonStyle,
|
||||||
onPressed:
|
onPressed: importInProgress
|
||||||
appsProvider.apps.isEmpty ||
|
|
||||||
importInProgress
|
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
runObtainiumExport(pickOnly: true);
|
runObtainiumExport(pickOnly: true);
|
||||||
@@ -710,6 +708,12 @@ class _SelectionModalState extends State<SelectionModal> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void selectAll({bool deselect = false}) {
|
||||||
|
for (var e in entrySelections.keys) {
|
||||||
|
entrySelections[e] = !deselect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Map<MapEntry<String, List<String>>, bool> filteredEntrySelections = {};
|
Map<MapEntry<String, List<String>>, bool> filteredEntrySelections = {};
|
||||||
@@ -731,6 +735,32 @@ class _SelectionModalState extends State<SelectionModal> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
getSelectAllButton() {
|
||||||
|
if (widget.onlyOneSelectionAllowed) {
|
||||||
|
return SizedBox.shrink();
|
||||||
|
}
|
||||||
|
var noneSelected = entrySelections.values.where((v) => v == true).isEmpty;
|
||||||
|
return noneSelected
|
||||||
|
? TextButton(
|
||||||
|
style: const ButtonStyle(visualDensity: VisualDensity.compact),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
selectAll();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(tr('selectAll')),
|
||||||
|
)
|
||||||
|
: TextButton(
|
||||||
|
style: const ButtonStyle(visualDensity: VisualDensity.compact),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
selectAll(deselect: true);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(tr('deselectX', args: [''])),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
title: Text(widget.title ?? tr('pick')),
|
title: Text(widget.title ?? tr('pick')),
|
||||||
@@ -900,6 +930,7 @@ class _SelectionModalState extends State<SelectionModal> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
getSelectAllButton(),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
Reference in New Issue
Block a user