feat(nav): 底部导航改为首页推荐追剧我的
This commit is contained in:
1 parent
ec3cb8f163
commit
91e869d589
34 files changed
+359
-263
No files matched your search
+106
-22
@@ -7,6 +7,8 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
|
||||
import 'package:fruitshorts/pages/favorites/favorites_page.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
|
||||
@@ -19,8 +21,8 @@ import '../support/widget_player.dart';
|
||||
const _keys = [
|
||||
Key('home-tabs-bar'),
|
||||
Key('tab-home'),
|
||||
Key('tab-theater'),
|
||||
Key('tab-create'),
|
||||
Key('tab-recommend'),
|
||||
Key('tab-follow'),
|
||||
Key('tab-mine'),
|
||||
];
|
||||
|
||||
@@ -47,20 +49,54 @@ void main() {
|
||||
for (final key in _keys.skip(1)) {
|
||||
expect(tester.getSize(find.byKey(key)).height, greaterThanOrEqualTo(48));
|
||||
}
|
||||
final tabCenters = _keys
|
||||
.skip(1)
|
||||
.map((key) => tester.getCenter(find.byKey(key)).dx)
|
||||
.toList();
|
||||
expect(tabCenters, orderedEquals(tabCenters.toList()..sort()));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.text('Home'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.text('Recommend'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-follow')),
|
||||
matching: find.text('Following'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-mine')),
|
||||
matching: find.text('My'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
final barFinder = find.byKey(const Key('home-tabs-bar'));
|
||||
final bar = tester.widget<Container>(barFinder);
|
||||
final decoration = bar.decoration as BoxDecoration;
|
||||
final border = decoration.border as Border;
|
||||
// 所有页面统一深色导航。
|
||||
expect(decoration.color, AppColors.bar);
|
||||
expect(border.top.color, AppColors.border);
|
||||
expect(decoration.color, AppColors.navBackground);
|
||||
expect(border.top.color, AppColors.navDivider);
|
||||
expect(border.top.width, 0.5);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-theater')),
|
||||
matching: find.text('Theater'),
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.text('Recommend'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
@@ -85,6 +121,27 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.byIcon(Icons.smart_display_outlined),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-follow')),
|
||||
matching: find.byIcon(Icons.bookmark_border_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-mine')),
|
||||
matching: find.byIcon(Icons.person_outline_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Icon>(
|
||||
@@ -94,23 +151,26 @@ void main() {
|
||||
),
|
||||
)
|
||||
.color,
|
||||
AppColors.blue,
|
||||
AppColors.navSelected,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(haptics.selectionClicks, 1);
|
||||
final theaterBar = tester.widget<Container>(barFinder);
|
||||
final theaterDecoration = theaterBar.decoration as BoxDecoration;
|
||||
expect(theaterDecoration.color, AppColors.bar.withValues(alpha: 0.96));
|
||||
expect((theaterDecoration.border as Border).top.color, AppColors.border);
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
expect(theaterDecoration.color, AppColors.navBackground);
|
||||
expect(
|
||||
(theaterDecoration.border as Border).top.color,
|
||||
AppColors.navDivider,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(haptics.selectionClicks, 1);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-theater')),
|
||||
matching: find.byIcon(Icons.explore_rounded),
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.byIcon(Icons.smart_display_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
@@ -118,13 +178,13 @@ void main() {
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-theater')),
|
||||
matching: find.text('Theater'),
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.text('Recommend'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
?.color,
|
||||
AppColors.blue,
|
||||
AppColors.navSelected,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
@@ -147,32 +207,56 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_map_four_tabs_to_home_theater_create_and_me', (
|
||||
testWidgets('should_map_four_tabs_to_home_recommend_following_and_me', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-follow')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
final favorites = find.byType(FavoritesContent);
|
||||
expect(favorites, findsOneWidget);
|
||||
expect(find.byKey(const Key('favorites-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('favorites-back')), findsNothing);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: favorites, matching: find.byType(Scaffold)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(Navigator.canPop(tester.element(favorites)), isFalse);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-follow')),
|
||||
matching: find.byIcon(Icons.bookmark_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-mine')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Viewer'), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-menu')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-watchlist')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-creator-center')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-library-tab-0')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(favorites, findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
expect(Navigator.canPop(tester.element(favorites)), isFalse);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
|
||||
Reference in new issue
Block a user