optimierung
parent
c91f3901dd
commit
a989878cca
|
@ -14,7 +14,7 @@ class AndroidApp extends StatelessWidget {
|
|||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
scaffoldBackgroundColor: Colors.grey.shade100, //<-- SEE
|
||||
scaffoldBackgroundColor: Colors.grey.shade200, //<-- SEE
|
||||
),
|
||||
home: box.get("USER") == null ? const OnboardingPage() : const MainPage(),
|
||||
routes: {
|
||||
|
|
|
@ -45,12 +45,9 @@ class CardComponent extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 300,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF6E7BFB),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF6E7BFB),
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
margin: const EdgeInsets.fromLTRB(0, 16, 0, 16),
|
||||
child: Column(
|
||||
|
|
|
@ -11,7 +11,10 @@ class CardComponent extends StatefulWidget {
|
|||
final bool addButtonVisible;
|
||||
|
||||
const CardComponent(
|
||||
{Key? key, required this.eatingMealName, required this.selectedMeal, this.addButtonVisible = true})
|
||||
{Key? key,
|
||||
required this.eatingMealName,
|
||||
required this.selectedMeal,
|
||||
this.addButtonVisible = true})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -40,11 +43,14 @@ class _CardComponentState extends State<CardComponent> {
|
|||
}
|
||||
|
||||
getImageOfMeal() {
|
||||
if (widget.eatingMealName.toLowerCase() == dotenv.env['BREAKFAST_FIELD']!.toLowerCase()) {
|
||||
if (widget.eatingMealName.toLowerCase() ==
|
||||
dotenv.env['BREAKFAST_FIELD']!.toLowerCase()) {
|
||||
return const Image(image: AssetImage('assets/images/tea.png'));
|
||||
} else if (widget.eatingMealName.toLowerCase() == dotenv.env['LUNCH_FIELD']!.toLowerCase()) {
|
||||
} else if (widget.eatingMealName.toLowerCase() ==
|
||||
dotenv.env['LUNCH_FIELD']!.toLowerCase()) {
|
||||
return const Image(image: AssetImage('assets/images/fries.png'));
|
||||
} else if (widget.eatingMealName.toLowerCase() == dotenv.env['DINNER_FIELD']!.toLowerCase()) {
|
||||
} else if (widget.eatingMealName.toLowerCase() ==
|
||||
dotenv.env['DINNER_FIELD']!.toLowerCase()) {
|
||||
return const Image(image: AssetImage('assets/images/ice.png'));
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +83,6 @@ class _CardComponentState extends State<CardComponent> {
|
|||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int getCountedCalories() {
|
||||
|
@ -94,22 +99,14 @@ class _CardComponentState extends State<CardComponent> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.fromLTRB(0, 24, 0, 0),
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(0, 16, 0, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
getImageOfMeal(),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.6,
|
||||
child: Text(
|
||||
Text(
|
||||
StringUtils.capitalize(widget.eatingMealName),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
@ -119,35 +116,35 @@ class _CardComponentState extends State<CardComponent> {
|
|||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
getElevatedButton(),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
width: MediaQuery.of(context).size.width * 1,
|
||||
child: ListView.builder(
|
||||
primary: false,
|
||||
shrinkWrap: true,
|
||||
itemCount: getMapOfDistinctElementsWithCounterAndCalories(widget.selectedMeal).keys.length,
|
||||
itemCount: getMapOfDistinctElementsWithCounterAndCalories(
|
||||
widget.selectedMeal)
|
||||
.keys
|
||||
.length,
|
||||
itemBuilder: (context, i) {
|
||||
Map<String,List<int>> map = getMapOfDistinctElementsWithCounterAndCalories(widget.selectedMeal);
|
||||
Map<String, List<int>> map =
|
||||
getMapOfDistinctElementsWithCounterAndCalories(
|
||||
widget.selectedMeal);
|
||||
String foodName = map.keys.elementAt(i);
|
||||
List<int> values = map.values.elementAt(i);
|
||||
return Text(
|
||||
getFoodListStringByFood(foodName, values[0], values[1])
|
||||
);
|
||||
}
|
||||
),
|
||||
return Text(getFoodListStringByFood(
|
||||
foodName, values[0], values[1]));
|
||||
}),
|
||||
),
|
||||
widget.selectedMeal.isNotEmpty
|
||||
? const Divider()
|
||||
: const SizedBox.shrink(),
|
||||
widget.selectedMeal.isNotEmpty
|
||||
? Text("${getCountedCalories()} kcal")
|
||||
? Column(
|
||||
children: [
|
||||
const Divider(),
|
||||
Text("${getCountedCalories()} kcal")
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
));
|
||||
|
|
|
@ -10,17 +10,18 @@ class MealPageStatisticsFoodComponent extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(0, 16, 0, 0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white
|
||||
),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
const TitleComponent("Nahrung"),
|
||||
FoodComponent(box: Hive.box(StatisticsService.instance.todayStatisticsBoxName),)
|
||||
FoodComponent(
|
||||
box: Hive.box(StatisticsService.instance.todayStatisticsBoxName),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -34,9 +34,7 @@ class _DaysMealPageState extends State<DaysMealPageComponent> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
|
||||
child: Row(
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
DaysTextComponent(
|
||||
|
@ -65,7 +63,6 @@ class _DaysMealPageState extends State<DaysMealPageComponent> {
|
|||
index: 2
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ class StatisticsPercentage extends StatelessWidget {
|
|||
valueListenable: StatisticsService.instance.ingredients,
|
||||
builder: (context, value, child) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 2.0, color: Colors.black)),
|
||||
height: heightStatisticsContainer,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 0),
|
||||
child: Row(
|
||||
|
|
|
@ -36,9 +36,12 @@ class MainPageState extends State<MainPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: false,
|
||||
appBar: AppBar(
|
||||
title: Text(pages[currentIndex].title),
|
||||
backgroundColor: Colors.grey.shade100,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.grey.shade400,
|
||||
elevation: 0,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 8),
|
||||
|
|
|
@ -24,16 +24,28 @@ class _MealPlanState extends State<MealPlanPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
body: SizedBox(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 16),
|
||||
child: Column(
|
||||
children: const [
|
||||
DaysMealPageComponent(),
|
||||
StatisticsPercentage(),
|
||||
MealPageStatisticsFoodComponent(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const MealPageStatisticsFoodComponent(),
|
||||
],
|
||||
),
|
||||
)));
|
||||
|
|
|
@ -20,19 +20,24 @@ class ProgressPage extends StatelessWidget {
|
|||
return getTitle;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: in versch. Dateien auslagern, damit der Code nicht voll gemüllt wird
|
||||
* */
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
ValueListenableBuilder(
|
||||
valueListenable: StatisticsService.instance.dailyAverageForCurrentWeek,
|
||||
valueListenable: StatisticsService
|
||||
.instance.dailyAverageForCurrentWeek,
|
||||
builder: (context, value, child) {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
|
@ -40,86 +45,111 @@ class ProgressPage extends StatelessWidget {
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TitleComponent("Täglicher Durchschnitt (in kcal)"),
|
||||
const TitleComponent("Kalorien"),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const SecondaryTextComponent("Durchschnittlich"),
|
||||
SecondaryBigTextComponent("${value.toString()} kcal/Tag"),
|
||||
const SecondaryTextComponent(
|
||||
"Durchschnittlich"),
|
||||
SecondaryBigTextComponent(
|
||||
"${value.toString()} kcal/Tag"),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: StatisticsService.instance.barChartData,
|
||||
valueListenable:
|
||||
StatisticsService.instance.barChartData,
|
||||
builder: (context, value, child) {
|
||||
return SizedBox(
|
||||
height: 325,
|
||||
height: 300,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 15, // Adjust the height of the legend as needed
|
||||
height: 15,
|
||||
// Adjust the height of the legend as needed
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0),
|
||||
// Adjust the spacing between legend items
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red, // Use the color of the first bar rod for the legend item
|
||||
color: Colors.red,
|
||||
// Use the color of the first bar rod for the legend item
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
|
||||
const SizedBox(width: 4.0),
|
||||
// Adjust the spacing between the color indicator and the legend label
|
||||
const Text(
|
||||
'Frühstück', // Replace with your desired legend label
|
||||
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
|
||||
'Frühstück',
|
||||
// Replace with your desired legend label
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
12), // Adjust the font size of the legend labels
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0),
|
||||
// Adjust the spacing between legend items
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.green, // Use the color of the first bar rod for the legend item
|
||||
color: Colors.green,
|
||||
// Use the color of the first bar rod for the legend item
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
|
||||
const SizedBox(width: 4.0),
|
||||
// Adjust the spacing between the color indicator and the legend label
|
||||
const Text(
|
||||
'Mittagessen', // Replace with your desired legend label
|
||||
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
|
||||
'Mittagessen',
|
||||
// Replace with your desired legend label
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
12), // Adjust the font size of the legend labels
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0),
|
||||
// Adjust the spacing between legend items
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.yellow, // Use the color of the first bar rod for the legend item
|
||||
color: Colors.yellow,
|
||||
// Use the color of the first bar rod for the legend item
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
|
||||
const SizedBox(width: 4.0),
|
||||
// Adjust the spacing between the color indicator and the legend label
|
||||
const Text(
|
||||
'Abendessen', // Replace with your desired legend label
|
||||
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
|
||||
'Abendessen',
|
||||
// Replace with your desired legend label
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
12), // Adjust the font size of the legend labels
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -127,9 +157,9 @@ class ProgressPage extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top:50.0), // Adjust the margin value as needed
|
||||
child: SizedBox(
|
||||
Container(
|
||||
margin:
|
||||
const EdgeInsets.fromLTRB(0, 24, 0, 0),
|
||||
height: 250,
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
|
@ -142,38 +172,52 @@ class ProgressPage extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: StatisticsService.instance.weeklyCaloryRanking,
|
||||
],
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
margin: const EdgeInsets.fromLTRB(0, 16, 0, 0),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable:
|
||||
StatisticsService.instance.weeklyCaloryRanking,
|
||||
builder: (context, value, child) {
|
||||
return Column(
|
||||
//TODO: Loop through the values and display them dynamically
|
||||
children: [
|
||||
const TitleComponent("Lebensmittel mit dem höchsten Kaloriengehalt"),
|
||||
const SizedBox(height: 24,),
|
||||
const TitleComponent(
|
||||
"Lebensmittel mit dem höchsten Kaloriengehalt"),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
for (var item in value.toSet())
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SecondaryTextComponent(getWeeklyRankingString(item.name)),
|
||||
SecondaryTextComponent(item.calories.toString()),
|
||||
SecondaryTextComponent(
|
||||
getWeeklyRankingString(item.name)),
|
||||
SecondaryTextComponent(
|
||||
item.calories.toString()),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
BarTouchData get barTouchData => BarTouchData(
|
||||
|
@ -262,9 +306,11 @@ class ProgressPage extends StatelessWidget {
|
|||
getTitlesWidget: (value, _) {
|
||||
// Return a custom widget for each axis value
|
||||
return Container(
|
||||
constraints: const BoxConstraints.tightFor(width: double.infinity),
|
||||
constraints:
|
||||
const BoxConstraints.tightFor(width: double.infinity),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 3.0), // Adjust the margin value as needed
|
||||
padding: const EdgeInsets.only(right: 3.0),
|
||||
// Adjust the margin value as needed
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
|
@ -280,16 +326,14 @@ class ProgressPage extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
);
|
||||
));
|
||||
|
||||
FlBorderData get borderData => FlBorderData(
|
||||
show: true, // Set to true to display the chart border
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.black, width: 1),
|
||||
left: BorderSide(color: Colors.black, width: 1),// Hide the left border
|
||||
left:
|
||||
BorderSide(color: Colors.black, width: 1), // Hide the left border
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,9 +23,7 @@ void main() async {
|
|||
await Hive.openBox(dotenv.env['STATISTICS_MAIN_BOX'] ?? 'STATISTICS_MAIN_BOX');
|
||||
await Hive.openBox(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN');
|
||||
await Hive.openBox<User>('USER_BOX');
|
||||
//Hive.deleteFromDisk();
|
||||
setupTodayBox();
|
||||
//mockDataForWholeWeek();
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
runApp(const AndroidApp());
|
||||
|
|
Loading…
Reference in New Issue