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

+15 -4
View File
@@ -37,13 +37,24 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Continue Watching'), findsNothing);
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-title')), findsNothing);
expect(find.text('All'), findsOneWidget);
expect(find.text('For You'), findsNothing);
expect(
tester.getCenter(find.text('All')).dx,
lessThan(tester.getCenter(find.text('Hot')).dx),
);
expect(
tester
.getTopLeft(
find.byKey(const Key('home-drama-card-the-signal-demo')),
)
.dy -
tester
.getBottomLeft(find.byKey(const Key('home-category-chips')))
.dy,
closeTo(14, 0.1),
);
final grid = tester.widget<SliverGrid>(
find.byKey(const Key('home-all-dramas-grid')),
@@ -135,7 +146,7 @@ void main() {
await tester.tap(find.byKey(const Key('tab-discover')));
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-title')), findsNothing);
expect(find.text('No matching dramas.'), findsOneWidget);
await tester.tap(find.text('Romance'));
@@ -154,7 +165,7 @@ void main() {
await tester.tap(find.byKey(const Key('tab-discover')));
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-title')), findsNothing);
expect(find.text('Categories could not be loaded.'), findsOneWidget);
expect(find.text('Retry'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing);
@@ -176,7 +187,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-title')), findsNothing);
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
expect(tester.takeException(), isNull);
});
+44 -7
View File
@@ -23,24 +23,51 @@ void main() {
);
expect(find.byKey(const Key('empty-state-art')), findsOneWidget);
expect(find.byKey(const Key('empty-state-art-inner')), findsOneWidget);
expect(find.byKey(const Key('empty-state-icon')), findsOneWidget);
expect(find.text('No stories'), findsOneWidget);
expect(find.text('New content will appear here.'), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('empty-state-art'))),
const Size(96, 96),
const Size(84, 84),
);
expect(
tester.getSize(find.byKey(const Key('empty-state-art-inner'))),
const Size(56, 56),
);
expect(
tester.getSize(find.byKey(const Key('empty-state-icon'))),
const Size(42, 42),
const Size(27, 27),
);
final outer = tester.widget<Container>(
find.byKey(const Key('empty-state-art')),
);
final outerDecoration = outer.decoration! as BoxDecoration;
expect(outerDecoration.shape, BoxShape.circle);
expect(outerDecoration.color?.a, closeTo(0.055, 0.001));
expect(outerDecoration.border!.top.color.a, closeTo(0.11, 0.001));
final inner = tester.widget<Container>(
find.byKey(const Key('empty-state-art-inner')),
);
expect((inner.decoration! as BoxDecoration).color?.a, closeTo(0.11, 0.001));
expect(
tester
.widget<Padding>(find.byKey(const Key('empty-state-padding')))
.padding,
const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
);
expect(
tester
.widget<Text>(find.byKey(const Key('empty-state-title')))
.style
?.fontSize,
16,
15,
);
final subtitle = tester.widget<Text>(
find.text('New content will appear here.'),
);
expect(subtitle.style?.fontSize, 12.5);
expect(tester.widget<Text>(find.text('Retry')).style?.fontSize, 13);
expect(
tester.getSize(find.byKey(const Key('empty-state-action'))).height,
greaterThanOrEqualTo(44),
@@ -72,18 +99,28 @@ void main() {
expect(
tester.getSize(find.byKey(const Key('empty-state-art'))),
const Size(64, 64),
const Size(60, 60),
);
expect(
tester.getSize(find.byKey(const Key('empty-state-art-inner'))),
const Size(40, 40),
);
expect(
tester.getSize(find.byKey(const Key('empty-state-icon'))),
const Size(28, 28),
const Size(21, 21),
);
expect(
tester
.widget<Text>(find.byKey(const Key('empty-state-title')))
.style
?.fontSize,
14,
15,
);
expect(
tester
.widget<Padding>(find.byKey(const Key('empty-state-padding')))
.padding,
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
);
expect(find.byKey(const Key('empty-state-action')), findsNothing);
});
@@ -129,7 +166,7 @@ void main() {
final content = tester.widget<ConstrainedBox>(
find.byKey(const Key('empty-state-content')),
);
expect(content.constraints.maxWidth, 280);
expect(content.constraints.maxWidth, 260);
expect(tester.takeException(), isNull);
});
}
+17 -11
View File
@@ -155,7 +155,7 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(
@@ -186,15 +186,17 @@ void main() {
.active,
isFalse,
);
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('drawer-discover')));
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(
Navigator.of(tester.element(find.text('All Dramas'))).canPop(),
Navigator.of(
tester.element(find.byKey(const Key('home-all-dramas-grid'))),
).canPop(),
isFalse,
);
},
@@ -313,7 +315,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('All'), findsOneWidget);
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.text('Rewards'), findsOneWidget);
expect(find.text(r'$ 0'), findsOneWidget);
expect(find.text('Urban Romance', skipOffstage: false), findsOneWidget);
@@ -345,10 +347,12 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.text('Home'));
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.byTooltip('Search'), findsNothing);
expect(
Navigator.of(tester.element(find.text('All Dramas'))).canPop(),
Navigator.of(
tester.element(find.byKey(const Key('home-all-dramas-grid'))),
).canPop(),
isFalse,
);
@@ -365,10 +369,12 @@ void main() {
await tester.tap(find.byKey(const Key('tab-discover')));
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.byTooltip('Search'), findsNothing);
expect(
Navigator.of(tester.element(find.text('All Dramas'))).canPop(),
Navigator.of(
tester.element(find.byKey(const Key('home-all-dramas-grid'))),
).canPop(),
isFalse,
);
await tester.tap(find.byKey(const Key('tab-my-list')));
@@ -564,7 +570,7 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.text('Quick access'), findsOneWidget);
@@ -572,7 +578,7 @@ void main() {
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.text('Quick access'), findsNothing);
expect(find.text('All Dramas'), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(
Navigator.of(
tester.element(find.byKey(const Key('home-tabs-bar'))),