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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// SPDX-License-Identifier: Apache-2.0
import 'package:flutter/material.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:dashboard_app/size.dart';
import '../vehicle-signals/vss_providers.dart';
class TirePressure extends StatelessWidget {
String tireName;
double tirePressure;
CrossAxisAlignment crossAxisAlignment;
MainAxisAlignment mainAxisAlignment;
TirePressure(
{Key? key,
required this.tireName,
required this.tirePressure,
required this.crossAxisAlignment,
required this.mainAxisAlignment})
: super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: SizeConfig.safeBlockVertical * 12,
width: SizeConfig.safeBlockHorizontal * 14,
child: Column(
mainAxisAlignment: mainAxisAlignment,
children: [
Text(
'${tireName}',
style: SizeConfig.smallnormalfont2,
),
Text(
tirePressure.toString() + ' PSI',
style: SizeConfig.smallnormalfont,
),
LinearPercentIndicator(
width: SizeConfig.safeBlockHorizontal * 11,
progressColor: tirePressure / 50 > 0.6 ? Colors.green : Colors.red,
lineHeight: SizeConfig.safeBlockVertical * 1.5,
alignment: MainAxisAlignment.center,
animateFromLastPercent: true,
animation: true,
percent: tirePressure / 50,
barRadius: Radius.circular(SizeConfig.fontsize / 4),
backgroundColor: Colors.grey,
),
],
),
);
}
}
class FrontLeftTirePressure extends ConsumerWidget {
FrontLeftTirePressure({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final vehicleFrontLeftTP =
ref.watch(vehicleSignalFrontLeftTirePressureProvider);
return TirePressure(
tireName: 'Left Front',
tirePressure: vehicleFrontLeftTP.pressure,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
);
}
}
class RearLeftTirePressure extends ConsumerWidget {
RearLeftTirePressure({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final vehicleRearLeftTP =
ref.watch(vehicleSignalRearLeftTirePressureProvider);
return TirePressure(
tireName: 'Left Rear',
tirePressure: vehicleRearLeftTP.pressure,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
);
}
}
class FrontRightTirePressure extends ConsumerWidget {
FrontRightTirePressure({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final vehicleFrontRightTP =
ref.watch(vehicleSignalFrontRightTirePressureProvider);
return TirePressure(
tireName: 'Right Front',
tirePressure: vehicleFrontRightTP.pressure,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
);
}
}
class RearRightTirePressure extends ConsumerWidget {
RearRightTirePressure({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final vehicleRearRightTP =
ref.watch(vehicleSignalRearRightTirePressureProvider);
return TirePressure(
tireName: 'Right Rear',
tirePressure: vehicleRearRightTP.pressure,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
);
}
}
|