summaryrefslogtreecommitdiffstats
path: root/lib/HomePage.dart
blob: 6487ef5895dc64aa1e7978030a7e0f67b598b1be (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
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
// SPDX-License-Identifier: Apache-2.0
import 'package:dashboard_app/Tier_pressure.dart';
import 'package:dashboard_app/drawArrow.dart';
import 'package:dashboard_app/provider.dart';
import 'package:dashboard_app/size.dart';
import 'package:dashboard_app/widgets/child_lock.dart';
import 'package:dashboard_app/widgets/fuel_and_speed.dart';
import 'package:dashboard_app/widgets/weather.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:latlng/latlng.dart';



import 'Kuksa-server/vehicle_provider.dart';


class HomePage extends ConsumerStatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends ConsumerState<HomePage> {
  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);
    final vehicle = ref.watch(vehicleSignalProvider);
    LatLng pos = LatLng(vehicle.currentLatitude, vehicle.currentLongitude);

    DateTime _now = ref.watch(DateTimeProvider);



    return Scaffold(
        backgroundColor: Colors.black,
        body: OrientationBuilder(
          builder: (context, orientation) {
            if (orientation == Orientation.landscape) {
              return Stack(
                children: [
                  SizedBox(
                    width: MediaQuery.of(context).size.width,
                    height: MediaQuery.of(context).size.height,
                    child: Container(
                      color: Colors.black,
                    ),
                  ),




                  Positioned(
                    right: SizeConfig.safeBlockHorizontal * 41,
                    top: SizeConfig.safeBlockVertical * 58,
                    child: ChildLockStatus(
                        isChildLockActiveLeft: vehicle.isChildLockActiveLeft,
                        isChildLockActiveRight: vehicle.isChildLockActiveRight),
                  ),

                  Positioned(
                    top: SizeConfig.safeBlockVertical * 18,
                    right: SizeConfig.safeBlockHorizontal * 38,
                    child: Column(

                      children: [
                        TierPressure(
                          tname: 'L Front Tier',
                          tpress: vehicle.frontLeftTP,
                          mainAxisAlignment: MainAxisAlignment.end,
                          crossAxisAlignment: CrossAxisAlignment.end,
                        ),
                        Container(
                          height: SizeConfig.safeBlockVertical * 10,
                          width: SizeConfig.safeBlockHorizontal * 12,
                          child: CustomPaint(
                            painter: Arrowpaint2(),
                          ),
                        )
                      ],
                    ),
                  ),
                  Positioned(
                    top: SizeConfig.safeBlockVertical * 65,
                    right: SizeConfig.safeBlockHorizontal * 38,
                    child: Column(

                      children: [
                        RotatedBox(
                          quarterTurns: 2,
                          child: Container(
                            height: SizeConfig.safeBlockVertical * 10,
                            width: SizeConfig.safeBlockHorizontal * 12,
                            child: CustomPaint(
                              painter: Arrowpaint(),
                            ),
                          ),
                        ),
                        TierPressure(
                          tname: 'L Rear Tier',
                          tpress: vehicle.rearLeftTP,
                          crossAxisAlignment: CrossAxisAlignment.end,
                          mainAxisAlignment: MainAxisAlignment.start,
                        ),
                      ],
                    ),
                  ),
                  Positioned(
                    top: SizeConfig.safeBlockVertical * 18,
                    right: SizeConfig.safeBlockHorizontal * 7,
                    child: Column(
                      children: [
                        TierPressure(
                          tname: 'R Front Tier',
                          tpress: vehicle.frontRightTP,
                          mainAxisAlignment: MainAxisAlignment.end,
                          crossAxisAlignment: CrossAxisAlignment.start,
                        ),
                        Container(
                          height: SizeConfig.safeBlockVertical * 10,
                          width: SizeConfig.safeBlockHorizontal * 12,
                          child: CustomPaint(
                            painter: Arrowpaint(),
                          ),
                        ),
                      ],
                    ),
                  ),
                  Positioned(
                    top: SizeConfig.safeBlockVertical * 65,
                    right: SizeConfig.safeBlockHorizontal * 7,
                    child: Column(
                      children: [
                        RotatedBox(
                          quarterTurns: 2,
                          child: Container(
                            height: SizeConfig.safeBlockVertical * 10,
                            width: SizeConfig.safeBlockHorizontal * 12,
                            child: CustomPaint(
                              painter: Arrowpaint2(),
                            ),
                          ),
                        ),
                        TierPressure(
                          tname: 'R Rear Tier',
                          tpress: vehicle.rearRightTP,
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                        ),
                      ],
                    ),
                  ),
                  Positioned(
                    top: SizeConfig.safeBlockVertical * 20,
                    right: SizeConfig.blockSizeHorizontal * 13,
                    bottom: SizeConfig.blockSizeVertical * 20,
                    child: SizedBox(
                      height: SizeConfig.screenHeight * 0.6,
                      width: SizeConfig.screenWidth * 0.30,
                      child: AnimatedContainer(
                        duration: Duration(milliseconds: 10),
                        child: Image.asset('images/car_img.png'),
                      ),
                    ),
                  ),

                  Positioned(
                      top: SizeConfig.safeBlockVertical * 7,
                      left: SizeConfig.safeBlockHorizontal * 2,
                      bottom: SizeConfig.safeBlockVertical * 4,
                      child: Container(
                        width: SizeConfig.screenWidth / 2,
                        height: SizeConfig.screenHeight * 0.75,
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Rpm(rpm: vehicle.rpm),

                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  'Avg. Fuel Consumtion',
                                  style: SizeConfig.smallnormalfont,
                                ),
                                Text(
                                  vehicle.fuelRate.toString() + ' KM/Litre',
                                  style: SizeConfig.smallnormalfont,
                                ),
                              ],
                            ),
                            // ignore: prefer_const_constructors
                            weather(
                              insideTemperatue: vehicle.insideTemperature,
                              outsideTempearure: vehicle.outsideTemperature,
                            ),
                            SpeedAndFuel(
                                fuel: vehicle.fuelLevel, speed: vehicle.speed),
                          ],
                        ),
                      ))
                ],
              );
            }
            //--------------------------Portrait mode ------------------------------------------------
            else {
              return Stack(
                children: [
                  Positioned(
                    top: 0,
                    bottom: 0,
                    left: 0,
                    right: 0,
                    child: Padding(
                      padding: EdgeInsets.fromLTRB(
                          SizeConfig.safeBlockHorizontal * 2,
                          SizeConfig.safeBlockVertical * 2,
                          SizeConfig.safeBlockHorizontal * 2,
                          0),

                      child: Column(
                        children: [
                          Flexible(flex: 1, child: SizedBox()),
                          SizedBox(
                            height: SizeConfig.safeBlockVertical,
                          ),
                          Flexible(
                            flex: 1,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.end,
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                              ],
                            ),
                          ),

                          SizedBox(
                            height: SizeConfig.safeBlockVertical,
                          ),
                          Flexible(
                            flex: 2,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Flexible(
                                  flex: 1,
                                  child: weather(
                                    insideTemperatue: vehicle.insideTemperature,
                                    outsideTempearure:
                                        vehicle.outsideTemperature,
                                  ),
                                ),
                                Flexible(
                                  flex: 2,
                                  child: SpeedAndFuel(
                                      fuel: vehicle.fuelLevel,
                                      speed: vehicle.speed),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(
                            height: SizeConfig.safeBlockVertical * 6,
                          ),
                          Flexible(
                            flex: 5,
                            child: Container(


                              // color: Colors.red,
                              height: SizeConfig.screenHeight * 0.6,
                              width: SizeConfig.screenWidth * 0.53,
                              child: Stack(
                                children: [
                                  Positioned(
                                    top: 0,
                                    left: 0,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.start,
                                      crossAxisAlignment:
                                          CrossAxisAlignment.end,
                                      children: [
                                        TierPressure(
                                          tname: 'L Front Tire',
                                          tpress: vehicle.frontLeftTP,
                                          mainAxisAlignment:
                                              MainAxisAlignment.end,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.end,
                                        ),
                                        Container(
                                          height:
                                              SizeConfig.safeBlockVertical * 6,
                                          width:
                                              SizeConfig.safeBlockHorizontal *
                                                  12,
                                          child: CustomPaint(
                                            painter: Arrowpaint2(),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Positioned(
                                    bottom: 0,
                                    left: 0,
                                    child: Column(
                                      children: [
                                        ChildLockStatus(
                                            isChildLockActiveLeft:
                                                vehicle.isChildLockActiveLeft,
                                            isChildLockActiveRight:
                                                vehicle.isChildLockActiveRight),
                                        RotatedBox(
                                          quarterTurns: 2,
                                          child: Container(
                                            height:
                                                SizeConfig.safeBlockVertical *
                                                    6,
                                            width:
                                                SizeConfig.safeBlockHorizontal *
                                                    12,
                                            child: CustomPaint(
                                              painter: Arrowpaint(),
                                            ),
                                          ),
                                        ),
                                        TierPressure(
                                          tname: 'L Rear Tire',
                                          tpress: vehicle.rearLeftTP,
                                          mainAxisAlignment:
                                              MainAxisAlignment.start,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.end,
                                        ),
                                      ],
                                    ),
                                  ),
                                  Positioned(
                                    top: 0,
                                    bottom: 0,
                                    left: SizeConfig.safeBlockHorizontal * 12,
                                    right: SizeConfig.safeBlockHorizontal * 12,
                                    child: SizedBox(

                                      child: AnimatedContainer(
                                        duration: Duration(milliseconds: 10),
                                        child: Image.asset(
                                          'images/car_img.png',
                                          fit: BoxFit.fill,
                                        ),
                                      ),
                                    ),
                                  ),
                                  Positioned(
                                    right: 0,
                                    top: 0,
                                    child: Column(
                                      children: [
                                        TierPressure(
                                          tname: 'R Front Tire',
                                          tpress: vehicle.frontRightTP,
                                          mainAxisAlignment:
                                              MainAxisAlignment.end,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                        ),
                                        Container(
                                          height:
                                              SizeConfig.safeBlockVertical * 6,
                                          width:
                                              SizeConfig.safeBlockHorizontal *
                                                  12,
                                          child: CustomPaint(
                                            painter: Arrowpaint(),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Positioned(
                                    bottom: 0,
                                    right: 0,
                                    child: Column(
                                      children: [
                                        ChildLockStatus(
                                            isChildLockActiveLeft:
                                                vehicle.isChildLockActiveLeft,
                                            isChildLockActiveRight:
                                                vehicle.isChildLockActiveRight),
                                        RotatedBox(
                                          quarterTurns: 2,
                                          child: Container(
                                            height:
                                                SizeConfig.safeBlockVertical *
                                                    6,
                                            width:
                                                SizeConfig.safeBlockHorizontal *
                                                    12,
                                            child: CustomPaint(
                                              painter: Arrowpaint2(),
                                            ),
                                          ),
                                        ),
                                        TierPressure(
                                          tname: 'R Rear Tire',
                                          tpress: vehicle.rearRightTP,
                                          mainAxisAlignment:
                                              MainAxisAlignment.start,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                        ),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          SizedBox(
                            height: SizeConfig.safeBlockVertical,
                          ),
                          Flexible(
                            flex: 1,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                Flexible(
                                  flex: 1,
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.end,
                                    crossAxisAlignment:
                                    CrossAxisAlignment.start,
                                    children: [
                                      Text(
                                        'Avg. Fuel Consumtion',
                                        style: SizeConfig.smallnormalfont2,
                                      ),
                                      Text(
                                        vehicle.fuelRate.toString() +
                                            ' KM/Litre',
                                        style: SizeConfig.smallnormalfont,
                                      ),
                                    ],
                                  ),
                                ),
                                Flexible(flex: 1, child: Rpm(rpm: vehicle.rpm)),
                              ],
                            ),
                          ),

                        ],
                      ),
                    ),
                  )
                ],
              );

            }
          },
        ));
  }
}