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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
// SPDX-License-Identifier: Apache-2.0
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_cluster_dashboard/map/navigationHome.dart';
import 'package:flutter_cluster_dashboard/provider.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/guages/guage_props.dart';
import 'package:flutter_cluster_dashboard/screen/paints/bottombar_paint.dart';
import 'package:flutter_cluster_dashboard/screen/paints/topbar_paint.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/guages/rpm_guage_animation_wrapper.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/left_bar.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/performance_mode.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/right_bar.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/guages/speed_guage_animation_wrapper.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/signals.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/turn_signal.dart';
import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_provider.dart';
import 'package:flutter_cluster_dashboard/cluster_config.dart';
import 'package:intl/intl.dart';
class Home extends ConsumerWidget {
const Home({Key? key}) : super(key: key);
GuageColors? getGuageColor(String mode) {
return (mode == "economy")
? GuageProps.ecoModeColor
: (mode == "sport")
? GuageProps.sportModeColor
: null;
}
String addZero(int val) {
String res = val.toString();
if (res.length < 2) {
if (res.isEmpty) {
return "00";
} else if (res.length == 1) {
return "0$res";
}
}
return res;
}
double calcPadding(double value, double height) {
// values wrt to values at 720 height
return (value * height) / 720;
}
@override
Widget build(BuildContext context, WidgetRef ref) {
final clusterConfig = ref.read(clusterConfigStateprovider);
final vehicle = ref.watch(vehicleSignalProvider);
final clock = ref.watch(clockProvider);
final windowHeight = MediaQuery.of(context).size.height;
final windowWidth = MediaQuery.of(context).size.width;
double screenHeight = windowHeight;
double screenWidth = windowWidth;
double ratHeight = (windowWidth * 9) / 16;
double ratWidth = (windowHeight * 16) / 9;
if (ratWidth <= windowWidth) {
screenHeight = windowHeight;
screenWidth = ratWidth;
} else {
screenHeight = ratHeight;
screenWidth = windowWidth;
}
return Scaffold(
backgroundColor: GuageProps.bgColor,
body: SafeArea(
child: Center(
child: Center(
child: SizedBox(
width: screenWidth,
height: screenHeight,
child: Flex(
direction: Axis.vertical,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
//TopBarPainter
Flexible(
flex: 1,
child: Stack(
children: [
TurnSignal(
screenHeight: screenHeight,
isLefton: vehicle.isLeftIndicator,
isRighton: vehicle.isRightIndicator,
),
Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.center,
children: [
// mid section of top bar
Flexible(
flex: 1,
child: SizedBox(
width: (400 * screenHeight) / 480,
height: (65 * screenHeight) / 480,
child: CustomPaint(
painter: TopBarPainter(),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
DateFormat('EEEE')
.format(clock)
.substring(0, 3),
style: TextStyle(
color: const Color.fromARGB(
255, 184, 183, 183),
fontSize: (20 * screenHeight) / 480,
fontWeight: FontWeight.bold),
),
SizedBox(
width: (40 * screenHeight) / 480),
Text(
"${clock.hour}:${addZero(clock.minute)}",
style: TextStyle(
color: const Color.fromARGB(
255, 255, 255, 255),
fontSize: (30 * screenHeight) / 480,
fontWeight: FontWeight.bold),
),
SizedBox(
width: (30 * screenHeight) / 480),
Text(
"${vehicle.ambientAirTemp} ${"\u00B0"}C",
style: TextStyle(
color: const Color.fromARGB(
255, 184, 183, 183),
fontSize: (20 * screenHeight) / 480,
fontWeight: FontWeight.bold),
),
],
),
),
),
),
],
),
],
),
),
// mid section
Flexible(
flex: 4,
fit: FlexFit.tight,
child: Stack(
children: [
//left and right arc
Padding(
padding: EdgeInsets.fromLTRB(
calcPadding(60, screenHeight),
calcPadding(60, screenHeight),
calcPadding(60, screenHeight),
0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Stack(
alignment: Alignment.bottomRight,
children: [
LeftArc(screenHeight: screenHeight),
Positioned(
child: Image.asset(
"images/temperature-icon.png",
color: Colors.white,
width: (13 * screenHeight) / 480,
),
),
],
),
Stack(
alignment: Alignment.bottomLeft,
children: [
RightArc(screenHeight: screenHeight),
Positioned(
child: Image.asset(
"images/fuel-icon.png",
color: Colors.white,
width: (18 * screenHeight) / 480,
))
],
),
],
),
),
//logo area
Padding(
padding: EdgeInsets.fromLTRB(
calcPadding(60, screenHeight),
0,
calcPadding(60, screenHeight),
0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: (550 * screenHeight) / 720,
height: (450 * screenHeight) / 720,
child: Flex(
direction: Axis.vertical,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// performance mode
Flexible(
flex: 1,
child: PerformanceMode(
size: Size((90 * screenHeight) / 480,
(20 * screenHeight) / 480),
mode: vehicle.performanceMode),
),
// logo
Flexible(
flex: 6,
fit: FlexFit.tight,
child: SizedBox(
width: (330 * screenHeight) / 720,
child: (clusterConfig
.enableNavigation &&
vehicle.isSteeringInfo)
? const NavigationHome()
: Padding(
padding: EdgeInsets.symmetric(
vertical:
(36.0 * screenHeight) /
720,
horizontal:
(48.0 * screenHeight) /
720),
child: Image.asset(
"images/logo_agl.png",
width:
(90 * screenHeight) / 480,
color: Colors.grey.shade600,
),
),
),
),
const Flexible(
flex: 1,
child: SizedBox(),
)
],
),
),
],
),
),
//warning signals
Padding(
padding: EdgeInsets.fromLTRB(
calcPadding(0, screenHeight),
calcPadding(430, screenHeight),
calcPadding(0, screenHeight),
0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Signals(
screenHeight: screenHeight,
vehicle: vehicle,
),
],
),
),
// guages
Padding(
padding: EdgeInsets.fromLTRB(
calcPadding(70, screenHeight),
calcPadding(30, screenHeight),
calcPadding(70, screenHeight),
0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Speed Guage
SpeedGauge(
screenHeight: screenHeight,
guageColor:
getGuageColor(vehicle.performanceMode),
),
//RPM Guage
RPMGauge(
screenHeight: screenHeight,
guageColor:
getGuageColor(vehicle.performanceMode),
),
],
),
)
],
),
),
// bottomBarPainter
Flexible(
flex: 1,
child: SizedBox(
width: (400 * screenHeight) / 480,
height: (50 * screenHeight) / 480,
child: CustomPaint(
size: Size((400 * screenHeight) / 480,
(50 * screenHeight) / 480),
painter: BottomBarPainter(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
(vehicle.selectedGear == Gear.parking)
? Text("P",
style: GuageProps.activeGearIconStyle(
screenHeight))
: Text("P",
style: GuageProps.gearIconStyle(
screenHeight)),
(vehicle.selectedGear == Gear.reverse)
? Text("R",
style: GuageProps.activeGearIconStyle(
screenHeight))
: Text("R",
style: GuageProps.gearIconStyle(
screenHeight)),
(vehicle.selectedGear == Gear.neutral)
? Text("N",
style: GuageProps.activeGearIconStyle(
screenHeight))
: Text("N",
style: GuageProps.gearIconStyle(
screenHeight)),
(vehicle.selectedGear == Gear.drive)
? Text("D",
style: GuageProps.activeGearIconStyle(
screenHeight))
: Text("D",
style: GuageProps.gearIconStyle(
screenHeight)),
]),
),
)),
],
),
),
),
),
),
);
}
}
|