fooder-app/lib/widgets/product.dart

65 lines
1.6 KiB
Dart
Raw Permalink Normal View History

2023-07-29 23:54:51 +02:00
import 'package:flutter/material.dart';
2023-07-30 15:31:36 +02:00
import 'package:fooder/models/product.dart';
import 'package:fooder/widgets/macro.dart';
2023-07-29 23:54:51 +02:00
import 'dart:core';
2024-04-04 19:03:41 +02:00
class ProductHeader extends StatelessWidget {
final String title;
const ProductHeader({super.key, required this.title});
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
title,
overflow: TextOverflow.fade,
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
),
),
],
);
}
}
2023-07-29 23:54:51 +02:00
class ProductWidget extends StatelessWidget {
final Product product;
const ProductWidget({super.key, required this.product});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(8),
child: Column(
children: <Widget>[
2024-04-04 19:03:41 +02:00
ProductHeader(
title: product.name,
),
const MacroHeaderWidget(
fiber: true,
calories: true,
alignment: Alignment.center,
2023-07-29 23:54:51 +02:00
),
2024-04-04 19:03:41 +02:00
MacroEntryWidget(
protein: product.protein,
carb: product.carb,
fat: product.fat,
2023-07-30 20:44:50 +02:00
fiber: product.fiber,
2024-04-04 19:03:41 +02:00
calories: product.calories,
alignment: Alignment.center,
2023-07-29 23:54:51 +02:00
),
],
),
);
}
}