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
Widget build(BuildContext context) {
final url = AppConfig.mediaUrl(path);
if (url.isEmpty) return _fallback();
if (url.isEmpty) return _fallback(brand: showFallbackIcon);
return Image.network(
url,
width: width,
height: height,
fit: fit,
errorBuilder: (_, _, _) => _fallback(),
gaplessPlayback: true,
errorBuilder: (_, _, _) => _fallback(brand: showFallbackIcon),
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
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(
width: width,
height: height,
color: fallbackColor,
color: brand ? AppColors.mediaBlack : fallbackColor,
alignment: Alignment.center,
child: showFallbackIcon
? Icon(
Icons.image_not_supported_outlined,
key: fallbackIconKey,
color: AppColors.muted,
size: 32,
)
: null,
child: mark,
);
final ratio = fallbackAspectRatio;
if (ratio == null) return fallback;