ui accelerometer compsensations and visual tweaks

This commit is contained in:
Mikkeli Matlock
2026-02-05 00:00:38 +09:00
parent 8044bbde94
commit 7d8f813b59
6 changed files with 108 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
@@ -42,8 +43,11 @@ class _AppRootState extends State<AppRoot> {
await Future.delayed(const Duration(milliseconds: 500));
// Check UART connection via backend health endpoint
// Also preload navigator images in parallel (usually UART is the bottleneck)
setState(() => _initStatus = 'UART: connecting...');
final imagePreloadFuture = _preloadNavigatorImages();
await _waitForUart();
await imagePreloadFuture;
setState(() => _initStatus = 'GPS: standby');
await Future.delayed(const Duration(milliseconds: 400));
@@ -97,6 +101,20 @@ class _AppRootState extends State<AppRoot> {
await Future.delayed(const Duration(milliseconds: 500));
}
/// Preload navigator images into Flutter's image cache
///
/// Scans for all PNGs in the navigator folder and precaches them.
/// Runs silently - no status updates (meant to run parallel with UART).
Future<void> _preloadNavigatorImages() async {
final images = await ConfigService.instance.getNavigatorImages();
for (final file in images) {
// precacheImage needs a context, but we're in initState territory
// Use the root context via a post-frame callback workaround
if (!mounted) return;
await precacheImage(FileImage(file), context);
}
}
@override
Widget build(BuildContext context) {
// Determine which screen to show (priority: overheat > splash > dashboard)