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