fix: Uninstall button should always be shown

This commit is contained in:
Alberto Ponces
2022-09-22 09:46:28 +01:00
parent 733190e76c
commit 3d25655851
2 changed files with 54 additions and 52 deletions

View File

@ -104,52 +104,50 @@ class AppInfoView extends StatelessWidget {
), ),
), ),
), ),
if (app.isRooted) VerticalDivider(
VerticalDivider( color: Theme.of(context).canvasColor,
color: Theme.of(context).canvasColor, indent: 12.0,
indent: 12.0, endIndent: 12.0,
endIndent: 12.0, width: 1.0,
width: 1.0, ),
), Expanded(
if (app.isRooted) child: Material(
Expanded( type: MaterialType.transparency,
child: Material( child: InkWell(
type: MaterialType.transparency, borderRadius: BorderRadius.circular(16.0),
child: InkWell( onTap: () => model.showUninstallDialog(
borderRadius: BorderRadius.circular(16.0), context,
onTap: () => model.showUninstallDialog( app,
context, false,
app, ),
false, child: Column(
), mainAxisAlignment:
child: Column( MainAxisAlignment.center,
mainAxisAlignment: children: <Widget>[
MainAxisAlignment.center, Icon(
children: <Widget>[ Icons.delete_outline,
Icon( color: Theme.of(context)
Icons.delete_outline, .colorScheme
color: Theme.of(context) .primary,
.colorScheme ),
.primary, const SizedBox(height: 10),
), I18nText(
const SizedBox(height: 10), 'appInfoView.uninstallButton',
I18nText( child: Text(
'appInfoView.uninstallButton', '',
child: Text( style: TextStyle(
'', color: Theme.of(context)
style: TextStyle( .colorScheme
color: Theme.of(context) .primary,
.colorScheme fontWeight: FontWeight.bold,
.primary,
fontWeight: FontWeight.bold,
),
), ),
), ),
], ),
), ],
), ),
), ),
), ),
),
VerticalDivider( VerticalDivider(
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
indent: 12.0, indent: 12.0,

View File

@ -20,20 +20,26 @@ class AppInfoViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final RootAPI _rootAPI = RootAPI(); final RootAPI _rootAPI = RootAPI();
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async { Future<void> uninstallApp(
BuildContext context,
PatchedApplication app,
bool onlyUnpatch,
) async {
bool isUninstalled = true;
if (app.isRooted) { if (app.isRooted) {
bool hasRootPermissions = await _rootAPI.hasRootPermissions(); bool hasRootPermissions = await _rootAPI.hasRootPermissions();
if (hasRootPermissions) { if (hasRootPermissions) {
_rootAPI.deleteApp(app.packageName, app.apkFilePath); await _rootAPI.deleteApp(app.packageName, app.apkFilePath);
_managerAPI.deletePatchedApp(app);
if (!onlyUnpatch) { if (!onlyUnpatch) {
DeviceApps.uninstallApp(app.packageName); await DeviceApps.uninstallApp(app.packageName);
} }
} }
} else { } else {
DeviceApps.uninstallApp(app.packageName).then( isUninstalled = await DeviceApps.uninstallApp(app.packageName);
(value) => _managerAPI.deletePatchedApp(app), }
); if (isUninstalled) {
await _managerAPI.deletePatchedApp(app);
locator<HomeViewModel>().initialize(context);
} }
} }
@ -87,8 +93,7 @@ class AppInfoViewModel extends BaseViewModel {
CustomMaterialButton( CustomMaterialButton(
label: I18nText('yesButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
uninstallApp(app, onlyUnpatch); uninstallApp(context, app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@ -97,8 +102,7 @@ class AppInfoViewModel extends BaseViewModel {
), ),
); );
} else { } else {
uninstallApp(app, onlyUnpatch); uninstallApp(context, app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} }