aboutsummaryrefslogtreecommitdiff
path: root/lib/components/AppList.dart
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-11-13 20:13:01 +0530
committerAkshay Nair <phenax5@gmail.com>2020-11-13 20:13:01 +0530
commit7382d42679d202cc0caa252026ebbd2d3cb1e202 (patch)
tree71438568f4d2c2e8336fb3ba3c7b0685ece42cf6 /lib/components/AppList.dart
parent9ec12ef75ae742c0560591c48d14a44418038f79 (diff)
downloaddaft-launcher-7382d42679d202cc0caa252026ebbd2d3cb1e202.tar.gz
daft-launcher-7382d42679d202cc0caa252026ebbd2d3cb1e202.zip
testtest
Diffstat (limited to 'lib/components/AppList.dart')
-rw-r--r--lib/components/AppList.dart47
1 files changed, 30 insertions, 17 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]);
},
);
}