aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/components/AppList.dart47
-rw-r--r--lib/components/SearchableAppList.dart3
-rw-r--r--lib/main.dart1
-rw-r--r--lib/pages/Home.dart11
4 files changed, 37 insertions, 25 deletions
diff --git a/lib/components/AppList.dart b/lib/components/AppList.dart
index 5b54b04..d9fdd95 100644
--- a/lib/components/AppList.dart
+++ b/lib/components/AppList.dart
@@ -2,30 +2,43 @@ import 'package:flutter/material.dart';
import 'package:device_apps/device_apps.dart';
class AppList extends StatelessWidget {
- List<Application> appList;
- void Function(Application) openApp;
- void Function(Application) openOptionsMenu;
+ final List<Application> appList;
+ final void Function(Application) openApp;
+ final void Function(Application) openOptionsMenu;
+ final bool allowReorder;
- AppList({ this.appList, this.openApp, this.openOptionsMenu }): super();
+ AppList({ this.appList, this.openApp, this.openOptionsMenu, this.allowReorder = false }): super();
+
+ onReorder(int a, int b) {
+ //
+ }
+
+ Widget buildItem(Application app) {
+ return Container(
+ key: Key(app.packageName),
+ child: ListTile(
+ contentPadding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
+ dense: true,
+ title: Text('${app.appName}', style: const TextStyle(fontSize: 16)),
+ onTap: () => openApp(app),
+ onLongPress: () => !this.allowReorder ? openOptionsMenu(app) : null,
+ ),
+ );
+ }
@override
Widget build(BuildContext ctx) {
+ if (this.allowReorder) {
+ return ReorderableListView(
+ key: Key("reorderlist"),
+ onReorder: this.onReorder,
+ children: appList.map(this.buildItem).toList(),
+ );
+ }
return ListView.builder(
itemCount: appList.length,
itemBuilder: (ctx, index) {
- Application app = appList[index];
- return Column(
- children: [
- ListTile(
- contentPadding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
- dense: true,
- title: Text('${app.appName}', style: const TextStyle(fontSize: 16)),
- onTap: () => openApp(app),
- onLongPress: () => openOptionsMenu(app),
- ),
- Divider(height: 1.0),
- ],
- );
+ return this.buildItem(appList[index]);
},
);
}
diff --git a/lib/components/SearchableAppList.dart b/lib/components/SearchableAppList.dart
index 3ac0d25..7a8b651 100644
--- a/lib/components/SearchableAppList.dart
+++ b/lib/components/SearchableAppList.dart
@@ -35,8 +35,6 @@ class _SearchableAppListState extends State<SearchableAppList> {
@override
Widget build(BuildContext ctx) {
- ThemeData theme = Theme.of(context);
-
List<Application> results = widget.appList
.where(_filterApp)
.toList();
@@ -68,6 +66,7 @@ class _SearchableAppListState extends State<SearchableAppList> {
appList: results,
openApp: widget.openApp,
openOptionsMenu: widget.openOptionsMenu,
+ allowReorder: false,
)),
],
);
diff --git a/lib/main.dart b/lib/main.dart
index f7f3c06..c9b2f09 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -116,7 +116,6 @@ class MyAppState extends StreamState<MyApp> {
searchFieldFocus.requestFocus();
} else {
searchFieldFocus.unfocus();
- //SystemChannels.textInput.invokeMethod('TextInput.hide');
}
},
children: [
diff --git a/lib/pages/Home.dart b/lib/pages/Home.dart
index 0e3ff5e..2df9779 100644
--- a/lib/pages/Home.dart
+++ b/lib/pages/Home.dart
@@ -11,7 +11,7 @@ import '../data/applications.dart';
import '../data/favorites.dart';
class StatusInfoCard extends StatelessWidget {
- DateTime dateTime;
+ final DateTime dateTime;
StatusInfoCard({ this.dateTime }): super();
@@ -122,10 +122,10 @@ class StatusInfoCard extends StatelessWidget {
}
class HomeView extends StatelessWidget {
- DateTime dateTime;
- List<Application> favoriteApps;
- void Function(Application) openApp;
- void Function(BuildContext, Application) openOptionsMenu;
+ final DateTime dateTime;
+ final List<Application> favoriteApps;
+ final void Function(Application) openApp;
+ final void Function(BuildContext, Application) openOptionsMenu;
HomeView({ this.dateTime, this.favoriteApps, this.openApp, this.openOptionsMenu }): super();
@@ -141,6 +141,7 @@ class HomeView extends StatelessWidget {
appList: favoriteApps,
openApp: openApp,
openOptionsMenu: (app) => openOptionsMenu(ctx, app),
+ allowReorder: true,
),
)),
],