mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 05:00:21 +02:00
Added uninstall option
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/main.dart';
|
||||
@@ -361,40 +362,12 @@ class _AppPageState extends State<AppPage> {
|
||||
onPressed: app?.downloadProgress != null
|
||||
? null
|
||||
: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(tr('removeAppQuestion')),
|
||||
content: Text(tr(
|
||||
'xWillBeRemovedButRemainInstalled',
|
||||
args: [
|
||||
app?.installedInfo?.name ??
|
||||
app?.app.name ??
|
||||
tr('app')
|
||||
])),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
HapticFeedback
|
||||
.selectionClick();
|
||||
appsProvider.removeApps(
|
||||
[app!.app.id]).then((_) {
|
||||
int count = 0;
|
||||
Navigator.of(context)
|
||||
.popUntil((_) =>
|
||||
count++ >= 2);
|
||||
});
|
||||
},
|
||||
child: Text(tr('remove'))),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('cancel')))
|
||||
],
|
||||
);
|
||||
});
|
||||
appsProvider.removeAppsWithModal(
|
||||
context, [app!.app]).then((value) {
|
||||
if (value == true) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor:
|
||||
@@ -414,3 +387,18 @@ class _AppPageState extends State<AppPage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveAppsModal extends StatefulWidget {
|
||||
const RemoveAppsModal({super.key, this.apps = const []});
|
||||
final List<App> apps;
|
||||
|
||||
@override
|
||||
State<RemoveAppsModal> createState() => _RemoveAppsModalState();
|
||||
}
|
||||
|
||||
class _RemoveAppsModalState extends State<RemoveAppsModal> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
|
@@ -389,28 +389,30 @@ class AppsPageState extends State<AppsPage> {
|
||||
onPressed: selectedApps.isEmpty
|
||||
? null
|
||||
: () {
|
||||
showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: tr(
|
||||
'removeSelectedAppsQuestion'),
|
||||
items: const [],
|
||||
initValid: true,
|
||||
message: tr(
|
||||
'xWillBeRemovedButRemainInstalled',
|
||||
args: [
|
||||
plural('apps',
|
||||
selectedApps.length)
|
||||
]),
|
||||
);
|
||||
}).then((values) {
|
||||
if (values != null) {
|
||||
appsProvider.removeApps(selectedApps
|
||||
.map((e) => e.id)
|
||||
.toList());
|
||||
}
|
||||
});
|
||||
appsProvider.removeAppsWithModal(
|
||||
context, selectedApps.toList());
|
||||
// showDialog<Map<String, dynamic>?>(
|
||||
// context: context,
|
||||
// builder: (BuildContext ctx) {
|
||||
// return GeneratedFormModal(
|
||||
// title: tr(
|
||||
// 'removeSelectedAppsQuestion'),
|
||||
// items: const [],
|
||||
// initValid: true,
|
||||
// message: tr(
|
||||
// 'xWillBeRemovedButRemainInstalled',
|
||||
// args: [
|
||||
// plural('apps',
|
||||
// selectedApps.length)
|
||||
// ]),
|
||||
// );
|
||||
// }).then((values) {
|
||||
// if (values != null) {
|
||||
// appsProvider.removeApps(selectedApps
|
||||
// .map((e) => e.id)
|
||||
// .toList());
|
||||
// }
|
||||
// });
|
||||
},
|
||||
tooltip: tr('removeSelectedApps'),
|
||||
icon: const Icon(Icons.delete_outline_outlined),
|
||||
|
Reference in New Issue
Block a user