You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
meals/lib/screens/filters.dart

95 lines
3.8 KiB
Dart

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../providers/filters_provider.dart';
class FiltersScreen extends ConsumerWidget {
const FiltersScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: AppBar(
title: const Text('Your filters'),
),
body: Column(
children: [
SwitchListTile(
value: ref.watch(filtersProvider)[Filter.glutenFree]!,
onChanged: (checked) => ref
.read(filtersProvider.notifier)
.setFilter(Filter.glutenFree, checked),
title: Text(
'Gluten free',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
subtitle: Text(
'Only includes 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: ref.watch(filtersProvider)[Filter.lactoseFree]!,
onChanged: (checked) => ref
.read(filtersProvider.notifier)
.setFilter(Filter.lactoseFree, checked),
title: Text(
'Lactose free',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
subtitle: Text(
'Only includes 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: ref.watch(filtersProvider)[Filter.veggie]!,
onChanged: (checked) => ref
.read(filtersProvider.notifier)
.setFilter(Filter.veggie, checked),
title: Text(
'Veggie',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
subtitle: Text(
'Only includes veggie 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: ref.watch(filtersProvider)[Filter.vegan]!,
onChanged: (checked) => ref
.read(filtersProvider.notifier)
.setFilter(Filter.vegan, checked),
title: Text(
'Vegan',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
subtitle: Text(
'Only includes 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),
)
],
));
}
}