feat(flutter): 首页网格改为三列并首位显示全部

This commit is contained in:
Zhou Weidong committed 2026-10-17 22:34:14 +08:00
1 parent 0466b4b425
commit f0db631fa2
4 files changed
+17 -11

No files matched your search

+1 -1
View File
@@ -270,7 +270,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
Widget _categories(AppLocalizations l10n, CategoryController categories) {
final choices = <({String code, String label})>[
(code: CategoryController.allCode, label: l10n.forYou),
(code: CategoryController.allCode, label: l10n.all),
(code: CategoryController.hotCode, label: l10n.hot),
(code: CategoryController.newCode, label: l10n.newest),
for (final category in categories.categories)
@@ -68,9 +68,9 @@ class _HomeDramaGrid extends StatelessWidget {
sliver: SliverGrid(
key: const Key('home-all-dramas-grid'),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 16,
crossAxisSpacing: 12,
crossAxisCount: 3,
mainAxisSpacing: 14,
crossAxisSpacing: 10,
childAspectRatio: 2 / 3,
),
delegate: SliverChildBuilderDelegate(
+11 -5
View File
@@ -25,7 +25,7 @@ void main() {
});
testWidgets(
'should_show_all_dramas_in_two_column_sliver_grid_without_continue_watching',
'should_show_all_dramas_in_three_column_sliver_grid_without_continue_watching',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
@@ -38,15 +38,21 @@ void main() {
expect(find.text('Continue Watching'), findsNothing);
expect(find.text('All Dramas'), findsOneWidget);
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),
);
final grid = tester.widget<SliverGrid>(
find.byKey(const Key('home-all-dramas-grid')),
);
final delegate =
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
expect(delegate.crossAxisCount, 2);
expect(delegate.crossAxisSpacing, 12);
expect(delegate.mainAxisSpacing, 16);
expect(delegate.crossAxisCount, 3);
expect(delegate.crossAxisSpacing, 10);
expect(delegate.mainAxisSpacing, 14);
expect(delegate.childAspectRatio, closeTo(2 / 3, 0.001));
expect(
tester
@@ -154,7 +160,7 @@ void main() {
expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing);
});
testWidgets('should_fit_two_column_grid_on_compact_screen', (tester) async {
testWidgets('should_fit_three_column_grid_on_compact_screen', (tester) async {
tester.view.physicalSize = const Size(320, 568);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
+2 -2
View File
@@ -225,7 +225,7 @@ void main() {
expect(find.text('首页'), findsOneWidget);
await tester.tap(find.text('首页'));
await tester.pumpAndSettle();
expect(find.text('为你推荐'), findsOneWidget);
expect(find.text('全部'), findsOneWidget);
expect(find.text('热门'), findsOneWidget);
});
@@ -312,7 +312,7 @@ void main() {
await tester.tap(find.text('Home'));
await tester.pumpAndSettle();
expect(find.text('For You'), findsOneWidget);
expect(find.text('All'), findsOneWidget);
expect(find.text('All Dramas'), findsOneWidget);
expect(find.text('Rewards'), findsOneWidget);
expect(find.text(r'$ 0'), findsOneWidget);