diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-06-05 21:55:06 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-06-05 21:55:06 +0530 |
| commit | f4fc9576aa77045d3b6c26263a7200af0c8b6151 (patch) | |
| tree | 5d139bb258ae60fb3d1371652ad6c884ead3abc9 /lib/components | |
| parent | 83be047e15efd91a26ac27da1710b0e273706b19 (diff) | |
| download | daft-launcher-f4fc9576aa77045d3b6c26263a7200af0c8b6151.tar.gz daft-launcher-f4fc9576aa77045d3b6c26263a7200af0c8b6151.zip | |
refactors application data to use streams
Diffstat (limited to 'lib/components')
| -rw-r--r-- | lib/components/SearchableAppList.dart | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/components/SearchableAppList.dart b/lib/components/SearchableAppList.dart index 249b763..d9c7a17 100644 --- a/lib/components/SearchableAppList.dart +++ b/lib/components/SearchableAppList.dart @@ -8,9 +8,6 @@ class _SearchableAppListState extends State<SearchableAppList> { void initState() { super.initState(); - _inputController.addListener(() { - - }); } void dispose() { @@ -40,6 +37,11 @@ class _SearchableAppListState extends State<SearchableAppList> { Widget build(BuildContext ctx) { ThemeData theme = Theme.of(context); + List<Application> results = widget.appList + .where(_filterApp) + .toList(); + results.sort(_appSorter); + return Column( children: [ Container( @@ -47,13 +49,10 @@ class _SearchableAppListState extends State<SearchableAppList> { child: Align( alignment: Alignment.topRight, child: TextField( - //onChanged: onInput, enableSuggestions: false, controller: _inputController, decoration: InputDecoration( contentPadding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0), - //prefix: Container(padding: , child: Text('')), - //prefixStyle: TextStyle(color: theme.primaryColor), hintStyle: TextStyle(color: Color(0x88D8DEE9)), hintText: 'Search', suffix: IconButton( @@ -64,24 +63,10 @@ class _SearchableAppListState extends State<SearchableAppList> { ) ), ), - Expanded(child: FutureBuilder( - future: widget.appListF, - builder: (ctx, AsyncSnapshot<List<Application>> snap) { - if (!snap.hasData) { - return Text('Loading...'); - } - - List<Application> results = snap.data - .where(_filterApp) - .toList(); - results.sort(_appSorter); - - return AppList( + Expanded(child: AppList( appList: results, openApp: widget.openApp, openOptionsMenu: widget.openOptionsMenu, - ); - } )), ], ); @@ -89,11 +74,11 @@ class _SearchableAppListState extends State<SearchableAppList> { } class SearchableAppList extends StatefulWidget { - Future<List<Application>> appListF; + List<Application> appList; void Function(Application) openApp; void Function(Application) openOptionsMenu; - SearchableAppList({ this.appListF, this.openApp, this.openOptionsMenu }): super(); + SearchableAppList({ this.appList, this.openApp, this.openOptionsMenu }): super(); @override _SearchableAppListState createState() => _SearchableAppListState(); |
