165 Start
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_navigation/models/meal.dart';
|
||||
import 'package:flutter_navigation/widgets/meal_item_trait.dart';
|
||||
import 'package:transparent_image/transparent_image.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) {
|
||||
@@ -20,7 +33,9 @@ class MealItem extends StatelessWidget {
|
||||
clipBehavior: Clip.hardEdge,
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
onSelectMeal(meal);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
FadeInImage(
|
||||
@@ -56,7 +71,17 @@ class MealItem extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [],
|
||||
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