gps_speed_card.dart 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:flutter/material.dart';
  2. import '../../../core/theme/app_colors.dart';
  3. import '../../../core/widgets/surface_card.dart';
  4. /// Speed from GPS, shown only when no OBD-II adapter is connected.
  5. class GpsSpeedCard extends StatelessWidget {
  6. const GpsSpeedCard({super.key, required this.speedKmh, this.compact = false});
  7. final double speedKmh;
  8. final bool compact;
  9. @override
  10. Widget build(BuildContext context) {
  11. final colors = context.colors;
  12. final theme = Theme.of(context);
  13. return Semantics(
  14. label: '${speedKmh.round()} kilometers per hour from GPS',
  15. child: SurfaceCard(
  16. padding: EdgeInsets.fromLTRB(
  17. compact ? 16 : 20,
  18. compact ? 13 : 16,
  19. compact ? 16 : 20,
  20. compact ? 13 : 16,
  21. ),
  22. radius: 24,
  23. child: Column(
  24. crossAxisAlignment: CrossAxisAlignment.start,
  25. children: [
  26. Row(
  27. children: [
  28. Container(
  29. width: 7,
  30. height: 7,
  31. decoration: BoxDecoration(
  32. color: colors.accent,
  33. shape: BoxShape.circle,
  34. ),
  35. ),
  36. const SizedBox(width: 8),
  37. Text(
  38. 'GPS',
  39. style: theme.textTheme.labelMedium?.copyWith(
  40. color: colors.inkMuted,
  41. letterSpacing: 0.8,
  42. ),
  43. ),
  44. const Spacer(),
  45. Text(
  46. 'FROM LOCATION',
  47. style: theme.textTheme.labelSmall?.copyWith(
  48. color: colors.inkFaint,
  49. fontSize: compact ? 9 : 10,
  50. letterSpacing: 0.5,
  51. ),
  52. ),
  53. ],
  54. ),
  55. SizedBox(height: compact ? 6 : 8),
  56. Row(
  57. crossAxisAlignment: CrossAxisAlignment.end,
  58. children: [
  59. Text(
  60. speedKmh.round().toString(),
  61. style: theme.textTheme.displaySmall?.copyWith(
  62. fontSize: compact ? 38 : 46,
  63. height: 0.95,
  64. fontFeatures: const [FontFeature.tabularFigures()],
  65. ),
  66. ),
  67. const SizedBox(width: 7),
  68. Padding(
  69. padding: const EdgeInsets.only(bottom: 5),
  70. child: Text(
  71. 'km/h',
  72. style: theme.textTheme.bodySmall?.copyWith(
  73. color: colors.inkMuted,
  74. ),
  75. ),
  76. ),
  77. ],
  78. ),
  79. ],
  80. ),
  81. ),
  82. );
  83. }
  84. }