162 Start
parent
89a9a761d1
commit
ccefd0e0fa
@ -0,0 +1,43 @@
|
||||
enum Complexity {
|
||||
simple,
|
||||
challenging,
|
||||
hard,
|
||||
}
|
||||
|
||||
enum Affordability {
|
||||
affordable,
|
||||
pricey,
|
||||
luxurious,
|
||||
}
|
||||
|
||||
class Meal {
|
||||
const Meal({
|
||||
required this.id,
|
||||
required this.categories,
|
||||
required this.title,
|
||||
required this.imageUrl,
|
||||
required this.ingredients,
|
||||
required this.steps,
|
||||
required this.duration,
|
||||
required this.complexity,
|
||||
required this.affordability,
|
||||
required this.isGlutenFree,
|
||||
required this.isLactoseFree,
|
||||
required this.isVegan,
|
||||
required this.isVegetarian,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final List<String> categories;
|
||||
final String title;
|
||||
final String imageUrl;
|
||||
final List<String> ingredients;
|
||||
final List<String> steps;
|
||||
final int duration;
|
||||
final Complexity complexity;
|
||||
final Affordability affordability;
|
||||
final bool isGlutenFree;
|
||||
final bool isLactoseFree;
|
||||
final bool isVegan;
|
||||
final bool isVegetarian;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_navigation/widgets/meal_item.dart';
|
||||
|
||||
import '../models/meal.dart';
|
||||
|
||||
class MealsScreen extends StatelessWidget {
|
||||
const MealsScreen({super.key, required this.title, required this.meals});
|
||||
|
||||
final String title;
|
||||
final List<Meal> meals;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget content = Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Uh oh ... nothing here!',
|
||||
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Try selecting a different category!',
|
||||
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (meals.isNotEmpty) {
|
||||
content = ListView.builder(
|
||||
itemCount: meals.length,
|
||||
itemBuilder: (ctx, index) => MealItem(meal: meals[index]),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_navigation/models/meal.dart';
|
||||
import 'package:transparent_image/transparent_image.dart';
|
||||
|
||||
class MealItem extends StatelessWidget {
|
||||
const MealItem({
|
||||
super.key,
|
||||
required this.meal,
|
||||
});
|
||||
|
||||
final Meal meal;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.all(8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Stack(
|
||||
children: [
|
||||
FadeInImage(
|
||||
placeholder: MemoryImage(kTransparentImage),
|
||||
image: NetworkImage(meal.imageUrl),
|
||||
fit: BoxFit.cover,
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
color: Colors.black54,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
horizontal: 44,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
meal.title,
|
||||
maxLines: 2,
|
||||
textAlign: TextAlign.center,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue