diff options
| -rw-r--r-- | lib/components/AppList.dart | 47 | ||||
| -rw-r--r-- | lib/components/SearchableAppList.dart | 3 | ||||
| -rw-r--r-- | lib/main.dart | 1 | ||||
| -rw-r--r-- | lib/pages/Home.dart | 11 | ||||
| -rw-r--r-- | pubspec.lock | 25 |
5 files changed, 53 insertions, 34 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, ), )), ], diff --git a/pubspec.lock b/pubspec.lock index 5e65493..424e931 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,7 +14,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" boolean_selector: dependency: transitive description: @@ -22,6 +22,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0-nullsafety.2" charcode: dependency: transitive description: @@ -42,7 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.15.0-nullsafety.2" device_apps: dependency: "direct main" description: @@ -85,14 +92,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.9" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.2" path: dependency: transitive description: @@ -153,7 +160,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -181,21 +188,21 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.16" + version: "0.2.18" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.2" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.2" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.10.0-0.0.dev <2.10.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" |
