initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_meals/models/category.dart';
|
||||
|
||||
class CategoryGridItem extends StatelessWidget {
|
||||
const CategoryGridItem({
|
||||
super.key,
|
||||
required this.category,
|
||||
required this.onSelectCategory,
|
||||
});
|
||||
|
||||
final Category category;
|
||||
final void Function() onSelectCategory;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onSelectCategory,
|
||||
splashColor: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
category.color.withOpacity(0.55),
|
||||
category.color.withOpacity(0.9),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
)),
|
||||
child: Text(
|
||||
category.title,
|
||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MainDrawer extends StatelessWidget {
|
||||
const MainDrawer({super.key, required this.onSelectScreen});
|
||||
|
||||
final void Function(String identifier) onSelectScreen;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: Column(
|
||||
children: [
|
||||
DrawerHeader(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
Theme.of(context)
|
||||
.colorScheme
|
||||
.primaryContainer
|
||||
.withOpacity(0.8),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.fastfood,
|
||||
size: 48,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 18),
|
||||
Text(
|
||||
'Cooking Up!',
|
||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.restaurant,
|
||||
size: 26,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
title: Text(
|
||||
'Meals',
|
||||
style: Theme.of(context).textTheme.titleSmall!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
onSelectScreen('meals');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.settings,
|
||||
size: 26,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
title: Text(
|
||||
'Filters',
|
||||
style: Theme.of(context).textTheme.titleSmall!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
onSelectScreen('filters');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:transparent_image/transparent_image.dart';
|
||||
|
||||
import 'package:flutter_meals/widgets/meal_item_trait.dart';
|
||||
import 'package:flutter_meals/models/meal.dart';
|
||||
|
||||
class MealItem extends StatelessWidget {
|
||||
const MealItem({
|
||||
super.key,
|
||||
required this.meal,
|
||||
required this.onSelectMeal,
|
||||
});
|
||||
|
||||
final Meal meal;
|
||||
final void Function(Meal meal) onSelectMeal;
|
||||
|
||||
String get complexityText {
|
||||
return meal.complexity.name[0].toUpperCase() +
|
||||
meal.complexity.name.substring(1);
|
||||
}
|
||||
|
||||
String get affordabilityText {
|
||||
return meal.affordability.name[0].toUpperCase() +
|
||||
meal.affordability.name.substring(1);
|
||||
}
|
||||
|
||||
@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: () {
|
||||
onSelectMeal(meal);
|
||||
},
|
||||
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, // Very long text ...
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
MealItemTrait(
|
||||
icon: Icons.schedule,
|
||||
label: '${meal.duration} min',
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
MealItemTrait(
|
||||
icon: Icons.work,
|
||||
label: complexityText,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
MealItemTrait(
|
||||
icon: Icons.attach_money,
|
||||
label: affordabilityText,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MealItemTrait extends StatelessWidget {
|
||||
const MealItemTrait({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 17,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user