|
|
|
|
@ -3,11 +3,21 @@ import 'package:flutter/material.dart';
|
|
|
|
|
// import 'package:flutter_navigation/screens/tabs.dart';
|
|
|
|
|
// import 'package:flutter_navigation/widgets/main_drawer.dart';
|
|
|
|
|
|
|
|
|
|
enum Filter {
|
|
|
|
|
glutenFree,
|
|
|
|
|
lactoseFree,
|
|
|
|
|
vegetarien,
|
|
|
|
|
vegan,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FiltersScreen extends StatefulWidget {
|
|
|
|
|
const FiltersScreen({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.currentFilters,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final Map<Filter, bool> currentFilters;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
|
return _FiltersScreenState();
|
|
|
|
|
@ -20,6 +30,16 @@ class _FiltersScreenState extends State<FiltersScreen> {
|
|
|
|
|
var _vegetarianFilterSet = false;
|
|
|
|
|
var _veganFilterSet = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
_glutenFilterSet = widget.currentFilters[Filter.glutenFree]!;
|
|
|
|
|
_lactoseFilterSet = widget.currentFilters[Filter.lactoseFree]!;
|
|
|
|
|
_vegetarianFilterSet = widget.currentFilters[Filter.vegetarien]!;
|
|
|
|
|
_veganFilterSet = widget.currentFilters[Filter.vegan]!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
@ -38,96 +58,107 @@ class _FiltersScreenState extends State<FiltersScreen> {
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
body: Column(children: [
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _glutenFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_glutenFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Gluten-free',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include gluten-free meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _lactoseFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_lactoseFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Lactose-free',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
body: WillPopScope(
|
|
|
|
|
onWillPop: () async {
|
|
|
|
|
Navigator.of(context).pop({
|
|
|
|
|
Filter.glutenFree: _glutenFilterSet,
|
|
|
|
|
Filter.lactoseFree: _lactoseFilterSet,
|
|
|
|
|
Filter.vegetarien: _vegetarianFilterSet,
|
|
|
|
|
Filter.vegan: _veganFilterSet,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
child: Column(children: [
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _glutenFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_glutenFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Gluten-free',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include gluten-free meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include lactose-free meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _lactoseFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_lactoseFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Lactose-free',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include lactose-free meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _vegetarianFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_vegetarianFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Vegetarian',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _vegetarianFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_vegetarianFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Vegetarian',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include vegetarian meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include vegetarian meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _veganFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_veganFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Vegan',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include vegan meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile(
|
|
|
|
|
value: _veganFilterSet,
|
|
|
|
|
onChanged: (isChecked) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_veganFilterSet = isChecked;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
title: Text(
|
|
|
|
|
'Vegan',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
'Only include vegan meals.',
|
|
|
|
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
activeColor: Theme.of(context).colorScheme.tertiary,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 34, right: 22),
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
]),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|