174 Start

This commit is contained in:
2024-03-08 13:44:56 +01:00
parent 03bb6f5b8f
commit 4d170f524c
3 changed files with 203 additions and 16 deletions
+133
View File
@@ -0,0 +1,133 @@
import 'package:flutter/material.dart';
// import 'package:flutter_navigation/screens/tabs.dart';
// import 'package:flutter_navigation/widgets/main_drawer.dart';
class FiltersScreen extends StatefulWidget {
const FiltersScreen({
super.key,
});
@override
State<StatefulWidget> createState() {
return _FiltersScreenState();
}
}
class _FiltersScreenState extends State<FiltersScreen> {
var _glutenFilterSet = false;
var _lactoseFilterSet = false;
var _vegetarianFilterSet = false;
var _veganFilterSet = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Your Filters'),
),
// drawer: MainDrawer(
// onSelectScreen: (identifier) {
// Navigator.of(context).pop();
// if (identifier == 'meals') {
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(
// builder: (ctx) => const TabsScreen(),
// ),
// );
// }
// },
// ),
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,
),
),
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),
),
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),
),
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),
),
]),
);
}
}
+15 -1
View File
@@ -4,6 +4,7 @@ import 'package:flutter_navigation/screens/meals.dart';
import 'package:flutter_navigation/widgets/main_drawer.dart';
import '../models/meal.dart';
import 'filters.dart';
class TabsScreen extends StatefulWidget {
const TabsScreen({super.key});
@@ -45,6 +46,17 @@ class _TabsScreenState extends State<TabsScreen> {
});
}
void _setScreen(String identifier) {
Navigator.of(context).pop();
if (identifier == 'filters') {
Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => const FiltersScreen(),
),
);
}
}
@override
Widget build(BuildContext context) {
Widget activePage = CategoriesScreen(
@@ -64,7 +76,9 @@ class _TabsScreenState extends State<TabsScreen> {
appBar: AppBar(
title: Text(activePageTitle),
),
drawer: const MainDrawer(),
drawer: MainDrawer(
onSelectScreen: _setScreen,
),
body: activePage,
bottomNavigationBar: BottomNavigationBar(
onTap: _selectPage,