From fe5cebca2be3bff2e9acea13fab2a4d8f706e02f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 2 Jun 2020 22:31:27 +0530 Subject: Simple text field added --- lib/components/SearchableAppList.dart | 39 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'lib/components') diff --git a/lib/components/SearchableAppList.dart b/lib/components/SearchableAppList.dart index 8f9da2f..820759d 100644 --- a/lib/components/SearchableAppList.dart +++ b/lib/components/SearchableAppList.dart @@ -3,12 +3,12 @@ import 'package:device_apps/device_apps.dart'; import 'AppList.dart'; -class SearchableAppList extends StatelessWidget { - Future> appListF; - void Function(Application) openApp; - void Function(Application) openOptionsMenu; - - SearchableAppList({ this.appListF, this.openApp, this.openOptionsMenu }): super(); +class _SearchableAppListState extends State { + String _searchTerm = ''; + + void onInput(String str) { + setState(() { _searchTerm = str; }); + } int _appSorter(Application a, Application b) { return a.appName.compareTo(b.appName); @@ -18,9 +18,17 @@ class SearchableAppList extends StatelessWidget { Widget build(BuildContext ctx) { return Column( children: [ - Text('My text input'), + Container( + height: 100, + child: TextField( + decoration: InputDecoration( + border: InputBorder.none, + hintText: 'Enter a search term', + ), + ), + ), Expanded(child: FutureBuilder( - future: appListF, + future: widget.appListF, builder: (ctx, AsyncSnapshot> snap) { if (!snap.hasData) { return Text('Loading...'); @@ -29,8 +37,8 @@ class SearchableAppList extends StatelessWidget { snap.data.sort(_appSorter); return AppList( appList: snap.data, - openApp: openApp, - openOptionsMenu: openOptionsMenu, + openApp: widget.openApp, + openOptionsMenu: widget.openOptionsMenu, ); } )), @@ -39,3 +47,14 @@ class SearchableAppList extends StatelessWidget { } } +class SearchableAppList extends StatefulWidget { + Future> appListF; + void Function(Application) openApp; + void Function(Application) openOptionsMenu; + + SearchableAppList({ this.appListF, this.openApp, this.openOptionsMenu }): super(); + + @override + _SearchableAppListState createState() => _SearchableAppListState(); +} + -- cgit v1.3.1