feat(home): 启动页停留至首页就绪

This commit is contained in:
Zhou Weidong committed 2026-10-20 19:57:13 +08:00
1 parent c76b388814
commit 7871b0cfbb
3 files changed
+221 -9

No files matched your search

+36 -9
View File
@@ -37,6 +37,11 @@ class HomePage extends StatefulWidget {
}
class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
static const _androidSplashAsset = 'assets/icon/splash_logo_android12.png';
static const _defaultSplashAsset = 'assets/icon/splash_logo.png';
static const _androidSplashSize = 288.0;
static const _defaultSplashSize = 384.0;
bool _resumeRetryInFlight = false;
@override
@@ -100,15 +105,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
AppLocalizations l10n,
) {
if (catalog.loading) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: const Scaffold(
backgroundColor: AppColors.splashInk,
body: Center(
child: CircularProgressIndicator(color: AppColors.blue),
),
),
);
return catalog.settled ? _retryLoading() : _startupSplash();
}
if (catalog.error != null) {
return Scaffold(
@@ -140,6 +137,36 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
onRefreshFeed: catalog.refresh,
);
}
Widget _startupSplash() {
final isAndroid = defaultTargetPlatform == TargetPlatform.android;
final size = isAndroid ? _androidSplashSize : _defaultSplashSize;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: ColoredBox(
color: AppColors.splashInk,
child: Center(
child: Image.asset(
isAndroid ? _androidSplashAsset : _defaultSplashAsset,
key: const Key('startup-splash'),
width: size,
height: size,
fit: BoxFit.contain,
),
),
),
);
}
Widget _retryLoading() {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: const Scaffold(
backgroundColor: AppColors.splashInk,
body: Center(child: CircularProgressIndicator(color: AppColors.blue)),
),
);
}
}
/// 首页目录加载失败与重试入口。