fix(client): 商品公开页暂无图片时显示门店名首字,替换硬编码岩美
Deploy / deploy (push) Successful in 1m20s

_EmptyGalleryContent 接收 shopName 参数,无图片时展示
门店名第一个字符的文字头像,不再显示品牌名。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-05-24 20:59:17 +08:00
parent b591bc522d
commit d48f9f4bd0
@@ -130,7 +130,7 @@ class _PublicProductScreenState extends State<PublicProductScreen> {
slivers: [ slivers: [
// 1. Gallery // 1. Gallery
SliverToBoxAdapter( SliverToBoxAdapter(
child: _HeroGallery(imageUrls: imageUrls), child: _HeroGallery(imageUrls: imageUrls, shopName: shop?['name'] as String? ?? ''),
), ),
// 2. Verified ribbon // 2. Verified ribbon
SliverToBoxAdapter( SliverToBoxAdapter(
@@ -227,7 +227,8 @@ class _PublicProductScreenState extends State<PublicProductScreen> {
class _HeroGallery extends StatefulWidget { class _HeroGallery extends StatefulWidget {
final List<String> imageUrls; final List<String> imageUrls;
const _HeroGallery({required this.imageUrls}); final String shopName;
const _HeroGallery({required this.imageUrls, this.shopName = ''});
@override @override
State<_HeroGallery> createState() => _HeroGalleryState(); State<_HeroGallery> createState() => _HeroGalleryState();
@@ -280,7 +281,7 @@ class _HeroGalleryState extends State<_HeroGallery> {
), ),
// Image or placeholder // Image or placeholder
if (urls.isEmpty) if (urls.isEmpty)
_EmptyGalleryContent() _EmptyGalleryContent(shopName: widget.shopName)
else else
PageView.builder( PageView.builder(
controller: _ctrl, controller: _ctrl,
@@ -291,7 +292,7 @@ class _HeroGalleryState extends State<_HeroGallery> {
child: Image.network( child: Image.network(
urls[i], urls[i],
fit: BoxFit.contain, fit: BoxFit.contain,
errorBuilder: (_, __, ___) => _EmptyGalleryContent(), errorBuilder: (_, __, ___) => _EmptyGalleryContent(shopName: widget.shopName),
), ),
), ),
), ),
@@ -409,8 +410,12 @@ class _HeroGalleryState extends State<_HeroGallery> {
} }
class _EmptyGalleryContent extends StatelessWidget { class _EmptyGalleryContent extends StatelessWidget {
final String shopName;
const _EmptyGalleryContent({this.shopName = ''});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final initial = shopName.isNotEmpty ? shopName.characters.first : '';
return Center( return Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -421,9 +426,9 @@ class _EmptyGalleryContent extends StatelessWidget {
color: const Color(0xFF0F3057), color: const Color(0xFF0F3057),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Center( child: Center(
child: Text('岩美', child: Text(initial,
style: TextStyle(color: Colors.white70, fontSize: 18, fontWeight: FontWeight.w700)), style: const TextStyle(color: Colors.white70, fontSize: 28, fontWeight: FontWeight.w700)),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),