refactor(empty-state): 空状态支持内容居中

This commit is contained in:
Zhou Weidong committed 2026-11-02 14:44:38 +08:00
1 parent 59fbd33059
commit 7463d3ee26
8 files changed
+131 -80

No files matched your search

+3 -3
View File
@@ -69,7 +69,7 @@ void main() {
semantics.dispose();
});
testWidgets('should_render_compact_dimensions_for_embedded_empty_state', (
testWidgets('should_keep_standard_icon_size_in_compact_empty_state', (
tester,
) async {
await _pump(
@@ -83,7 +83,7 @@ void main() {
expect(
tester.getSize(find.byKey(const Key('empty-state-icon'))),
const Size(44, 44),
const Size(72, 72),
);
expect(find.byType(DecoratedBox), findsNothing);
expect(
@@ -97,7 +97,7 @@ void main() {
tester
.widget<Padding>(find.byKey(const Key('empty-state-padding')))
.padding,
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
);
expect(find.byKey(const Key('empty-state-action')), findsNothing);
});
+8
View File
@@ -174,6 +174,14 @@ void main() {
expect(find.byKey(const Key('favorites-empty')), findsOneWidget);
expect(find.byType(EmptyState), findsOneWidget);
final viewport = tester.getRect(
find.byKey(const Key('favorites-empty-scroll')),
);
final content = tester.getRect(
find.byKey(const Key('empty-state-content')),
);
expect(content.center.dx, closeTo(viewport.center.dx, 0.1));
expect(content.center.dy, closeTo(viewport.center.dy, 0.1));
});
testWidgets('should_show_retry_when_favorite_list_fails', (tester) async {
+21
View File
@@ -209,6 +209,27 @@ void main() {
expect(find.text('The Signal'), findsOneWidget);
});
testWidgets('should_center_empty_state_in_remaining_page_space', (
tester,
) async {
final auth = await _auth(signedIn: true);
await _pumpPage(
tester,
auth: auth,
history: CountingWatchHistory(const []),
catalog: FakeCatalogRepository(),
);
final viewport = tester.getRect(
find.byKey(const Key('watch-records-empty-scroll')),
);
final content = tester.getRect(
find.byKey(const Key('empty-state-content')),
);
expect(content.center.dx, closeTo(viewport.center.dx, 0.1));
expect(content.center.dy, closeTo(viewport.center.dy, 0.1));
});
testWidgets('should_remove_and_clear_device_history_when_signed_out', (
tester,
) async {