mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-28 08:49:29 +02:00
Category displayed on App/Apps pages
+ category save bugfix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/components/generated_form_modal.dart';
|
import 'package:obtainium/components/generated_form_modal.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/main.dart';
|
import 'package:obtainium/main.dart';
|
||||||
@@ -33,6 +34,7 @@ class _AppPageState extends State<AppPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var categories = settingsProvider.categories;
|
||||||
var sourceProvider = SourceProvider();
|
var sourceProvider = SourceProvider();
|
||||||
AppInMemory? app = appsProvider.apps[widget.appId];
|
AppInMemory? app = appsProvider.apps[widget.appId];
|
||||||
var source = app != null ? sourceProvider.getSource(app.app.url) : null;
|
var source = app != null ? sourceProvider.getSource(app.app.url) : null;
|
||||||
@@ -148,7 +150,63 @@ class _AppPageState extends State<AppPage> {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontStyle: FontStyle.italic, fontSize: 12),
|
fontStyle: FontStyle.italic, fontSize: 12),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
|
app?.app.category != null
|
||||||
|
? Chip(
|
||||||
|
label: Text(app!.app.category!),
|
||||||
|
backgroundColor:
|
||||||
|
Color(categories[app.app.category!] ?? 0x0),
|
||||||
|
onDeleted: () {
|
||||||
|
app.app.category = null;
|
||||||
|
appsProvider.saveApps([app.app]);
|
||||||
|
},
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
)
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
showDialog<Map<String, String>?>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext ctx) {
|
||||||
|
return GeneratedFormModal(
|
||||||
|
title: 'Pick a Category',
|
||||||
|
items: [
|
||||||
|
[
|
||||||
|
GeneratedFormItem(
|
||||||
|
'category', // TODO
|
||||||
|
label: 'Category',
|
||||||
|
opts: [
|
||||||
|
MapEntry('',
|
||||||
|
'No Category'),
|
||||||
|
...categories
|
||||||
|
.entries
|
||||||
|
.map((e) =>
|
||||||
|
MapEntry(
|
||||||
|
e.key,
|
||||||
|
e.key))
|
||||||
|
.toList()
|
||||||
|
])
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}).then((value) {
|
||||||
|
if (value != null && app != null) {
|
||||||
|
String? cat = (value['category']
|
||||||
|
?.isNotEmpty ??
|
||||||
|
false)
|
||||||
|
? value['category']
|
||||||
|
: null;
|
||||||
|
app.app.category = cat;
|
||||||
|
appsProvider.saveApps([app.app]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: const Text('Categorize')) // TODO
|
||||||
|
])
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
|
@@ -225,7 +225,15 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
String? changesUrl = SourceProvider()
|
String? changesUrl = SourceProvider()
|
||||||
.getSource(sortedApps[index].app.url)
|
.getSource(sortedApps[index].app.url)
|
||||||
.changeLogPageFromStandardUrl(sortedApps[index].app.url);
|
.changeLogPageFromStandardUrl(sortedApps[index].app.url);
|
||||||
return ListTile(
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.symmetric(
|
||||||
|
vertical: BorderSide(
|
||||||
|
width: 3,
|
||||||
|
color: Color(settingsProvider.categories[
|
||||||
|
sortedApps[index].app.category] ??
|
||||||
|
const Color.fromARGB(0, 0, 0, 0).value)))),
|
||||||
|
child: ListTile(
|
||||||
tileColor: sortedApps[index].app.pinned
|
tileColor: sortedApps[index].app.pinned
|
||||||
? Colors.grey.withOpacity(0.1)
|
? Colors.grey.withOpacity(0.1)
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
@@ -249,9 +257,11 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: sortedApps[index].app.pinned
|
fontWeight: sortedApps[index].app.pinned
|
||||||
? FontWeight.bold
|
? FontWeight.bold
|
||||||
: FontWeight.normal),
|
: FontWeight.normal,
|
||||||
),
|
),
|
||||||
subtitle: Text(tr('byX', args: [sortedApps[index].app.author]),
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
tr('byX', args: [sortedApps[index].app.author]),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: sortedApps[index].app.pinned
|
fontWeight: sortedApps[index].app.pinned
|
||||||
? FontWeight.bold
|
? FontWeight.bold
|
||||||
@@ -277,9 +287,14 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
)),
|
)),
|
||||||
sortedApps[index].app.installedVersion != null &&
|
|
||||||
sortedApps[index].app.installedVersion !=
|
sortedApps[index].app.installedVersion !=
|
||||||
sortedApps[index].app.latestVersion
|
null &&
|
||||||
|
sortedApps[index]
|
||||||
|
.app
|
||||||
|
.installedVersion !=
|
||||||
|
sortedApps[index]
|
||||||
|
.app
|
||||||
|
.latestVersion
|
||||||
? GestureDetector(
|
? GestureDetector(
|
||||||
onTap: changesUrl == null
|
onTap: changesUrl == null
|
||||||
? null
|
? null
|
||||||
@@ -288,13 +303,16 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
mode: LaunchMode
|
mode: LaunchMode
|
||||||
.externalApplication);
|
.externalApplication);
|
||||||
},
|
},
|
||||||
child: appsProvider.areDownloadsRunning()
|
child: appsProvider
|
||||||
|
.areDownloadsRunning()
|
||||||
? Text(tr('pleaseWait'))
|
? Text(tr('pleaseWait'))
|
||||||
: Text(
|
: Text(
|
||||||
'${tr('updateAvailable')}${sortedApps[index].app.additionalSettings['trackOnly'] == 'true' ? ' ${tr('estimateInBracketsShort')}' : ''}',
|
'${tr('updateAvailable')}${sortedApps[index].app.additionalSettings['trackOnly'] == 'true' ? ' ${tr('estimateInBracketsShort')}' : ''}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle:
|
||||||
decoration: changesUrl == null
|
FontStyle.italic,
|
||||||
|
decoration: changesUrl ==
|
||||||
|
null
|
||||||
? TextDecoration.none
|
? TextDecoration.none
|
||||||
: TextDecoration
|
: TextDecoration
|
||||||
.underline),
|
.underline),
|
||||||
@@ -314,7 +332,7 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
));
|
||||||
}, childCount: sortedApps.length))
|
}, childCount: sortedApps.length))
|
||||||
])),
|
])),
|
||||||
persistentFooterButtons: [
|
persistentFooterButtons: [
|
||||||
|
@@ -19,6 +19,7 @@ import 'package:obtainium/app_sources/steammobile.dart';
|
|||||||
import 'package:obtainium/components/generated_form.dart';
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/mass_app_sources/githubstars.dart';
|
import 'package:obtainium/mass_app_sources/githubstars.dart';
|
||||||
|
import 'package:obtainium/providers/settings_provider.dart';
|
||||||
|
|
||||||
class AppNames {
|
class AppNames {
|
||||||
late String author;
|
late String author;
|
||||||
@@ -354,7 +355,8 @@ class SourceProvider {
|
|||||||
apk.apkUrls.length - 1,
|
apk.apkUrls.length - 1,
|
||||||
additionalSettings,
|
additionalSettings,
|
||||||
DateTime.now(),
|
DateTime.now(),
|
||||||
currentApp?.pinned ?? false);
|
currentApp?.pinned ?? false,
|
||||||
|
category: currentApp?.category);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns errors in [results, errors] instead of throwing them
|
// Returns errors in [results, errors] instead of throwing them
|
||||||
|
Reference in New Issue
Block a user