merge: 合并 K11 首页三列网格
This commit is contained in:
commit
b5a8656ff0
4 files changed
+17
-11
No files matched your search
@@ -270,7 +270,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
|||||||
|
|
||||||
Widget _categories(AppLocalizations l10n, CategoryController categories) {
|
Widget _categories(AppLocalizations l10n, CategoryController categories) {
|
||||||
final choices = <({String code, String label})>[
|
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.hotCode, label: l10n.hot),
|
||||||
(code: CategoryController.newCode, label: l10n.newest),
|
(code: CategoryController.newCode, label: l10n.newest),
|
||||||
for (final category in categories.categories)
|
for (final category in categories.categories)
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ class _HomeDramaGrid extends StatelessWidget {
|
|||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
key: const Key('home-all-dramas-grid'),
|
key: const Key('home-all-dramas-grid'),
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 3,
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 14,
|
||||||
crossAxisSpacing: 12,
|
crossAxisSpacing: 10,
|
||||||
childAspectRatio: 2 / 3,
|
childAspectRatio: 2 / 3,
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets(
|
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) async {
|
||||||
tester.view.physicalSize = const Size(390, 844);
|
tester.view.physicalSize = const Size(390, 844);
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
@@ -38,15 +38,21 @@ void main() {
|
|||||||
|
|
||||||
expect(find.text('Continue Watching'), findsNothing);
|
expect(find.text('Continue Watching'), findsNothing);
|
||||||
expect(find.text('All Dramas'), findsOneWidget);
|
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>(
|
final grid = tester.widget<SliverGrid>(
|
||||||
find.byKey(const Key('home-all-dramas-grid')),
|
find.byKey(const Key('home-all-dramas-grid')),
|
||||||
);
|
);
|
||||||
final delegate =
|
final delegate =
|
||||||
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
||||||
expect(delegate.crossAxisCount, 2);
|
expect(delegate.crossAxisCount, 3);
|
||||||
expect(delegate.crossAxisSpacing, 12);
|
expect(delegate.crossAxisSpacing, 10);
|
||||||
expect(delegate.mainAxisSpacing, 16);
|
expect(delegate.mainAxisSpacing, 14);
|
||||||
expect(delegate.childAspectRatio, closeTo(2 / 3, 0.001));
|
expect(delegate.childAspectRatio, closeTo(2 / 3, 0.001));
|
||||||
expect(
|
expect(
|
||||||
tester
|
tester
|
||||||
@@ -154,7 +160,7 @@ void main() {
|
|||||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing);
|
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.physicalSize = const Size(320, 568);
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ void main() {
|
|||||||
expect(find.text('首页'), findsOneWidget);
|
expect(find.text('首页'), findsOneWidget);
|
||||||
await tester.tap(find.text('首页'));
|
await tester.tap(find.text('首页'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('为你推荐'), findsOneWidget);
|
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.tap(find.text('Home'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.text('For You'), findsOneWidget);
|
expect(find.text('All'), findsOneWidget);
|
||||||
expect(find.text('All Dramas'), findsOneWidget);
|
expect(find.text('All Dramas'), findsOneWidget);
|
||||||
expect(find.text('Rewards'), findsOneWidget);
|
expect(find.text('Rewards'), findsOneWidget);
|
||||||
expect(find.text(r'$ 0'), findsOneWidget);
|
expect(find.text(r'$ 0'), findsOneWidget);
|
||||||
|
|||||||
Reference in new issue
Block a user