fix(cover): 封面占位改为品牌标识

This commit is contained in:
Zhou Weidong committed 2026-10-23 03:18:24 +08:00
1 parent 5043d6c25b
commit e0ba54f23b
1 file changed
+24 -13
+24 -13
View File
@@ -31,34 +31,45 @@ class RemoteImage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final url = AppConfig.mediaUrl(path); final url = AppConfig.mediaUrl(path);
if (url.isEmpty) return _fallback(); if (url.isEmpty) return _fallback(brand: showFallbackIcon);
return Image.network( return Image.network(
url, url,
width: width, width: width,
height: height, height: height,
fit: fit, fit: fit,
errorBuilder: (_, _, _) => _fallback(), gaplessPlayback: true,
errorBuilder: (_, _, _) => _fallback(brand: showFallbackIcon),
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) { frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
if (wasSynchronouslyLoaded || frame != null) return child; if (wasSynchronouslyLoaded || frame != null) return child;
return _fallback(); return _fallback(brand: showFallbackIcon);
}, },
); );
} }
Widget _fallback() { Widget _fallback({required bool brand}) {
final mark = brand
? LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth.isFinite
? constraints.maxWidth
: 120.0;
return Center(
child: Image.asset(
'assets/icon/splash_logo.png',
key: fallbackIconKey,
width: width * 0.72,
fit: BoxFit.contain,
),
);
},
)
: null;
final fallback = Container( final fallback = Container(
width: width, width: width,
height: height, height: height,
color: fallbackColor, color: brand ? AppColors.mediaBlack : fallbackColor,
alignment: Alignment.center, alignment: Alignment.center,
child: showFallbackIcon child: mark,
? Icon(
Icons.image_not_supported_outlined,
key: fallbackIconKey,
color: AppColors.muted,
size: 32,
)
: null,
); );
final ratio = fallbackAspectRatio; final ratio = fallbackAspectRatio;
if (ratio == null) return fallback; if (ratio == null) return fallback;