mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 05:00:21 +02:00
Apps now support multiple categories
This commit is contained in:
@@ -30,7 +30,7 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
AppSource? pickedSource;
|
||||
Map<String, dynamic> additionalSettings = {};
|
||||
bool additionalSettingsValid = true;
|
||||
String? category;
|
||||
List<String> pickedCategories = [];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -127,8 +127,8 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
if (app.additionalSettings['trackOnly'] == true) {
|
||||
app.installedVersion = app.latestVersion;
|
||||
}
|
||||
if (category != null) {
|
||||
app.category = category;
|
||||
if (pickedCategories != null) {
|
||||
app.categories = pickedCategories;
|
||||
}
|
||||
await appsProvider.saveApps([app]);
|
||||
|
||||
@@ -334,11 +334,8 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
),
|
||||
CategoryEditorSelector(
|
||||
alignment: WrapAlignment.start,
|
||||
singleSelect: true,
|
||||
onSelected: (categories) {
|
||||
category = categories.isEmpty
|
||||
? null
|
||||
: categories.first;
|
||||
pickedCategories = categories;
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
@@ -156,15 +156,12 @@ class _AppPageState extends State<AppPage> {
|
||||
),
|
||||
CategoryEditorSelector(
|
||||
alignment: WrapAlignment.center,
|
||||
singleSelect: true,
|
||||
preselected: app?.app.category != null
|
||||
? {app!.app.category!}
|
||||
preselected: app?.app.categories != null
|
||||
? app!.app.categories.toSet()
|
||||
: {},
|
||||
onSelected: (categories) {
|
||||
if (app != null) {
|
||||
app.app.category = categories.isNotEmpty
|
||||
? categories[0]
|
||||
: null;
|
||||
app.app.categories = categories;
|
||||
appsProvider.saveApps([app.app]);
|
||||
}
|
||||
}),
|
||||
|
@@ -102,7 +102,9 @@ class AppsPageState extends State<AppsPage> {
|
||||
}
|
||||
}
|
||||
if (filter.categoryFilter.isNotEmpty &&
|
||||
!filter.categoryFilter.contains(app.app.category)) {
|
||||
filter.categoryFilter
|
||||
.intersection(app.app.categories.toSet())
|
||||
.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -224,14 +226,21 @@ class AppsPageState extends State<AppsPage> {
|
||||
String? changesUrl = SourceProvider()
|
||||
.getSource(sortedApps[index].app.url)
|
||||
.changeLogPageFromStandardUrl(sortedApps[index].app.url);
|
||||
var transparent = const Color.fromARGB(0, 0, 0, 0).value;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
width: 4,
|
||||
color: Color(settingsProvider.categories[
|
||||
sortedApps[index].app.category] ??
|
||||
const Color.fromARGB(0, 0, 0, 0).value)))),
|
||||
color: Color(
|
||||
sortedApps[index].app.categories.isNotEmpty
|
||||
? settingsProvider.categories[
|
||||
sortedApps[index]
|
||||
.app
|
||||
.categories
|
||||
.first] ??
|
||||
transparent
|
||||
: transparent)))),
|
||||
child: ListTile(
|
||||
tileColor: sortedApps[index].app.pinned
|
||||
? Colors.grey.withOpacity(0.1)
|
||||
|
@@ -436,7 +436,7 @@ class _CategoryEditorSelectorState extends State<CategoryEditorSelector> {
|
||||
items: [
|
||||
[
|
||||
GeneratedFormTagInput('categories',
|
||||
label: tr('category'),
|
||||
label: tr('categories'),
|
||||
emptyMessage: tr('noCategories'),
|
||||
defaultValue: storedValues,
|
||||
alignment: widget.alignment,
|
||||
|
Reference in New Issue
Block a user