aboutsummaryrefslogtreecommitdiff
path: root/lib/components/SearchableAppList.dart
blob: 8f9da2f828961624c6f595d27d72b05afcc16a15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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,
              );
            }
          )),
        ],
    );
  }
}