import 'package:flutter/material.dart'; import 'features/app_shell.dart'; import 'services/adb_service.dart'; import 'services/artifact_staging_service.dart'; import 'services/jenkins_artifact_session.dart'; import 'services/jenkins_client.dart'; import 'services/token_store.dart'; import 'theme/app_theme.dart'; class AppSokApp extends StatefulWidget { const AppSokApp({ super.key, this.tokenStore, this.jenkinsClient, this.artifactStagingService, this.session, this.adbDiagnosticsLoader, }); final TokenStore? tokenStore; final JenkinsClient? jenkinsClient; final ArtifactStagingService? artifactStagingService; final JenkinsArtifactSession? session; final AdbDiagnosticsLoader? adbDiagnosticsLoader; @override State createState() => _AppSokAppState(); } class _AppSokAppState extends State { late final JenkinsArtifactSession _session = widget.session ?? JenkinsArtifactSession( store: widget.tokenStore ?? TokenStore(), client: widget.jenkinsClient ?? JenkinsClient(), stager: widget.artifactStagingService ?? ArtifactStagingService(), ); late final AdbService _adbService = AdbService(); late final Future _startup = _session.restore(); @override Widget build(BuildContext context) { return FutureBuilder( future: _startup, builder: (context, snapshot) { final isReady = snapshot.data ?? false; return MaterialApp( debugShowCheckedModeBanner: false, title: 'AppSok', theme: AppTheme.light(), home: AppSokShell( jobLoader: isReady ? _session.loadJobs : null, buildLoader: isReady ? _session.loadBuilds : null, artifactDownloader: isReady ? _session.downloadArtifact : null, artifactStager: isReady ? _session.stageApk : null, artifactCleaner: isReady ? _session.cleanup : null, adbDiagnosticsLoader: widget.adbDiagnosticsLoader ?? _adbService.collectDiagnostics, ), ); }, ); } }