diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/level_selection.dart | 66 | 
1 files changed, 46 insertions, 20 deletions
| diff --git a/lib/level_selection.dart b/lib/level_selection.dart index 33d8c8b..3d3a95a 100644 --- a/lib/level_selection.dart +++ b/lib/level_selection.dart @@ -20,6 +20,8 @@ class LevelSelection extends StatefulWidget {  class _LevelSelectionState extends State<LevelSelection> {    String? stepmaniaCoursesPath;    List<Simfile> stepmaniaCoursesFolders = []; +  List<Simfile> stepmaniaCoursesFoldersFiltered = []; +  String searchString = '';    @override    void initState() { @@ -27,7 +29,6 @@ class _LevelSelectionState extends State<LevelSelection> {      loadFolderPath();    } -    Future<void> loadFolderPath() async {      SharedPreferences prefs = await SharedPreferences.getInstance();      final String? stepmaniaCoursesPathSetting = @@ -40,6 +41,7 @@ class _LevelSelectionState extends State<LevelSelection> {      setState(() {        stepmaniaCoursesPath = stepmaniaCoursesPathSetting;        stepmaniaCoursesFolders = stepmaniaCoursesFoldersFuture; +      stepmaniaCoursesFoldersFiltered = stepmaniaCoursesFoldersFuture;      });    } @@ -68,7 +70,7 @@ class _LevelSelectionState extends State<LevelSelection> {          simfile.load();          return simfile;        }).toList(); -      simfiles.sort((a,b) => a.tags['TITLE']!.compareTo(b.tags['TITLE']!)); +      simfiles.sort((a, b) => a.tags['TITLE']!.compareTo(b.tags['TITLE']!));        return simfiles;      } catch (e) { @@ -104,24 +106,48 @@ class _LevelSelectionState extends State<LevelSelection> {            return Text(                'Folder empty. Add Stepmania Songs to Folder or select a different folder on \'+\'');          } else { -          return ListView.separated( -            itemCount: stepmaniaCoursesFolders.length, -            separatorBuilder: (BuildContext context, int index) => -                const Divider(), -            itemBuilder: (context, index) { -              return ListTile( -                leading: Image.file( -                    File(stepmaniaCoursesFolders[index].bannerPath!)), -                trailing: Icon(Icons.play_arrow), -                title: Text(stepmaniaCoursesFolders[index].tags["TITLE"]!), -                subtitle: Text('3:45'), -                onTap: () => Navigator.push( -                    context, -                    MaterialPageRoute( -                        builder: (BuildContext context) => -                            Level(stepmaniaCoursesFolders[index]))), -              ); -            }, +          return Column( +            children: [ +              Padding( +                padding: +                    const EdgeInsets.symmetric(horizontal: 16.0, vertical: 0.0), +                child: TextField( +                  onChanged: (input) { +                    setState(() { +                      stepmaniaCoursesFoldersFiltered = stepmaniaCoursesFolders +                          .where((simfile) => simfile.tags["TITLE"]! +                              .toLowerCase() +                              .contains(input.toLowerCase())) +                          .toList(); +                    }); +                  }, +                  decoration: InputDecoration( +                      // icon: Icon(Icons.search), +                      hintText: 'Search'), +                ), +              ), +              Expanded( +                child: ListView.separated( +                  itemCount: stepmaniaCoursesFoldersFiltered.length, +                  separatorBuilder: (BuildContext context, int index) => +                      const Divider(), +                  itemBuilder: (context, index) { +                    Simfile simfile = stepmaniaCoursesFoldersFiltered[index]; +                    return ListTile( +                      leading: Image.file(File(simfile.bannerPath!)), +                      trailing: Icon(Icons.play_arrow), +                      title: Text(simfile.tags["TITLE"]!), +                      subtitle: Text('3:45'), +                      onTap: () => Navigator.push( +                          context, +                          MaterialPageRoute( +                              builder: (BuildContext context) => +                                  Level(simfile))), +                    ); +                  }, +                ), +              ), +            ],            );          }        }), | 
