aboutsummaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens/dashboard/widgets/circle_indicator.dart
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:20:58 -0300
committerLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:31:12 -0300
commit70ec8a79a121471a004e7e4c23157d10157e136f (patch)
treea4f9c0a4fac4e4274ec4324a289b6ef62e1c5653 /lib/presentation/screens/dashboard/widgets/circle_indicator.dart
Initial cleanup push.
Based on agldemo2024 on commit 2a5dc04d801134338150c3f6afc67eaa65599763 Disable device preview. Disable Lottie animation. The original commit was b3c493c340fcb4bb0a937692838fc830bec3e9ea but I am just keeping this change, because the json did not really needed to change. I think. Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/presentation/screens/dashboard/widgets/circle_indicator.dart')
-rw-r--r--lib/presentation/screens/dashboard/widgets/circle_indicator.dart305
1 files changed, 305 insertions, 0 deletions
diff --git a/lib/presentation/screens/dashboard/widgets/circle_indicator.dart b/lib/presentation/screens/dashboard/widgets/circle_indicator.dart
new file mode 100644
index 0000000..7a4e724
--- /dev/null
+++ b/lib/presentation/screens/dashboard/widgets/circle_indicator.dart
@@ -0,0 +1,305 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+import 'custom_circle.dart';
+
+class RPMProgressIndicator extends ConsumerStatefulWidget {
+ const RPMProgressIndicator({super.key});
+
+ @override
+ RPMProgressIndicatorState createState() => RPMProgressIndicatorState();
+}
+
+class RPMProgressIndicatorState extends ConsumerState<RPMProgressIndicator>
+ with TickerProviderStateMixin {
+ late AnimationController controller;
+
+ @override
+ void initState() {
+ controller = AnimationController(
+ /// [AnimationController]s can be created with `vsync: this` because of
+ /// [TickerProviderStateMixin].
+ vsync: this,
+ duration: const Duration(seconds: 5),
+ )..addListener(() {
+ //setState(() {});
+ });
+ controller.repeat(reverse: true);
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final rpm =
+ ref.watch(vehicleProvider.select((vehicle) => vehicle.engineSpeed));
+ return Column(
+ children: [
+ SizedBox(
+ height: 252,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+
+ Text(
+ rpm.toString(),
+ style: GoogleFonts.brunoAce(
+ textStyle: const TextStyle(color: Colors.white, fontSize: 44),
+ ),
+ ),
+ Stack(
+ children: [
+ if (rpm > 6500)
+ SizedBox(
+ height: 200,
+ width: 200,
+ child: CircularProgressIndicator(
+ strokeWidth: 12,
+ backgroundColor: Colors.transparent,
+ //value: controller.value,
+ valueColor: const AlwaysStoppedAnimation<Color>(
+ AGLDemoColors.redProgressStrokeColor),
+ value: rpm * (1 / maxRpm),
+ ),
+ ),
+ SizedBox(
+ height: 200,
+ width: 200,
+ child: CircularProgressIndicator(
+ strokeWidth: 12,
+ backgroundColor: Colors.transparent,
+ //value: controller.value,
+ valueColor: const AlwaysStoppedAnimation<Color>(
+ AGLDemoColors.jordyBlueColor),
+ value: rpm >= 6500
+ ? 6500 * (1 / maxRpm)
+ : rpm * (1 / maxRpm),
+ ),
+ ),
+ ],
+ ),
+ SizedBox(
+ height: 220,
+ width: 220,
+ child: CustomPaint(
+ foregroundPainter: CirclePainter(
+ value: rpm.toDouble(),
+ maxValue: maxRpm.toDouble(),
+ isRPM: true,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const Text(
+ 'RPM',
+ style: TextStyle(color: Colors.white, fontSize: 40),
+ ),
+ ],
+ );
+ }
+}
+
+
+
+class SpeedProgressIndicator extends ConsumerStatefulWidget {
+ const SpeedProgressIndicator({super.key});
+
+ @override
+ SpeedProgressIndicatorState createState() => SpeedProgressIndicatorState();
+}
+
+class SpeedProgressIndicatorState extends ConsumerState<SpeedProgressIndicator>
+ with TickerProviderStateMixin {
+ late AnimationController controller;
+
+ @override
+ void initState() {
+ controller = AnimationController(
+ /// [AnimationController]s can be created with `vsync: this` because of
+ /// [TickerProviderStateMixin].
+ vsync: this,
+ duration: const Duration(seconds: 5),
+ )..addListener(() {
+ //setState(() {});
+ });
+ controller.repeat(reverse: true);
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final speed = ref.watch(vehicleProvider.select((vehicle) => vehicle.speed));
+ final unit =
+ ref.watch(unitStateProvider.select((unit) => unit.distanceUnit));
+ return Column(
+ children: [
+
+ SizedBox(
+ height: 252,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+
+ Text(
+ unit == DistanceUnit.kilometers
+ ? speed.toStringAsFixed(0)
+ : (speed * 1.609).toStringAsFixed(0),
+ style: GoogleFonts.brunoAce(
+ textStyle: const TextStyle(
+ color: Colors.white,
+ fontSize: 44,
+ ),
+ ),
+ ),
+ SizedBox(
+ height: 200,
+ width: 200,
+ child: CircularProgressIndicator(
+ strokeWidth: 12,
+ //backgroundColor: const Color(0xFF2962FF),
+ //value: controller.value,
+ value: unit == DistanceUnit.kilometers
+ ? speed * (1 / maxSpeed)
+ : (speed * (1 / maxSpeed) * 1.609),
+ semanticsLabel: 'Speed progress indicator',
+ ),
+ ),
+ SizedBox(
+ height: 220,
+ width: 220,
+ child: CustomPaint(
+ foregroundPainter:
+ CirclePainter(value: speed, maxValue: maxSpeed),
+ ),
+ ),
+ ],
+ ),
+
+ ),
+ Text(
+ unit == DistanceUnit.kilometers ? 'Km/h' : 'Mph',
+ style: const TextStyle(color: Colors.white, fontSize: 40),
+ ),
+ ],
+ );
+ }
+}
+
+class FuelProgressIndicator extends ConsumerStatefulWidget {
+ const FuelProgressIndicator({super.key});
+
+ @override
+ FuelProgressIndicatorState createState() => FuelProgressIndicatorState();
+}
+
+class FuelProgressIndicatorState extends ConsumerState<FuelProgressIndicator>
+ with TickerProviderStateMixin {
+ late AnimationController controller;
+
+ @override
+ void initState() {
+ controller = AnimationController(
+ /// [AnimationController]s can be created with `vsync: this` because of
+ /// [TickerProviderStateMixin].
+ vsync: this,
+ duration: const Duration(seconds: 5),
+ )..addListener(() {
+ //setState(() {});
+ });
+ controller.repeat(reverse: true);
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final fuelLevel =
+ ref.watch(vehicleProvider.select((vehicle) => vehicle.fuelLevel));
+ return Column(
+ children: [
+ SizedBox(
+ height: 252,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+
+ Text(
+ '${(fuelLevel * (1 / maxFuelLevel) * 100).toStringAsFixed(0)}%',
+ style: GoogleFonts.brunoAce(
+ textStyle: const TextStyle(
+ color: Colors.white,
+ fontSize: 44,
+ ),
+ ),
+ ),
+ Stack(
+ children: [
+ SizedBox(
+ height: 200,
+ width: 200,
+ child: CircularProgressIndicator(
+ strokeWidth: 12,
+ backgroundColor: Colors.transparent,
+ value: fuelLevel >= 12
+ ? 12 * (1 / maxFuelLevel)
+ : fuelLevel * (1 / maxFuelLevel),
+ valueColor: const AlwaysStoppedAnimation<Color>(
+ AGLDemoColors.redProgressStrokeColor),
+ ),
+ ),
+ if (fuelLevel > 12)
+ SizedBox(
+ height: 200,
+ width: 200,
+ child: CircularProgressIndicator(
+ strokeWidth: 12,
+ backgroundColor: Colors.transparent,
+ //value: controller.value,
+ valueColor: const AlwaysStoppedAnimation<Color>(
+ AGLDemoColors.jordyBlueColor),
+ value: fuelLevel * (1 / maxFuelLevel),
+ ),
+ ),
+
+ ],
+ ),
+ SizedBox(
+ height: 220,
+ width: 220,
+ child: CustomPaint(
+ foregroundPainter: CirclePainter(
+ value: fuelLevel,
+ maxValue: maxFuelLevel,
+ isFuel: true,
+ isRPM: false),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const Text(
+ 'Fuel',
+ style: TextStyle(color: Colors.white, fontSize: 40),
+ ),
+ ],
+ );
+ }
+}
+