multiple updates
- colour theme implemented. ThemeService based global switching for future light detection triggers - test flipflop service for various fun - navigator widget class with state switching
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../services/config_service.dart';
|
||||
import '../services/pi_io.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/navigator_widget.dart';
|
||||
import '../widgets/stat_box.dart';
|
||||
|
||||
// test service for triggers
|
||||
import '../services/test_flipflop_service.dart';
|
||||
|
||||
/// Main dashboard - displays Pi vitals and placeholder stats
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
const DashboardScreen({super.key});
|
||||
@@ -17,6 +20,7 @@ class DashboardScreen extends StatefulWidget {
|
||||
|
||||
class _DashboardScreenState extends State<DashboardScreen> {
|
||||
final _random = Random();
|
||||
final _navigatorKey = GlobalKey<NavigatorWidgetState>();
|
||||
Timer? _timer;
|
||||
|
||||
double? _piTemp;
|
||||
@@ -40,33 +44,24 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
_temp = 20 + _random.nextInt(60);
|
||||
});
|
||||
});
|
||||
|
||||
// DEBUG: flip-flop theme + navigator every 2s
|
||||
TestFlipFlopService.instance.start(navigatorKey: _navigatorKey);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
TestFlipFlopService.instance.stop();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Build navigator image from filesystem
|
||||
Widget _buildNavigatorImage() {
|
||||
final config = ConfigService.instance;
|
||||
final imagePath = '${config.assetsPath}/navigator/${config.navigator}/default.png';
|
||||
|
||||
return Image.file(
|
||||
File(imagePath),
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
// Graceful fallback - empty box if image missing
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = AppTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
backgroundColor: theme.background,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Row(
|
||||
@@ -84,20 +79,20 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Text(
|
||||
'SMART SEROW',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Colors.teal,
|
||||
color: theme.subdued,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${_voltage.toStringAsFixed(1)}V',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: _voltage < 12.0 ? Colors.red : Colors.green,
|
||||
color: _voltage < 12.0 ? theme.highlight : theme.foreground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 48),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Main Pi temperature display
|
||||
Expanded(
|
||||
@@ -107,17 +102,17 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
children: [
|
||||
Text(
|
||||
_piTemp != null ? _piTemp!.toStringAsFixed(1) : '—',
|
||||
style: const TextStyle(
|
||||
fontSize: 180,
|
||||
style: TextStyle(
|
||||
fontSize: 250,
|
||||
fontWeight: FontWeight.w200,
|
||||
color: Colors.white,
|
||||
color: theme.foreground,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Pi Temp',
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
color: Colors.grey,
|
||||
color: theme.subdued,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -144,7 +139,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: _buildNavigatorImage(),
|
||||
child: NavigatorWidget(key: _navigatorKey),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../services/config_service.dart';
|
||||
import '../services/pi_io.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
/// Overheat warning screen with shutdown countdown
|
||||
///
|
||||
@@ -81,30 +82,31 @@ class _OverheatScreenState extends State<OverheatScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = AppTheme.of(context);
|
||||
final threshold = ConfigService.instance.overheatThreshold;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
backgroundColor: theme.background,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Warning icon
|
||||
const Icon(
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 100,
|
||||
color: Colors.red,
|
||||
color: theme.highlight,
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// OVERHEATING text
|
||||
const Text(
|
||||
Text(
|
||||
'OVERHEATING',
|
||||
style: TextStyle(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
color: theme.highlight,
|
||||
letterSpacing: 4,
|
||||
),
|
||||
),
|
||||
@@ -114,10 +116,10 @@ class _OverheatScreenState extends State<OverheatScreen> {
|
||||
// Current temperature
|
||||
Text(
|
||||
_currentTemp != null ? '${_currentTemp!.toStringAsFixed(1)}°C' : '—',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 120,
|
||||
fontWeight: FontWeight.w200,
|
||||
color: Colors.white,
|
||||
color: theme.foreground,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
@@ -127,9 +129,9 @@ class _OverheatScreenState extends State<OverheatScreen> {
|
||||
// Threshold info
|
||||
Text(
|
||||
'Threshold: ${threshold.toStringAsFixed(0)}°C',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey,
|
||||
color: theme.subdued,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -138,9 +140,9 @@ class _OverheatScreenState extends State<OverheatScreen> {
|
||||
// Countdown
|
||||
Text(
|
||||
'Shutdown in $_secondsRemaining s',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
color: Colors.orange,
|
||||
color: theme.highlight,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
/// Splash screen - shown during initialization
|
||||
class SplashScreen extends StatelessWidget {
|
||||
final String status;
|
||||
@@ -8,8 +10,10 @@ class SplashScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = AppTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
backgroundColor: theme.background,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -17,13 +21,13 @@ class SplashScreen extends StatelessWidget {
|
||||
Icon(
|
||||
Icons.terrain,
|
||||
size: 120,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: theme.subdued,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Smart Serow',
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
color: theme.foreground,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -31,7 +35,7 @@ class SplashScreen extends StatelessWidget {
|
||||
Text(
|
||||
status,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: Colors.grey,
|
||||
color: theme.subdued,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user