Complete v2.0 ultra-lightweight rebuild with premium color themes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mikkeli Matlock
2025-08-24 22:35:20 +09:00
parent 23b232f8f0
commit bab90a9830
37 changed files with 550 additions and 315 deletions
-198
View File
@@ -1,198 +0,0 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/settings_provider.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
),
body: Consumer<SettingsProvider>(
builder: (context, settings, child) {
return ListView(
children: [
_buildSectionHeader(context, 'Display'),
SwitchListTile(
title: const Text('Dark Mode'),
subtitle: const Text('Switch between light and dark themes'),
value: settings.isDarkMode,
onChanged: settings.setDarkMode,
),
ListTile(
title: const Text('Speed Unit'),
subtitle: Text('Current: ${settings.speedUnitString}'),
trailing: const Icon(Icons.chevron_right),
onTap: () => _showSpeedUnitDialog(context, settings),
),
ListTile(
title: const Text('Speedometer Style'),
subtitle: Text(settings.speedometerStyle == SpeedometerStyle.digital
? 'Digital Display'
: 'Analog Gauge'),
trailing: const Icon(Icons.chevron_right),
onTap: () => _showSpeedometerStyleDialog(context, settings),
),
const Divider(),
_buildSectionHeader(context, 'Information Display'),
SwitchListTile(
title: const Text('Show Coordinates'),
subtitle: const Text('Display current latitude and longitude'),
value: settings.showCoordinates,
onChanged: settings.setShowCoordinates,
),
SwitchListTile(
title: const Text('Show Distance'),
subtitle: const Text('Display total trip distance'),
value: settings.showDistance,
onChanged: settings.setShowDistance,
),
SwitchListTile(
title: const Text('Show Trip Time'),
subtitle: const Text('Display elapsed trip time'),
value: settings.showTripTime,
onChanged: settings.setShowTripTime,
),
SwitchListTile(
title: const Text('Show GPS Accuracy'),
subtitle: const Text('Display current GPS accuracy'),
value: settings.showAccuracy,
onChanged: settings.setShowAccuracy,
),
const Divider(),
_buildSectionHeader(context, 'About'),
ListTile(
title: const Text('GPS Speedometer'),
subtitle: const Text('Version 1.0.0\nCreated with Claude Code'),
leading: const Icon(Icons.info_outline),
),
],
);
},
),
);
}
Widget _buildSectionHeader(BuildContext context, String title) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Text(
title,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.w600,
),
),
);
}
void _showSpeedUnitDialog(BuildContext context, SettingsProvider settings) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Speed Unit'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
RadioListTile<SpeedUnit>(
title: const Text('Kilometers per hour (km/h)'),
value: SpeedUnit.kmh,
groupValue: settings.speedUnit,
onChanged: (value) {
if (value != null) {
settings.setSpeedUnit(value);
Navigator.pop(context);
}
},
),
RadioListTile<SpeedUnit>(
title: const Text('Miles per hour (mph)'),
value: SpeedUnit.mph,
groupValue: settings.speedUnit,
onChanged: (value) {
if (value != null) {
settings.setSpeedUnit(value);
Navigator.pop(context);
}
},
),
RadioListTile<SpeedUnit>(
title: const Text('Knots'),
value: SpeedUnit.knots,
groupValue: settings.speedUnit,
onChanged: (value) {
if (value != null) {
settings.setSpeedUnit(value);
Navigator.pop(context);
}
},
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
],
),
);
}
void _showSpeedometerStyleDialog(BuildContext context, SettingsProvider settings) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Speedometer Style'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
RadioListTile<SpeedometerStyle>(
title: const Text('Digital Display'),
subtitle: const Text('Clean numeric display'),
value: SpeedometerStyle.digital,
groupValue: settings.speedometerStyle,
onChanged: (value) {
if (value != null) {
settings.setSpeedometerStyle(value);
Navigator.pop(context);
}
},
),
RadioListTile<SpeedometerStyle>(
title: const Text('Analog Gauge'),
subtitle: const Text('Classic circular speedometer'),
value: SpeedometerStyle.analog,
groupValue: settings.speedometerStyle,
onChanged: (value) {
if (value != null) {
settings.setSpeedometerStyle(value);
Navigator.pop(context);
}
},
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
],
),
);
}
}
-187
View File
@@ -1,187 +0,0 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/location_provider.dart';
import '../providers/settings_provider.dart';
import '../widgets/digital_speedometer.dart';
import '../widgets/analog_speedometer.dart';
import '../widgets/info_panel.dart';
import '../widgets/speed_unit_selector.dart';
import 'settings_screen.dart';
class SpeedometerScreen extends StatefulWidget {
const SpeedometerScreen({super.key});
@override
State<SpeedometerScreen> createState() => _SpeedometerScreenState();
}
class _SpeedometerScreenState extends State<SpeedometerScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<LocationProvider>().initializeLocation();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('GPS Speedometer'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: () {
context.read<LocationProvider>().resetTrip();
},
tooltip: 'Reset Trip',
),
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const SettingsScreen()),
);
},
tooltip: 'Settings',
),
],
),
body: Consumer2<LocationProvider, SettingsProvider>(
builder: (context, locationProvider, settingsProvider, child) {
if (!locationProvider.hasLocationPermission) {
return _buildPermissionError(locationProvider.errorMessage);
}
if (locationProvider.errorMessage.isNotEmpty) {
return _buildError(locationProvider.errorMessage);
}
return Column(
children: [
Expanded(
flex: 3,
child: Column(
children: [
Expanded(
child: _buildSpeedometer(locationProvider, settingsProvider),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8.0),
child: const SpeedUnitSelector(),
),
],
),
),
Expanded(
flex: 1,
child: InfoPanel(
locationProvider: locationProvider,
settingsProvider: settingsProvider,
),
),
],
);
},
),
);
}
Widget _buildSpeedometer(LocationProvider locationProvider, SettingsProvider settingsProvider) {
final speed = settingsProvider.convertSpeed(locationProvider.currentSpeed);
return GestureDetector(
onTap: () {
final newStyle = settingsProvider.speedometerStyle == SpeedometerStyle.digital
? SpeedometerStyle.analog
: SpeedometerStyle.digital;
settingsProvider.setSpeedometerStyle(newStyle);
},
child: settingsProvider.speedometerStyle == SpeedometerStyle.digital
? DigitalSpeedometer(
speed: speed,
unit: settingsProvider.speedUnitString,
)
: AnalogSpeedometer(
speed: speed,
unit: settingsProvider.speedUnitString,
),
);
}
Widget _buildPermissionError(String message) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.location_off,
size: 64,
color: Colors.red,
),
const SizedBox(height: 16),
Text(
'Location Permission Required',
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
message,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
context.read<LocationProvider>().initializeLocation();
},
child: const Text('Retry'),
),
],
),
),
);
}
Widget _buildError(String message) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
size: 64,
color: Colors.orange,
),
const SizedBox(height: 16),
Text(
'GPS Error',
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
message,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
context.read<LocationProvider>().initializeLocation();
},
child: const Text('Retry'),
),
],
),
),
);
}
}