| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import '../../core/theme/app_colors.dart';
- import '../../core/widgets/app_icon.dart';
- import '../home/obd_controller.dart';
- import '../home/telemetry_settings_controller.dart';
- import 'settings_widgets.dart';
- /// Settings card for showing speed on Home and choosing its source.
- class SpeedSettingsCard extends StatelessWidget {
- const SpeedSettingsCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = context.colors;
- final theme = Theme.of(context);
- final telemetry = context.watch<TelemetrySettingsController>();
- final obd = context.watch<ObdController>();
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Container(
- width: 42,
- height: 42,
- decoration: BoxDecoration(
- color: colors.accentSoft,
- borderRadius: BorderRadius.circular(14),
- ),
- alignment: Alignment.center,
- child: AppIcon(
- 'assets/icons/gauge.svg',
- size: 20,
- color: colors.accent,
- ),
- ),
- const SizedBox(width: 14),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('Show speed', style: theme.textTheme.titleMedium),
- const SizedBox(height: 2),
- Text(
- 'Show the speed card on the home screen.',
- style: theme.textTheme.bodySmall?.copyWith(
- color: colors.inkMuted,
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 8),
- SettingsSwitch(
- value: telemetry.speedEnabled,
- semanticsLabel: telemetry.speedEnabled
- ? 'Hide the speed card'
- : 'Show the speed card',
- onChanged: telemetry.setSpeedEnabled,
- ),
- ],
- ),
- if (obd.hasConfiguredAdapter) ...[
- Divider(color: colors.border, height: 30),
- Row(
- children: [
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Use OBD-II for speed',
- style: theme.textTheme.bodyLarge,
- ),
- const SizedBox(height: 2),
- Text(
- 'GPS is used when this is off.',
- style: theme.textTheme.bodySmall?.copyWith(
- color: colors.inkMuted,
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 8),
- SettingsSwitch(
- value: telemetry.speedUseObd,
- semanticsLabel: telemetry.speedUseObd
- ? 'Use GPS for speed'
- : 'Use OBD-II for speed',
- onChanged: telemetry.setSpeedUseObd,
- ),
- ],
- ),
- ],
- ],
- );
- }
- }
|