From 5c4149b723ccf685e3a7065bebcacd6341571ed1 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 4 Jun 2020 00:41:06 +0530 Subject: Adds remove from favorites + context menu for favorites items --- lib/pages/Apps.dart | 47 +++++------------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'lib/pages/Apps.dart') diff --git a/lib/pages/Apps.dart b/lib/pages/Apps.dart index 7049799..8c61814 100644 --- a/lib/pages/Apps.dart +++ b/lib/pages/Apps.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:device_apps/device_apps.dart'; -import 'package:android_intent/android_intent.dart'; import '../components/FixedContainer.dart'; import '../components/SearchableAppList.dart'; @@ -32,52 +31,16 @@ class Option extends StatelessWidget { } class AppsView extends StatelessWidget { + void Function(Application) openApp; + void Function(BuildContext, Application) openOptionsMenu; + + AppsView({ this.openApp, this.openOptionsMenu }): super(); + Future> appListF = DeviceApps.getInstalledApplications( includeSystemApps: true, onlyAppsWithLaunchIntent: true, ); - void openApp(Application app) { - DeviceApps.openApp(app.packageName); - } - - void openOptionsMenu(BuildContext ctx, Application app) { - showDialog(context: ctx, builder: (BuildContext ctx) => buildOptionsMenu(ctx, app)); - } - - Widget buildOptionsMenu(BuildContext ctx, Application app) { - ThemeData theme = Theme.of(ctx); - - return Dialog( - child: Container( - decoration: BoxDecoration( - color: theme.backgroundColor, - ), - height: 170.0, - child: ListView( - children: [ - Option(child: Text('Add to favorites'), onTap: () async { - await addToFavorites(app); - }), - Option(child: Text('App Settings'), onTap: () async { - await AndroidIntent( - action: 'action_application_details_settings', - data: 'package:${app.packageName}', - ).launch(); - }), - Option(child: Text('Uninstall'), onTap: () async { - // FIXME: Doesn't work - await AndroidIntent( - action: 'action_delete', - data: 'package:${app.packageName}', - ).launch(); - }), - ], - ), - ), - ); - } - @override Widget build(BuildContext ctx) { return FixedContainer( -- cgit v1.3.1