filtering works!
This commit is contained in:
@@ -119,6 +119,9 @@ class ListPage extends StatelessWidget {
|
||||
children: [
|
||||
TextField(
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
label: Text(Strings.quote)
|
||||
),
|
||||
controller: bodyController,
|
||||
),
|
||||
TextField(
|
||||
@@ -218,19 +221,21 @@ class ListPage extends StatelessWidget {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: provider.filterController,
|
||||
onChanged: (_) => provider.filterQuotes(),
|
||||
decoration: InputDecoration(
|
||||
label: Text(Strings.filterQuery),
|
||||
label: Text(
|
||||
'${Strings.filterQuery} – ${Strings.byAttribute} ${(provider.filterBy == 0) ? Strings.author : Strings.quote}'
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.cancel),
|
||||
onPressed: provider.clearFilterController
|
||||
)
|
||||
onPressed: () {
|
||||
provider.clearFilterController();
|
||||
provider.filterQuotes();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: provider.filterQuotes,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.more_horiz),
|
||||
onPressed: () {
|
||||
@@ -246,23 +251,83 @@ class ListPage extends StatelessWidget {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SizedBox(
|
||||
height: 300,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(Constants.edgeInset),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(Strings.filterBy),
|
||||
trailing: Icon(Icons.filter_alt),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(Strings.exportSelectedQuotes),
|
||||
trailing: Icon(Icons.import_export),
|
||||
),
|
||||
],
|
||||
)
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(Constants.edgeInset),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(Strings.filterBy),
|
||||
trailing: Icon(Icons.filter_alt),
|
||||
onTap: () {
|
||||
_showFilterOptionsBottomSheet(context, provider);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(Strings.exportSelectedQuotes),
|
||||
trailing: Icon(Icons.import_export),
|
||||
onTap: () {
|
||||
// TODO: trigger an os dialog FileSave
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showFilterOptionsBottomSheet(
|
||||
BuildContext context,
|
||||
QuoteProvider provider,
|
||||
) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(Constants.edgeInset),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text(Strings.author),
|
||||
leading: Radio<int>(
|
||||
value: 0,
|
||||
groupValue: provider.filterBy,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
provider.setFilterBy(value);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
provider.setFilterBy(0);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
title: const Text(Strings.quote),
|
||||
leading: Radio<int>(
|
||||
value: 1,
|
||||
groupValue: provider.filterBy,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
provider.setFilterBy(value);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
provider.setFilterBy(1);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user