75 lines
2.2 KiB
Dart
75 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:percent_indicator/linear_percent_indicator.dart';
|
|
|
|
class DietChatComponent extends StatefulWidget {
|
|
final double fatPercentPerThousandCalorie = 3.7;
|
|
final double proteinPercentPerThousandCalorie = 4.5;
|
|
final double carbsPercentPerThousandCalorie = 12.8;
|
|
|
|
final String carbs = "Kohlenhydrate";
|
|
final String protein = "Protein";
|
|
final String fat = "Fett";
|
|
|
|
late String fatGramm, carbGramm, proteinGramm = "";
|
|
late double fatSummary, carbSummary, proteinSummary = 0.0;
|
|
|
|
DietChatComponent(int calorienSummary, {super.key, int calorienLeft = 0}){
|
|
fatSummary = (calorienSummary / 100) * fatPercentPerThousandCalorie;
|
|
carbSummary = (calorienSummary / 100) * carbsPercentPerThousandCalorie;
|
|
proteinSummary = (calorienSummary / 100) * proteinPercentPerThousandCalorie;
|
|
fatGramm = '0 / $fatSummary g';
|
|
carbGramm = '0 / $carbSummary g';
|
|
proteinGramm = '0 / $proteinSummary g';
|
|
}
|
|
|
|
@override
|
|
State<DietChatComponent> createState() => _DietChatComponentState();
|
|
}
|
|
|
|
class _DietChatComponentState extends State<DietChatComponent> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Text(widget.carbs),
|
|
LinearPercentIndicator(
|
|
width: 100.0,
|
|
lineHeight: 8.0,
|
|
percent: 0.9,
|
|
progressColor: Colors.blue,
|
|
),
|
|
Text(widget.carbGramm)
|
|
],
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(widget.protein),
|
|
LinearPercentIndicator(
|
|
width: 100.0,
|
|
lineHeight: 8.0,
|
|
percent: 0.9,
|
|
progressColor: Colors.blue,
|
|
),
|
|
Text(widget.proteinGramm)
|
|
],
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(widget.fat),
|
|
LinearPercentIndicator(
|
|
width: 100.0,
|
|
lineHeight: 8.0,
|
|
percent: 0.9,
|
|
progressColor: Colors.blue,
|
|
),
|
|
Text(widget.fatGramm)
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|