feat(flutter): 精简首页标题并重做空态视觉

This commit is contained in:
Zhou Weidong committed 2026-10-17 22:44:21 +08:00
1 parent b5a8656ff0
commit 2dd4627bdc
5 files changed
+127 -63

No files matched your search

+48 -23
View File
@@ -4,15 +4,17 @@ import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
const double _regularArtSize = 96;
const double _compactArtSize = 64;
const double _regularIconSize = 42;
const double _compactIconSize = 28;
const double _regularRadius = 28;
const double _compactRadius = 18;
const double _maxContentWidth = 280;
const double _regularArtSize = 84;
const double _compactArtSize = 60;
const double _regularInnerSize = 56;
const double _compactInnerSize = 40;
const double _regularIconSize = 27;
const double _compactIconSize = 21;
const double _maxContentWidth = 260;
const double _actionMinHeight = 44;
const double _artOpacity = 0.11;
const double _outerArtOpacity = 0.055;
const double _outerBorderOpacity = 0.11;
const double _innerArtOpacity = 0.11;
/// 统一空列表占位:柔和图标、标题、可选说明与操作。
class EmptyState extends StatelessWidget {
@@ -39,6 +41,7 @@ class EmptyState extends StatelessWidget {
final dark = Theme.of(context).brightness == Brightness.dark;
final iconColor = dark ? AppColors.blueSoft : AppColors.blue;
final artSize = compact ? _compactArtSize : _regularArtSize;
final innerSize = compact ? _compactInnerSize : _regularInnerSize;
final iconSize = compact ? _compactIconSize : _regularIconSize;
final hasAction = actionLabel != null && onAction != null;
return Center(
@@ -46,7 +49,11 @@ class EmptyState extends StatelessWidget {
key: const Key('empty-state-content'),
constraints: const BoxConstraints(maxWidth: _maxContentWidth),
child: Padding(
padding: EdgeInsets.all(compact ? 16 : 24),
key: const Key('empty-state-padding'),
padding: EdgeInsets.symmetric(
horizontal: compact ? 16 : 24,
vertical: compact ? 16 : 28,
),
child: Semantics(
container: true,
label: title,
@@ -60,20 +67,35 @@ class EmptyState extends StatelessWidget {
height: artSize,
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.blue.withValues(alpha: _artOpacity),
borderRadius: BorderRadius.circular(
compact ? _compactRadius : _regularRadius,
shape: BoxShape.circle,
color: AppColors.blue.withValues(alpha: _outerArtOpacity),
border: Border.all(
color: AppColors.blue.withValues(
alpha: _outerBorderOpacity,
),
),
),
child: Icon(
icon,
key: const Key('empty-state-icon'),
size: iconSize,
color: iconColor,
child: Container(
key: const Key('empty-state-art-inner'),
width: innerSize,
height: innerSize,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.blue.withValues(
alpha: _innerArtOpacity,
),
),
child: Icon(
icon,
key: const Key('empty-state-icon'),
size: iconSize,
color: iconColor,
),
),
),
),
SizedBox(height: compact ? 10 : 16),
SizedBox(height: compact ? 10 : 14),
ExcludeSemantics(
child: Text(
title,
@@ -83,7 +105,7 @@ class EmptyState extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
color: scheme.onSurface,
fontSize: compact ? 14 : 16,
fontSize: 15,
fontWeight: FontWeight.w600,
height: 1.35,
),
@@ -99,14 +121,14 @@ class EmptyState extends StatelessWidget {
textAlign: TextAlign.center,
style: const TextStyle(
color: AppColors.muted,
fontSize: 13,
height: 1.4,
fontSize: 12.5,
height: 1.45,
),
),
),
],
if (hasAction) ...[
const SizedBox(height: 10),
const SizedBox(height: 8),
TextButton(
key: const Key('empty-state-action'),
onPressed: onAction,
@@ -115,7 +137,10 @@ class EmptyState extends StatelessWidget {
minimumSize: const Size(44, _actionMinHeight),
padding: const EdgeInsets.symmetric(horizontal: 14),
),
child: Text(actionLabel!),
child: Text(
actionLabel!,
style: const TextStyle(fontSize: 13),
),
),
],
],
+3 -18
View File
@@ -144,24 +144,8 @@ class _DiscoverPageState extends State<DiscoverPage> {
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 18, 16, 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_categories(l10n, categories),
const SizedBox(height: 18),
Text(
l10n.allDramas,
key: const Key('home-all-dramas-title'),
style: const TextStyle(
color: AppColors.onPrimary,
fontSize: 18,
fontWeight: FontWeight.w700,
height: 1.2,
),
),
],
),
padding: const EdgeInsets.fromLTRB(16, 18, 16, 14),
child: _categories(l10n, categories),
),
),
_HomeDramaGrid(
@@ -277,6 +261,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
(code: 'category-${category.id}', label: category.name),
];
return SizedBox(
key: const Key('home-category-chips'),
height: 32,
child: ListView.separated(
scrollDirection: Axis.horizontal,