162 Start
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_navigation/data/dummy_data.dart';
|
||||
import 'package:flutter_navigation/screens/meals.dart';
|
||||
|
||||
import '../models/category.dart';
|
||||
import '../widgets/category_grid_item.dart';
|
||||
|
||||
class CategoriesScreen extends StatelessWidget {
|
||||
const CategoriesScreen({super.key});
|
||||
|
||||
void _selectCategory(BuildContext context, Category category) {
|
||||
final filteredMeals = dummyMeals.where((meal) => meal.categories.contains(category.id)).toList();
|
||||
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (ctx) => MealsScreen(
|
||||
title: category.title,
|
||||
meals: filteredMeals,
|
||||
),
|
||||
),
|
||||
); //Navigator.push(context, route);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -22,7 +37,12 @@ class CategoriesScreen extends StatelessWidget {
|
||||
),
|
||||
children: [
|
||||
for (final category in availableCategories)
|
||||
CategoryGridItem(category: category)
|
||||
CategoryGridItem(
|
||||
category: category,
|
||||
onSelectCategory: () {
|
||||
_selectCategory(context, category);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user