aboutsummaryrefslogtreecommitdiff
path: root/lib/components
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-02 22:17:22 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-02 22:17:22 +0530
commitc285f8e733d448555209f95fd76eedbeef5d9e24 (patch)
treee28137a9fa79ba4c8e721df9877d0ee4671f4973 /lib/components
parentc60b58a16662fb33121e94b05cc1c868d8f3f16d (diff)
downloaddaft-launcher-c285f8e733d448555209f95fd76eedbeef5d9e24.tar.gz
daft-launcher-c285f8e733d448555209f95fd76eedbeef5d9e24.zip
Adds application list component in apps view
Diffstat (limited to '')
-rw-r--r--lib/components/AppList.dart33
-rw-r--r--lib/components/FixedContainer.dart34
-rw-r--r--lib/components/SearchableAppList.dart41
3 files changed, 108 insertions, 0 deletions
diff --git a/lib/components/AppList.dart b/lib/components/AppList.dart
index e69de29..5b54b04 100644
--- a/lib/components/AppList.dart
+++ b/lib/components/AppList.dart
@@ -0,0 +1,33 @@
+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;
+
+ AppList({ this.appList, this.openApp, this.openOptionsMenu }): super();
+
+ @override
+ Widget build(BuildContext ctx) {
+ 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),
+ ],
+ );
+ },
+ );
+ }
+}
+
diff --git a/lib/components/FixedContainer.dart b/lib/components/FixedContainer.dart
new file mode 100644
index 0000000..99db1c8
--- /dev/null
+++ b/lib/components/FixedContainer.dart
@@ -0,0 +1,34 @@
+import 'package:flutter/material.dart';
+import 'package:device_apps/device_apps.dart';
+
+import '../components/AppList.dart';
+
+class FixedContainer extends StatelessWidget {
+ EdgeInsets padding;
+ Widget child;
+
+ FixedContainer({ this.padding, this.child }): super();
+
+ @override
+ Widget build(BuildContext ctx) {
+ return LayoutBuilder(
+ builder: (BuildContext context, BoxConstraints viewportConstraints) {
+ return SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minHeight: viewportConstraints.maxHeight,
+ ),
+ child: IntrinsicHeight(
+ child: Container(
+ padding: padding,
+ height: viewportConstraints.maxHeight,
+ child: child,
+ )
+ ),
+ ),
+ );
+ }
+ );
+ }
+}
+
diff --git a/lib/components/SearchableAppList.dart b/lib/components/SearchableAppList.dart
index e69de29..8f9da2f 100644
--- a/lib/components/SearchableAppList.dart
+++ b/lib/components/SearchableAppList.dart
@@ -0,0 +1,41 @@
+import 'package:flutter/material.dart';
+import 'package:device_apps/device_apps.dart';
+
+import 'AppList.dart';
+
+class SearchableAppList extends StatelessWidget {
+ Future<List<Application>> appListF;
+ void Function(Application) openApp;
+ void Function(Application) openOptionsMenu;
+
+ SearchableAppList({ this.appListF, this.openApp, this.openOptionsMenu }): super();
+
+ int _appSorter(Application a, Application b) {
+ return a.appName.compareTo(b.appName);
+ }
+
+ @override
+ Widget build(BuildContext ctx) {
+ return Column(
+ children: [
+ Text('My text input'),
+ Expanded(child: FutureBuilder(
+ future: appListF,
+ builder: (ctx, AsyncSnapshot<List<Application>> snap) {
+ if (!snap.hasData) {
+ return Text('Loading...');
+ }
+
+ snap.data.sort(_appSorter);
+ return AppList(
+ appList: snap.data,
+ openApp: openApp,
+ openOptionsMenu: openOptionsMenu,
+ );
+ }
+ )),
+ ],
+ );
+ }
+}
+