new python build-deploy chain
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
@@ -19,13 +21,64 @@ class SmartSerowApp extends StatelessWidget {
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
home: const HomePage(),
|
||||
home: const AppRoot(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
/// Root widget that manages app state transitions
|
||||
class AppRoot extends StatefulWidget {
|
||||
const AppRoot({super.key});
|
||||
|
||||
@override
|
||||
State<AppRoot> createState() => _AppRootState();
|
||||
}
|
||||
|
||||
class _AppRootState extends State<AppRoot> {
|
||||
bool _initialized = false;
|
||||
String _initStatus = 'Starting...';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_runInitSequence();
|
||||
}
|
||||
|
||||
Future<void> _runInitSequence() async {
|
||||
// Simulate init checks - replace with real checks later
|
||||
// (UART, GPS, sensors, etc.)
|
||||
|
||||
setState(() => _initStatus = 'Checking systems...');
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
|
||||
setState(() => _initStatus = 'UART: standby');
|
||||
await Future.delayed(const Duration(milliseconds: 400));
|
||||
|
||||
setState(() => _initStatus = 'GPS: standby');
|
||||
await Future.delayed(const Duration(milliseconds: 400));
|
||||
|
||||
setState(() => _initStatus = 'Ready');
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
|
||||
setState(() => _initialized = true);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
child: _initialized
|
||||
? const DashboardScreen(key: ValueKey('dashboard'))
|
||||
: SplashScreen(key: const ValueKey('splash'), status: _initStatus),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Splash screen - shown during initialization
|
||||
class SplashScreen extends StatelessWidget {
|
||||
final String status;
|
||||
|
||||
const SplashScreen({super.key, required this.status});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -48,9 +101,9 @@ class HomePage extends StatelessWidget {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'System Ready',
|
||||
status,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: Colors.grey,
|
||||
),
|
||||
@@ -61,3 +114,141 @@ class HomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Main dashboard - placeholder with random updating values
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
const DashboardScreen({super.key});
|
||||
|
||||
@override
|
||||
State<DashboardScreen> createState() => _DashboardScreenState();
|
||||
}
|
||||
|
||||
class _DashboardScreenState extends State<DashboardScreen> {
|
||||
final _random = Random();
|
||||
Timer? _timer;
|
||||
|
||||
int _speed = 0;
|
||||
int _rpm = 0;
|
||||
double _voltage = 12.6;
|
||||
int _temp = 25;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Update random values every 500ms - simulates live data
|
||||
_timer = Timer.periodic(const Duration(milliseconds: 500), (_) {
|
||||
setState(() {
|
||||
_speed = _random.nextInt(120);
|
||||
_rpm = 1000 + _random.nextInt(8000);
|
||||
_voltage = 11.5 + _random.nextDouble() * 2;
|
||||
_temp = 20 + _random.nextInt(60);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'SMART SEROW',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Colors.teal,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${_voltage.toStringAsFixed(1)}V',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: _voltage < 12.0 ? Colors.red : Colors.green,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// Main speed display
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'$_speed',
|
||||
style: const TextStyle(
|
||||
fontSize: 180,
|
||||
fontWeight: FontWeight.w200,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'km/h',
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Bottom stats row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_StatBox(label: 'RPM', value: _rpm.toString()),
|
||||
_StatBox(label: 'TEMP', value: '$_temp°C'),
|
||||
_StatBox(label: 'GEAR', value: '—'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StatBox extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const _StatBox({required this.label, required this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Colors.grey,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user