2023-05-29 12:08:46 +02:00
|
|
|
import 'package:ernaehrung/android/components/meal_page_text/days_text_component.dart';
|
2023-05-30 09:38:54 +02:00
|
|
|
import 'package:ernaehrung/android/config/statistics.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
enum TimeSpan {
|
|
|
|
day,
|
|
|
|
week,
|
|
|
|
month
|
|
|
|
}
|
2023-05-29 12:08:46 +02:00
|
|
|
|
|
|
|
|
2023-05-30 09:38:54 +02:00
|
|
|
class DaysMealPageComponent extends StatefulWidget {
|
2023-05-29 12:08:46 +02:00
|
|
|
const DaysMealPageComponent({Key? key}) : super(key: key);
|
2023-05-30 09:38:54 +02:00
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _DaysMealPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _DaysMealPageState extends State<DaysMealPageComponent> {
|
|
|
|
int activatedIndex = 0;
|
|
|
|
|
|
|
|
void updateValue(int index) {
|
|
|
|
setState(() {
|
|
|
|
activatedIndex = index;
|
|
|
|
if(activatedIndex == 0){
|
2023-06-01 12:14:23 +02:00
|
|
|
StatisticsService.instance.updateReducedBoxByTimespan(TimeSpan.day);
|
2023-05-30 09:38:54 +02:00
|
|
|
}else if(activatedIndex == 1){
|
2023-06-01 12:14:23 +02:00
|
|
|
StatisticsService.instance.updateReducedBoxByTimespan(TimeSpan.week);
|
2023-05-30 09:38:54 +02:00
|
|
|
}else if(activatedIndex == 2){
|
2023-06-01 12:14:23 +02:00
|
|
|
StatisticsService.instance.updateReducedBoxByTimespan(TimeSpan.month);
|
2023-05-30 09:38:54 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-05-29 12:08:46 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
2023-05-30 09:38:54 +02:00
|
|
|
DaysTextComponent(
|
|
|
|
timeSpan: TimeSpan.day,
|
|
|
|
textColor: activatedIndex == 0
|
|
|
|
? const Color(0xff47a44b)
|
|
|
|
: const Color(0xff000000),
|
|
|
|
onPressed: updateValue,
|
|
|
|
index: 0
|
|
|
|
|
|
|
|
),
|
|
|
|
DaysTextComponent(
|
|
|
|
timeSpan: TimeSpan.week,
|
|
|
|
textColor: activatedIndex == 1
|
|
|
|
? const Color(0xff47a44b)
|
|
|
|
: const Color(0xff000000),
|
|
|
|
onPressed: updateValue,
|
|
|
|
index: 1
|
|
|
|
),
|
|
|
|
DaysTextComponent(
|
|
|
|
timeSpan: TimeSpan.month,
|
|
|
|
textColor: activatedIndex == 2
|
|
|
|
? const Color(0xff47a44b)
|
|
|
|
: const Color(0xff000000),
|
|
|
|
onPressed: updateValue,
|
|
|
|
index: 2
|
|
|
|
),
|
2023-05-29 12:08:46 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-05-30 09:38:54 +02:00
|
|
|
|