2023-05-30 21:03:46 +02:00
|
|
|
import 'package:ernaehrung/android/config/statistics.dart';
|
2023-05-29 12:08:46 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:percent_indicator/circular_percent_indicator.dart';
|
|
|
|
|
|
|
|
class CircularLoadingComponent extends StatelessWidget {
|
2023-06-02 00:38:19 +02:00
|
|
|
final int totalCalories;
|
|
|
|
const CircularLoadingComponent(this.totalCalories, {Key? key}) : super(key: key);
|
2023-05-29 12:08:46 +02:00
|
|
|
|
|
|
|
@override
|
2023-06-02 00:38:19 +02:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ValueListenableBuilder(
|
|
|
|
valueListenable: StatisticsService.instance.eatenCalories,
|
|
|
|
builder: (context, value, child) {
|
|
|
|
double progress =
|
|
|
|
double.parse((value / totalCalories).toStringAsFixed(1));
|
|
|
|
progress = progress > 1.0 ? 1.0 : progress;
|
2023-05-30 21:03:46 +02:00
|
|
|
|
2023-06-02 00:38:19 +02:00
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
CircularPercentIndicator(
|
|
|
|
animation: true,
|
|
|
|
radius: 60.0,
|
|
|
|
lineWidth: 5.0,
|
|
|
|
percent: progress,
|
|
|
|
center: Text(
|
|
|
|
"$value/$totalCalories Kcal",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
progressColor: Colors.lightGreen,
|
2023-05-30 21:03:46 +02:00
|
|
|
),
|
2023-06-02 00:38:19 +02:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2023-05-29 12:08:46 +02:00
|
|
|
}
|
2023-06-02 00:38:19 +02:00
|
|
|
}
|