diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-11-13 20:13:01 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-11-13 20:13:01 +0530 |
| commit | 7382d42679d202cc0caa252026ebbd2d3cb1e202 (patch) | |
| tree | 71438568f4d2c2e8336fb3ba3c7b0685ece42cf6 /lib/components | |
| parent | 9ec12ef75ae742c0560591c48d14a44418038f79 (diff) | |
| download | daft-launcher-7382d42679d202cc0caa252026ebbd2d3cb1e202.tar.gz daft-launcher-7382d42679d202cc0caa252026ebbd2d3cb1e202.zip | |
testtest
Diffstat (limited to 'lib/components')
| -rw-r--r-- | lib/components/AppList.dart | 47 | ||||
| -rw-r--r-- | lib/components/SearchableAppList.dart | 3 |
2 files changed, 31 insertions, 19 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, )), ], ); |
