summaryrefslogtreecommitdiffstats
path: root/lib/screen/widgets/left_bar.dart
blob: 3192c28c1dbe5a7a1a04d71e95a54e1eaac95e16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: Apache-2.0

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter_cluster_dashboard/screen/paints/arc_painter.dart';
import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_model.dart';
import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_provider.dart';

class LeftArc extends HookConsumerWidget {
  final double screenHeight;
  const LeftArc({Key? key, required this.screenHeight}) : super(key: key);
  // final Color color;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final VehicleSignal vehicle = ref.watch(vehicleSignalProvider);
    final animationController = useAnimationController(
      lowerBound: 0,
      upperBound: 100,
    )..animateTo(vehicle.coolantTemp,
        duration: const Duration(milliseconds: 1000));

    return AnimatedBuilder(
        animation: animationController,
        builder: (context, child) {
          return CustomPaint(
            size: Size(0, (220 * screenHeight) / 480),
            painter: LeftPainter(
              radi: (170 * screenHeight) / 480,
              currentValue: animationController.value,
              bottomPadding: 15,
              color: Color.lerp(Colors.yellow, Colors.red,
                      (animationController.value / 100)) ??
                  Colors.orange,
            ),
          );
        });
  }
}