Files
PeachDeployments/lib/Peach/see/splash/ViewSplash.dart
alvocool 38881d1fe1 Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:15:30 +03:00

29 lines
988 B
Dart

import '../parent/ParentViewModel.dart';
import 'ConnectSplash.dart';
class ViewSplash extends ParentViewModel {
ConnectSplash connection;
ViewSplash(super.context, this.connection);
/// Reads the stored servers, deployment history and theme preference, then
/// hands them to the screen. The splash is deliberately held for a minimum
/// duration so a fast read doesn't make it flash.
void bootstrap() async {
final started = DateTime.now();
try {
final servers = await getDataManager().getServers();
final history = await getDataManager().getDeployments();
final themeMode = await getDataManager().getThemeMode();
const minShow = Duration(milliseconds: 1300);
final elapsed = DateTime.now().difference(started);
if (elapsed < minShow) await Future.delayed(minShow - elapsed);
connection.onBootstrapped(servers, history, themeMode);
} catch (error) {
handleError(error, bootstrap, () {}, "Retry");
}
}
}