Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ae660156e | |||
| 9cd497f4f5 | |||
| 057f33fc50 | |||
| 550755fad9 | |||
| 940aaee135 | |||
| 6c9bada84d | |||
| 63ee536ef1 | |||
| 2c2267e5ae | |||
| e6ffb00b2a | |||
| b3e85983e7 | |||
| 89ce53bb1b | |||
| 56327c00ec | |||
| 20a7691ac2 |
@@ -13,7 +13,10 @@
|
|||||||
"Bash(cp:*)",
|
"Bash(cp:*)",
|
||||||
"Bash(flutter:*)",
|
"Bash(flutter:*)",
|
||||||
"Bash(powershell:*)",
|
"Bash(powershell:*)",
|
||||||
"WebFetch(domain:docs.anthropic.com)"
|
"WebFetch(domain:docs.anthropic.com)",
|
||||||
|
"WebSearch",
|
||||||
|
"WebFetch(domain:pub.dev)",
|
||||||
|
"Bash(git commit:*)"
|
||||||
],
|
],
|
||||||
"defaultMode": "acceptEdits"
|
"defaultMode": "acceptEdits"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
## Project Overview
|
## Project Overview
|
||||||
A customizable Flutter GPS speedometer app targeting Android devices, emphasizing modularity and user customization.
|
A customizable Flutter GPS speedometer app targeting Android devices, emphasizing modularity and user customization.
|
||||||
|
|
||||||
## Current Status: v1.1 Complete
|
## Current Status: v2.1.0 Complete
|
||||||
**Enhanced GPS speedometer with improved user experience and customization options.**
|
**GPS speedometer with floating window overlay functionality and optimized visual design.**
|
||||||
|
|
||||||
### Architecture Implemented
|
### Architecture Implemented
|
||||||
- **State Management:** Provider pattern
|
- **State Management:** Provider pattern
|
||||||
@@ -25,25 +25,50 @@ A customizable Flutter GPS speedometer app targeting Android devices, emphasizin
|
|||||||
|
|
||||||
### Technical Stack
|
### Technical Stack
|
||||||
```
|
```
|
||||||
Dependencies: geolocator, permission_handler, provider, shared_preferences, flutter_material_color_picker
|
Dependencies: geolocator, permission_handler, provider, shared_preferences, flutter_material_color_picker, flutter_overlay_window
|
||||||
Platforms: Android (primary), iOS support included but untested
|
Platforms: Android (primary), iOS support included but untested
|
||||||
Architecture: Provider + Consumer pattern for reactive state management
|
Architecture: Provider + Consumer pattern for reactive state management
|
||||||
Permissions: Location services with graceful degradation
|
Permissions: Location services + SYSTEM_ALERT_WINDOW for overlay functionality
|
||||||
```
|
```
|
||||||
|
|
||||||
## Recent Updates (v1.1)
|
## Recent Updates (v2.1.0)
|
||||||
|
|
||||||
### ✅ Completed Features
|
### ✅ Completed Features (Master Branch - Stable)
|
||||||
|
- [x] **Split Decimal Display**: Main speed prominent with smaller, faded decimal fraction for better readability
|
||||||
|
- [x] **Optimized Content Sizing**: Maximized readability with improved responsive layout and flex ratios
|
||||||
|
- [x] **Basic Floating Window**: Simple overlay with "GPS SPEEDO" text and close button (stable implementation)
|
||||||
|
- [x] **Navigation Icon Trigger**: Tap compass/navigation area to launch floating window overlay
|
||||||
|
- [x] **Multiple Close Options**: Overlay close button and long-press navigation area for easy dismissal
|
||||||
|
- [x] **Android System Integration**: SYSTEM_ALERT_WINDOW permissions and foreground service configuration
|
||||||
|
|
||||||
|
### 🚧 Work in Progress Features (dev/floating-window-wip Branch - Seriously Buggy)
|
||||||
|
- [ ] **Advanced Floating Window Overlay**: System-level overlay with live GPS data - basic functionality works but seriously buggy
|
||||||
|
- GPS data synchronization implemented but unreliable
|
||||||
|
- Theme/unit sync between main app and overlay works partially
|
||||||
|
- Proportional sizing and positioning needs major refinement
|
||||||
|
- Close button functionality works but overlay behavior inconsistent
|
||||||
|
- Performance may impact main app, needs optimization
|
||||||
|
|
||||||
|
### Previous Updates (v1.1)
|
||||||
- [x] **Portrait/Landscape Support**: Automatic orientation detection implemented
|
- [x] **Portrait/Landscape Support**: Automatic orientation detection implemented
|
||||||
- [x] **Interactive Gauge**: Click gauge face to switch digital/analog modes
|
- [x] **Interactive Gauge**: Click gauge face to switch digital/analog modes
|
||||||
- [x] **Extended Speed Units**: Added knots support with quick selector buttons
|
- [x] **Extended Speed Units**: Added knots support with quick selector buttons
|
||||||
|
|
||||||
## TODO - Future Improvements
|
## TODO - Future Improvements
|
||||||
|
|
||||||
### Critical Issues
|
### Known Issues
|
||||||
- [ ] **Dependency Updates**: Update 10 packages to latest compatible versions
|
|
||||||
|
**Master Branch (v2.1.0 - Stable):**
|
||||||
|
- [ ] **Dependency Updates**: Update packages to latest compatible versions
|
||||||
- [ ] **Orientation Override**: Fix auto-rotate to work regardless of system toggle status
|
- [ ] **Orientation Override**: Fix auto-rotate to work regardless of system toggle status
|
||||||
|
|
||||||
|
**Dev Branch (floating-window-wip - Seriously Buggy):**
|
||||||
|
- [ ] **Floating Window Reliability**: Overlay behavior inconsistent across different devices and Android versions
|
||||||
|
- [ ] **GPS Data Sync**: Real-time GPS synchronization between main app and overlay unreliable
|
||||||
|
- [ ] **Theme/Unit Sync**: Setting synchronization works partially but not consistently
|
||||||
|
- [ ] **Overlay Positioning**: Poor positioning stability, sizing calculations need major work
|
||||||
|
- [ ] **Performance**: Overlay may impact main app performance, needs optimization
|
||||||
|
|
||||||
### UI/UX Enhancements
|
### UI/UX Enhancements
|
||||||
- [ ] **Background Customization**: Custom background color selection
|
- [ ] **Background Customization**: Custom background color selection
|
||||||
- [ ] **Interface Rearrangement**: User-defined layout customization
|
- [ ] **Interface Rearrangement**: User-defined layout customization
|
||||||
@@ -66,6 +91,11 @@ Permissions: Location services with graceful degradation
|
|||||||
- **Memory**: Project uses automatic Claude Code memory - this file for major decisions only
|
- **Memory**: Project uses automatic Claude Code memory - this file for major decisions only
|
||||||
- **Git**: Active repository at `https://github.com/mikkelimatlock/gps_speedo`
|
- **Git**: Active repository at `https://github.com/mikkelimatlock/gps_speedo`
|
||||||
|
|
||||||
|
## Branch Strategy
|
||||||
|
- **master**: Stable releases, ready for production APK builds
|
||||||
|
- **dev/floating-window-wip**: Advanced floating window development (seriously buggy, not for release)
|
||||||
|
- Tagged releases: v2.1.0 on master branch contains stable basic floating window
|
||||||
|
|
||||||
## Code Patterns to Maintain
|
## Code Patterns to Maintain
|
||||||
- Provider pattern for state management
|
- Provider pattern for state management
|
||||||
- Separate widgets for reusability
|
- Separate widgets for reusability
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
<!-- Optional: for background location access -->
|
<!-- Optional: for background location access -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||||
|
|
||||||
<!-- TODO: Enable for display-over-apps functionality -->
|
<!-- Overlay window permissions for floating speedometer -->
|
||||||
<!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> -->
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="Speedo"
|
android:label="Speedo"
|
||||||
@@ -34,6 +36,12 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Service for overlay window -->
|
||||||
|
<service
|
||||||
|
android:name="flutter.overlay.window.flutter_overlay_window.OverlayService"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- Don't delete the meta-data below.
|
<!-- Don't delete the meta-data below.
|
||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|||||||
+15
-2
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
class ColorTheme {
|
class ColorTheme {
|
||||||
final Color background;
|
final Color background;
|
||||||
final Color speedText;
|
final Color speedText;
|
||||||
|
final Color speedTextSub;
|
||||||
final Color headingText;
|
final Color headingText;
|
||||||
final Color unitText;
|
final Color unitText;
|
||||||
final String name;
|
final String name;
|
||||||
@@ -10,6 +11,7 @@ class ColorTheme {
|
|||||||
const ColorTheme({
|
const ColorTheme({
|
||||||
required this.background,
|
required this.background,
|
||||||
required this.speedText,
|
required this.speedText,
|
||||||
|
required this.speedTextSub,
|
||||||
required this.headingText,
|
required this.headingText,
|
||||||
required this.unitText,
|
required this.unitText,
|
||||||
required this.name,
|
required this.name,
|
||||||
@@ -22,13 +24,15 @@ class ColorThemes {
|
|||||||
name: 'Yuzuki',
|
name: 'Yuzuki',
|
||||||
background: Color.fromARGB(255, 114, 85, 109),
|
background: Color.fromARGB(255, 114, 85, 109),
|
||||||
speedText: Color.fromARGB(255, 246, 224, 255),
|
speedText: Color.fromARGB(255, 246, 224, 255),
|
||||||
|
speedTextSub: Color.fromARGB(255, 245, 217, 245),
|
||||||
headingText: Color.fromARGB(255, 244, 201, 255),
|
headingText: Color.fromARGB(255, 244, 201, 255),
|
||||||
unitText: Color.fromARGB(255, 244, 201, 255),
|
unitText: Color.fromARGB(255, 244, 201, 255),
|
||||||
),
|
),
|
||||||
ColorTheme(
|
ColorTheme(
|
||||||
name: 'Yuubari',
|
name: 'Yuuparo',
|
||||||
background: Color.fromARGB(255, 85, 99, 112),
|
background: Color.fromARGB(255, 85, 99, 112),
|
||||||
speedText: Color.fromARGB(255, 255, 166, 0),
|
speedText: Color.fromARGB(255, 255, 171, 16),
|
||||||
|
speedTextSub: Color.fromARGB(255, 245, 204, 116),
|
||||||
headingText: Color.fromARGB(255, 228, 235, 238),
|
headingText: Color.fromARGB(255, 228, 235, 238),
|
||||||
unitText: Color.fromARGB(255, 141, 196, 184),
|
unitText: Color.fromARGB(255, 141, 196, 184),
|
||||||
),
|
),
|
||||||
@@ -36,9 +40,18 @@ class ColorThemes {
|
|||||||
name: 'Yuzuki Light',
|
name: 'Yuzuki Light',
|
||||||
background: Color.fromARGB(255, 246, 224, 255),
|
background: Color.fromARGB(255, 246, 224, 255),
|
||||||
speedText: Color.fromARGB(255, 114, 85, 109),
|
speedText: Color.fromARGB(255, 114, 85, 109),
|
||||||
|
speedTextSub: Color.fromARGB(255, 161, 138, 170),
|
||||||
headingText: Color.fromARGB(255, 140, 94, 151),
|
headingText: Color.fromARGB(255, 140, 94, 151),
|
||||||
unitText: Color.fromARGB(255, 114, 85, 109),
|
unitText: Color.fromARGB(255, 114, 85, 109),
|
||||||
),
|
),
|
||||||
|
ColorTheme(
|
||||||
|
name: 'Yuuparo Light',
|
||||||
|
background: Color.fromARGB(255, 228, 235, 238),
|
||||||
|
speedText: Color.fromARGB(255, 85, 99, 112),
|
||||||
|
speedTextSub: Color.fromARGB(255, 100, 100, 131),
|
||||||
|
headingText: Color.fromARGB(255, 255, 157, 65),
|
||||||
|
unitText: Color.fromARGB(255, 98, 124, 118),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
static ColorTheme getTheme(int index) {
|
static ColorTheme getTheme(int index) {
|
||||||
|
|||||||
+15
-5
@@ -3,11 +3,13 @@ import 'package:geolocator/geolocator.dart';
|
|||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
class GpsService {
|
class GpsService {
|
||||||
|
static double? _lastValidHeading;
|
||||||
|
|
||||||
static Stream<Position> get positionStream {
|
static Stream<Position> get positionStream {
|
||||||
return Geolocator.getPositionStream(
|
return Geolocator.getPositionStream(
|
||||||
locationSettings: const LocationSettings(
|
locationSettings: const LocationSettings(
|
||||||
accuracy: LocationAccuracy.bestForNavigation,
|
accuracy: LocationAccuracy.bestForNavigation,
|
||||||
distanceFilter: 1,
|
distanceFilter: 0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -21,16 +23,24 @@ class GpsService {
|
|||||||
return await Geolocator.isLocationServiceEnabled();
|
return await Geolocator.isLocationServiceEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double getCachedHeading(double heading) {
|
||||||
|
if (heading >= 0 && heading <= 360) {
|
||||||
|
_lastValidHeading = heading;
|
||||||
|
return heading;
|
||||||
|
}
|
||||||
|
return _lastValidHeading ?? 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
static String getCompassDirection(double heading) {
|
static String getCompassDirection(double heading) {
|
||||||
if (heading < 0) return 'N/A';
|
final cachedHeading = getCachedHeading(heading);
|
||||||
|
|
||||||
const directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
|
const directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
|
||||||
final index = ((heading + 22.5) / 45).floor() % 8;
|
final index = ((cachedHeading + 22.5) / 45).floor() % 8;
|
||||||
return directions[index];
|
return directions[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static String formatHeading(double heading) {
|
static String formatHeading(double heading) {
|
||||||
if (heading < 0) return 'N/A';
|
final cachedHeading = getCachedHeading(heading);
|
||||||
return '${heading.round()} ${getCompassDirection(heading)}';
|
return '${cachedHeading.round()} ${getCompassDirection(heading)}'; // don't add that degree symbol, this is cooler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+507
-58
@@ -2,18 +2,24 @@ import 'package:flutter/material.dart';
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
|
||||||
import 'speed_units.dart';
|
import 'speed_units.dart';
|
||||||
import 'gps_service.dart';
|
import 'gps_service.dart';
|
||||||
import 'color_themes.dart';
|
import 'color_themes.dart';
|
||||||
|
import 'dart:math' as math; // Import for math.pi
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const SpeedoApp());
|
runApp(const SpeedoApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry point for future overlay mode
|
// Entry point for overlay window
|
||||||
void mainOverlay() {
|
@pragma("vm:entry-point")
|
||||||
// TODO: Initialize overlay-specific setup
|
void overlayMain() {
|
||||||
runApp(const SpeedoApp(isOverlayMode: true));
|
print('[Overlay] 🚀 overlayMain() called');
|
||||||
|
runApp(const MaterialApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
home: OverlaySpeedometer(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpeedoApp extends StatelessWidget {
|
class SpeedoApp extends StatelessWidget {
|
||||||
@@ -45,17 +51,20 @@ class SpeedometerScreen extends StatefulWidget {
|
|||||||
State<SpeedometerScreen> createState() => _SpeedometerScreenState();
|
State<SpeedometerScreen> createState() => _SpeedometerScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
class _SpeedometerScreenState extends State<SpeedometerScreen> with WidgetsBindingObserver {
|
||||||
double _speed = 0.0;
|
double _speed = 0.0;
|
||||||
double _heading = -1.0;
|
double _heading = -1.0;
|
||||||
SpeedUnit _currentUnit = SpeedUnit.kmh;
|
SpeedUnit _currentUnit = SpeedUnit.kmh;
|
||||||
int _currentThemeIndex = 0;
|
int _currentThemeIndex = 0;
|
||||||
StreamSubscription<Position>? _positionSubscription;
|
StreamSubscription<Position>? _positionSubscription;
|
||||||
String _errorMessage = '';
|
String _errorMessage = '';
|
||||||
|
bool _isInBackground = false;
|
||||||
|
bool _isOverlayActive = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
_initializeGps();
|
_initializeGps();
|
||||||
_enableWakelock();
|
_enableWakelock();
|
||||||
}
|
}
|
||||||
@@ -70,11 +79,43 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
_positionSubscription?.cancel();
|
_positionSubscription?.cancel();
|
||||||
WakelockPlus.disable();
|
WakelockPlus.disable();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
super.didChangeAppLifecycleState(state);
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case AppLifecycleState.paused:
|
||||||
|
// App went to background (home key pressed or task switch)
|
||||||
|
if (!_isInBackground) {
|
||||||
|
_isInBackground = true;
|
||||||
|
_handleBackgroundTransition();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AppLifecycleState.resumed:
|
||||||
|
// App came back to foreground
|
||||||
|
_isInBackground = false;
|
||||||
|
break;
|
||||||
|
case AppLifecycleState.inactive:
|
||||||
|
case AppLifecycleState.detached:
|
||||||
|
case AppLifecycleState.hidden:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleBackgroundTransition() {
|
||||||
|
// When app goes to background, show floating window if GPS is active and no error
|
||||||
|
// Temporarily disable auto-trigger for debugging
|
||||||
|
// if (_speed >= 0 && _errorMessage.isEmpty) {
|
||||||
|
// _showFloatingWindow();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _initializeGps() async {
|
Future<void> _initializeGps() async {
|
||||||
try {
|
try {
|
||||||
final serviceEnabled = await GpsService.isLocationServiceEnabled();
|
final serviceEnabled = await GpsService.isLocationServiceEnabled();
|
||||||
@@ -91,7 +132,13 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
|
|
||||||
_positionSubscription = GpsService.positionStream.listen(
|
_positionSubscription = GpsService.positionStream.listen(
|
||||||
_onPositionUpdate,
|
_onPositionUpdate,
|
||||||
onError: (error) => setState(() => _errorMessage = 'GPS error: $error'),
|
onError: (error) {
|
||||||
|
// Only show persistent GPS errors, not temporary signal issues
|
||||||
|
final errorString = error.toString().toLowerCase();
|
||||||
|
if (!errorString.contains('timeout') && !errorString.contains('temporarily')) {
|
||||||
|
setState(() => _errorMessage = 'GPS error: $error');
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() => _errorMessage = 'Failed to initialize GPS');
|
setState(() => _errorMessage = 'Failed to initialize GPS');
|
||||||
@@ -104,24 +151,187 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
_heading = position.heading;
|
_heading = position.heading;
|
||||||
_errorMessage = '';
|
_errorMessage = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Push display data to overlay if active
|
||||||
|
_pushDataToOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _pushDataToOverlay() {
|
||||||
|
// Send complete display data to overlay including screen size
|
||||||
|
final displaySpeed = _currentUnit.convert(_speed);
|
||||||
|
final speedText = displaySpeed < 1.0 ? '--' : displaySpeed.toInt().toString();
|
||||||
|
final headingText = GpsService.formatHeading(_heading);
|
||||||
|
|
||||||
|
// Get system screen size to share with overlay
|
||||||
|
final window = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||||
|
final systemSize = window.physicalSize / window.devicePixelRatio;
|
||||||
|
|
||||||
|
print('[Main] 📤 SENDING to overlay:');
|
||||||
|
print(' speedText: "$speedText"');
|
||||||
|
print(' headingText: "$headingText"');
|
||||||
|
print(' direction: ${_heading.toStringAsFixed(1)}°');
|
||||||
|
print(' unit: ${_currentUnit.label}, theme: $_currentThemeIndex');
|
||||||
|
print(' systemScreen: ${systemSize.width.round()}x${systemSize.height.round()}');
|
||||||
|
|
||||||
|
// Calculate overlay size the same way as when launching
|
||||||
|
final overlayWidth = (systemSize.width * 0.4).round();
|
||||||
|
final overlayHeight = (overlayWidth * 0.5).round();
|
||||||
|
|
||||||
|
FlutterOverlayWindow.shareData({
|
||||||
|
'action': 'updateDisplay',
|
||||||
|
'speedText': speedText,
|
||||||
|
'headingText': headingText,
|
||||||
|
'heading': _heading,
|
||||||
|
'unitIndex': _currentUnit.index,
|
||||||
|
'themeIndex': _currentThemeIndex,
|
||||||
|
'systemScreenWidth': systemSize.width,
|
||||||
|
'systemScreenHeight': systemSize.height,
|
||||||
|
'overlayWidth': overlayWidth.clamp(280, 480).toDouble(),
|
||||||
|
'overlayHeight': overlayHeight.clamp(140, 240).toDouble(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cycleUnit() {
|
void _cycleUnit() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentUnit = _currentUnit.next;
|
_currentUnit = _currentUnit.next;
|
||||||
});
|
});
|
||||||
|
// Push updated display data to overlay
|
||||||
|
_pushDataToOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cycleTheme() {
|
void _cycleTheme() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentThemeIndex = ColorThemes.getNextThemeIndex(_currentThemeIndex);
|
_currentThemeIndex = ColorThemes.getNextThemeIndex(_currentThemeIndex);
|
||||||
});
|
});
|
||||||
|
// Push updated display data to overlay
|
||||||
|
_pushDataToOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showFloatingWindow() async {
|
||||||
|
try {
|
||||||
|
// Get actual system screen resolution for proportional sizing
|
||||||
|
final window = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||||
|
final systemSize = window.physicalSize / window.devicePixelRatio;
|
||||||
|
final overlayWidth = (systemSize.width * 0.4).round(); // 40% of system screen width
|
||||||
|
final overlayHeight = (overlayWidth * 0.5).round(); // 2:1 aspect ratio
|
||||||
|
|
||||||
|
// Debug info for development
|
||||||
|
// print('[Main] System resolution: ${systemSize.width.round()}x${systemSize.height.round()}');
|
||||||
|
// print('[Main] Calculated overlay size: ${overlayWidth}x${overlayHeight}');
|
||||||
|
|
||||||
|
// Send initial display data to overlay including screen size
|
||||||
|
final displaySpeed = _currentUnit.convert(_speed);
|
||||||
|
final speedText = displaySpeed < 1.0 ? '--' : displaySpeed.toInt().toString();
|
||||||
|
final headingText = GpsService.formatHeading(_heading);
|
||||||
|
|
||||||
|
await FlutterOverlayWindow.shareData({
|
||||||
|
'action': 'updateDisplay',
|
||||||
|
'speedText': speedText,
|
||||||
|
'headingText': headingText,
|
||||||
|
'heading': _heading,
|
||||||
|
'unitIndex': _currentUnit.index,
|
||||||
|
'themeIndex': _currentThemeIndex,
|
||||||
|
'systemScreenWidth': systemSize.width,
|
||||||
|
'systemScreenHeight': systemSize.height,
|
||||||
|
'overlayWidth': overlayWidth.clamp(280, 480).toDouble(),
|
||||||
|
'overlayHeight': overlayHeight.clamp(140, 240).toDouble(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show the overlay with proportional sizing based on system resolution
|
||||||
|
await FlutterOverlayWindow.showOverlay(
|
||||||
|
enableDrag: true,
|
||||||
|
overlayTitle: "GPS Speedometer",
|
||||||
|
overlayContent: 'GPS Speedometer Overlay',
|
||||||
|
flag: OverlayFlag.defaultFlag,
|
||||||
|
visibility: NotificationVisibility.visibilityPublic,
|
||||||
|
positionGravity: PositionGravity.none,
|
||||||
|
// Use system-based proportional sizing with reasonable limits
|
||||||
|
width: overlayWidth.clamp(280, 480),
|
||||||
|
height: overlayHeight.clamp(140, 240),
|
||||||
|
);
|
||||||
|
|
||||||
|
print('[Main] 🟢 OVERLAY LAUNCHED - Size: ${overlayWidth.clamp(280, 480)}x${overlayHeight.clamp(140, 240)}');
|
||||||
|
setState(() {
|
||||||
|
_isOverlayActive = true;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// Silent error handling - floating window issues shouldn't crash main app
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _closeFloatingWindow() async {
|
||||||
|
if (!_isOverlayActive) {
|
||||||
|
print('[Main] ⚠️ No overlay to close');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await FlutterOverlayWindow.closeOverlay();
|
||||||
|
print('[Main] 🔴 OVERLAY CLOSED - Requested from main app');
|
||||||
|
setState(() {
|
||||||
|
_isOverlayActive = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
print('[Main] ❌ Error closing overlay: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getSpeedDisplayText(double displaySpeed) {
|
||||||
|
if (_speed < 1.0 && (_heading < 0.0 || _heading >= 360.0)) {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
return displaySpeed.toStringAsFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSpeedDisplay(String speedText, ColorTheme currentTheme, double fontSize, {bool isLandscape = false}) {
|
||||||
|
if (speedText == '--') {
|
||||||
|
return Text(
|
||||||
|
speedText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize,
|
||||||
|
fontWeight: FontWeight.w300,
|
||||||
|
color: currentTheme.speedText,
|
||||||
|
fontFamily: 'DIN1451Alt',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split speed into integral and decimal parts
|
||||||
|
final parts = speedText.split('.');
|
||||||
|
final integralPart = parts[0];
|
||||||
|
final decimalPart = parts.length > 1 ? '.${parts[1]}' : '.0';
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
|
textBaseline: TextBaseline.alphabetic,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
integralPart,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize,
|
||||||
|
fontWeight: FontWeight.w300,
|
||||||
|
color: currentTheme.speedText,
|
||||||
|
fontFamily: 'DIN1451Alt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
decimalPart,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize * 0.5, // 60% of main font size
|
||||||
|
fontWeight: FontWeight.w300,
|
||||||
|
color: currentTheme.speedTextSub,
|
||||||
|
fontFamily: 'DIN1451Alt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final displaySpeed = _currentUnit.convert(_speed);
|
final displaySpeed = _currentUnit.convert(_speed);
|
||||||
final speedText = displaySpeed.toStringAsFixed(0);
|
final speedText = _getSpeedDisplayText(displaySpeed);
|
||||||
final currentTheme = ColorThemes.getTheme(_currentThemeIndex);
|
final currentTheme = ColorThemes.getTheme(_currentThemeIndex);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -147,11 +357,11 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
children: [
|
children: [
|
||||||
// Speed area - takes most space, precise tap targets on text only
|
// Speed area - takes most space, precise tap targets on text only
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 7,
|
flex: 65,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(4),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -169,33 +379,25 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
)
|
)
|
||||||
else ...[
|
else ...[
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 3,
|
flex: 4,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleUnit,
|
onTap: _cycleTheme, // Tap speed to cycle theme
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: _buildSpeedDisplay(speedText, currentTheme, 200),
|
||||||
speedText,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 200,
|
|
||||||
fontWeight: FontWeight.w300,
|
|
||||||
color: currentTheme.speedText,
|
|
||||||
fontFamily: 'DIN1451Alt',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleUnit,
|
onTap: _cycleUnit, // clicking on unit to cycle unit is more intuitive
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: Text(
|
||||||
_currentUnit.label,
|
_currentUnit.label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 64,
|
fontSize: 80,
|
||||||
color: currentTheme.unitText,
|
color: currentTheme.unitText,
|
||||||
fontFamily: 'DIN1451Alt',
|
fontFamily: 'DIN1451Alt',
|
||||||
),
|
),
|
||||||
@@ -208,34 +410,51 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Compass area - compact but fully tappable for theme cycling
|
// Compass area - compact but fully tappable for floating window
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 32,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleTheme,
|
onTap: () {
|
||||||
|
print('[Main] 🖱️ Navigation area tapped - overlay active: $_isOverlayActive');
|
||||||
|
if (_isOverlayActive) {
|
||||||
|
_closeFloatingWindow();
|
||||||
|
} else {
|
||||||
|
_showFloatingWindow();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
print('[Main] 🖱️ Navigation area long-pressed - overlay active: $_isOverlayActive');
|
||||||
|
_closeFloatingWindow();
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(2),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 2,
|
flex: 3,
|
||||||
|
child: Transform.rotate(
|
||||||
|
angle: (_heading >= 0 && _heading < 360) ? (_heading * math.pi / 180.0) : 0,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.navigation,
|
Icons.navigation,
|
||||||
size: 100,
|
size: 80,
|
||||||
color: currentTheme.headingText,
|
color: currentTheme.headingText,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: Text(
|
||||||
GpsService.formatHeading(_heading),
|
GpsService.formatHeading(_heading),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 96,
|
fontSize: 50,
|
||||||
color: currentTheme.headingText,
|
color: currentTheme.headingText,
|
||||||
fontFamily: 'DIN1451Alt',
|
fontFamily: 'DIN1451Alt',
|
||||||
),
|
),
|
||||||
@@ -256,11 +475,11 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
children: [
|
children: [
|
||||||
// Speed area - takes majority of space, precise tap targets on text only
|
// Speed area - takes majority of space, precise tap targets on text only
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 65,
|
flex: 66,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(3),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -278,33 +497,29 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
)
|
)
|
||||||
else ...[
|
else ...[
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 3,
|
flex: 1,
|
||||||
|
child: FittedBox(),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 20,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleUnit,
|
onTap: _cycleTheme,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: _buildSpeedDisplay(speedText, currentTheme, 160, isLandscape: true),
|
||||||
speedText,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 120,
|
|
||||||
fontWeight: FontWeight.w300,
|
|
||||||
color: currentTheme.speedText,
|
|
||||||
fontFamily: 'DIN1451Alt',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 7,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleUnit,
|
onTap: _cycleUnit,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: Text(
|
||||||
_currentUnit.label,
|
_currentUnit.label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 50,
|
||||||
color: currentTheme.unitText,
|
color: currentTheme.unitText,
|
||||||
fontFamily: 'DIN1451Alt',
|
fontFamily: 'DIN1451Alt',
|
||||||
),
|
),
|
||||||
@@ -312,40 +527,60 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 5,
|
||||||
|
child: FittedBox(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Compass area - smaller but fully tappable for theme cycling
|
// Compass area - smaller but fully tappable for floating window
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 35,
|
flex: 33,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: _cycleTheme,
|
onTap: () {
|
||||||
|
print('[Main] 🖱️ Navigation area tapped (landscape) - overlay active: $_isOverlayActive');
|
||||||
|
if (_isOverlayActive) {
|
||||||
|
_closeFloatingWindow();
|
||||||
|
} else {
|
||||||
|
_showFloatingWindow();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
print('[Main] 🖱️ Navigation area long-pressed (landscape) - overlay active: $_isOverlayActive');
|
||||||
|
_closeFloatingWindow();
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(2),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 2,
|
flex: 3,
|
||||||
|
child: Transform.rotate(
|
||||||
|
angle: (_heading >= 0 && _heading < 360) ? (_heading * math.pi / 180.0) : 0,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.navigation,
|
Icons.navigation,
|
||||||
size: 32,
|
size: 60,
|
||||||
color: currentTheme.headingText,
|
color: currentTheme.headingText,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.contain,
|
||||||
child: Text(
|
child: Text(
|
||||||
GpsService.formatHeading(_heading),
|
GpsService.formatHeading(_heading),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 30,
|
||||||
color: currentTheme.headingText,
|
color: currentTheme.headingText,
|
||||||
fontFamily: 'DIN1451Alt',
|
fontFamily: 'DIN1451Alt',
|
||||||
),
|
),
|
||||||
@@ -361,3 +596,217 @@ class _SpeedometerScreenState extends State<SpeedometerScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OverlaySpeedometer extends StatefulWidget {
|
||||||
|
const OverlaySpeedometer({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<OverlaySpeedometer> createState() => _OverlaySpeedometerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OverlaySpeedometerState extends State<OverlaySpeedometer> {
|
||||||
|
String _speedText = '--';
|
||||||
|
String _headingText = 'N/A';
|
||||||
|
double _heading = -1.0;
|
||||||
|
int _currentThemeIndex = 0;
|
||||||
|
double _systemScreenWidth = 400;
|
||||||
|
double _overlayWidth = 280;
|
||||||
|
double _overlayHeight = 140;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
print('[Overlay] 🟢 CREATED - Floating window initialized');
|
||||||
|
_getSystemScreenSize();
|
||||||
|
_listenToMainAppMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _getSystemScreenSize() {
|
||||||
|
try {
|
||||||
|
// Get actual system screen resolution, not just app window size
|
||||||
|
final window = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||||
|
final physicalSize = window.physicalSize;
|
||||||
|
final devicePixelRatio = window.devicePixelRatio;
|
||||||
|
final systemSize = physicalSize / devicePixelRatio;
|
||||||
|
|
||||||
|
print('[Overlay] 🔍 Screen detection:');
|
||||||
|
print(' physicalSize: ${physicalSize.width.round()}x${physicalSize.height.round()}');
|
||||||
|
print(' devicePixelRatio: $devicePixelRatio');
|
||||||
|
print(' calculated systemSize: ${systemSize.width.round()}x${systemSize.height.round()}');
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_systemScreenWidth = systemSize.width;
|
||||||
|
});
|
||||||
|
|
||||||
|
print('[Overlay] ✅ _systemScreenWidth set to: ${_systemScreenWidth.round()}');
|
||||||
|
} catch (e) {
|
||||||
|
print('[Overlay] ❌ Error getting system screen size: $e');
|
||||||
|
// Fallback to reasonable default
|
||||||
|
setState(() {
|
||||||
|
_systemScreenWidth = 400;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _listenToMainAppMessages() {
|
||||||
|
FlutterOverlayWindow.overlayListener.listen((data) {
|
||||||
|
if (data is Map && data['action'] == 'updateDisplay') {
|
||||||
|
setState(() {
|
||||||
|
_speedText = data['speedText'] ?? '--';
|
||||||
|
_headingText = data['headingText'] ?? 'N/A';
|
||||||
|
_heading = data['heading']?.toDouble() ?? -1.0;
|
||||||
|
_currentThemeIndex = data['themeIndex'] ?? 0;
|
||||||
|
// Update screen size and overlay dimensions if provided by main app
|
||||||
|
if (data.containsKey('systemScreenWidth')) {
|
||||||
|
_systemScreenWidth = data['systemScreenWidth']?.toDouble() ?? _systemScreenWidth;
|
||||||
|
}
|
||||||
|
if (data.containsKey('overlayWidth')) {
|
||||||
|
_overlayWidth = data['overlayWidth']?.toDouble() ?? _overlayWidth;
|
||||||
|
}
|
||||||
|
if (data.containsKey('overlayHeight')) {
|
||||||
|
_overlayHeight = data['overlayHeight']?.toDouble() ?? _overlayHeight;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
print('[Overlay] 📡 UPDATE received:');
|
||||||
|
print(' speedText: "$_speedText"');
|
||||||
|
print(' headingText: "$_headingText"');
|
||||||
|
print(' direction: ${_heading.toStringAsFixed(1)}°');
|
||||||
|
print(' themeIndex: $_currentThemeIndex');
|
||||||
|
print(' systemScreenWidth: ${_systemScreenWidth.round()}');
|
||||||
|
print(' overlaySize from main: ${_overlayWidth.round()}x${_overlayHeight.round()}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
print('[Overlay] 🔴 DESTROYED - Floating window disposed');
|
||||||
|
// No GPS subscription to cancel - overlay is display-only
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final currentTheme = ColorThemes.getTheme(_currentThemeIndex);
|
||||||
|
|
||||||
|
// Use overlay dimensions provided by main app (not calculated locally)
|
||||||
|
final fontSize = (_overlayWidth * 0.2); // Font size proportional to actual overlay width
|
||||||
|
|
||||||
|
print('[Overlay] 📐 Window size: ${_overlayWidth.round()}x${_overlayHeight.round()}, fontSize: ${fontSize.round()}');
|
||||||
|
|
||||||
|
return Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SizedBox(
|
||||||
|
// Use SizedBox to fill the overlay window completely
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: currentTheme.background.withOpacity(0.85),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: currentTheme.speedText.withOpacity(0.3),
|
||||||
|
width: 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// Main content - landscape layout (1:1 flex as per NOTES.txt)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
// Speed section - left half
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Center(
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Text(
|
||||||
|
_speedText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize,
|
||||||
|
fontWeight: FontWeight.w300,
|
||||||
|
color: currentTheme.speedText,
|
||||||
|
fontFamily: 'DIN1451Alt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Direction section - right half (same as full-screen behavior)
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
flex: 2,
|
||||||
|
child: Transform.rotate(
|
||||||
|
angle: (_heading >= 0 && _heading < 360) ? (_heading * math.pi / 180.0) : 0,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Icon(
|
||||||
|
Icons.navigation,
|
||||||
|
size: fontSize * 0.8,
|
||||||
|
color: currentTheme.headingText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Text(
|
||||||
|
_headingText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize * 0.4,
|
||||||
|
color: currentTheme.headingText,
|
||||||
|
fontFamily: 'DIN1451Alt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Semi-transparent close button (only interaction as per NOTES.txt)
|
||||||
|
Positioned(
|
||||||
|
top: 4,
|
||||||
|
right: 4,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => FlutterOverlayWindow.closeOverlay(),
|
||||||
|
child: Container(
|
||||||
|
width: _overlayHeight * 0.2,
|
||||||
|
height: _overlayHeight * 0.2,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.red.withOpacity(0.6),
|
||||||
|
borderRadius: BorderRadius.circular(_overlayHeight * 0.1),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.white.withOpacity(0.8),
|
||||||
|
width: 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: Colors.white.withOpacity(0.9),
|
||||||
|
size: _overlayHeight * 0.15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,6 +134,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
flutter_overlay_window:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_overlay_window
|
||||||
|
sha256: "17988420249da68e421d1b44b511e6113d3de7a9e52c3fbd6d99730508af4580"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
+5
-1
@@ -2,7 +2,7 @@ name: gps_speedo
|
|||||||
description: "Speedo - A Flutter application."
|
description: "Speedo - A Flutter application."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 2.0.0+1
|
version: 2.1.0+2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.0
|
sdk: ^3.9.0
|
||||||
@@ -21,6 +21,10 @@ dependencies:
|
|||||||
# Keep screen awake during navigation
|
# Keep screen awake during navigation
|
||||||
wakelock_plus: ^1.2.8
|
wakelock_plus: ^1.2.8
|
||||||
|
|
||||||
|
# Floating window overlay capability
|
||||||
|
flutter_overlay_window: ^0.5.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
Reference in New Issue
Block a user