feat(app): 底部导航精简为三 Tab

This commit is contained in:
Zhou Weidong committed 2026-10-20 05:14:52 +08:00
1 parent 19caaa0a22
commit dc8ca7b743
3 files changed
+2 -115

No files matched your search

-19
View File
@@ -22,7 +22,6 @@ import '../discover/discover_view.dart';
import '../splash/splash_page.dart';
import '../mine/mine_view.dart';
import '../player/player_view.dart';
import '../ranking/ranking_view.dart';
import 'home_binding.dart';
import 'home_logic.dart';
import 'widgets/home_menu_sheet.dart';
@@ -75,7 +74,6 @@ class HomePage extends StatelessWidget {
return _HomeTabs(
key: ValueKey(catalog.dramas.first.id),
dramas: catalog.dramas,
sections: catalog.sections,
banners: catalog.banners,
);
}
@@ -104,12 +102,10 @@ class _HomeTabs extends StatefulWidget {
const _HomeTabs({
super.key,
required this.dramas,
required this.sections,
required this.banners,
});
final List<Drama> dramas;
final List<FeedSection> sections;
final List<FeedBanner> banners;
@override
@@ -214,13 +210,6 @@ class _HomeTabsState extends State<_HomeTabs> {
onSignOut: () => context.read<AuthController>().signOut(),
wallet: context.read<WalletController>(),
),
RankingPage(
sections: widget.sections,
fallback: widget.dramas,
onOpen: (drama) => logic.openDrama(context, drama),
embedded: true,
active: logic.tab == 3,
),
],
),
bottomNavigationBar: logic.videoImmersive
@@ -244,14 +233,6 @@ class _HomeTabsState extends State<_HomeTabs> {
selected: logic.tab == 1,
onTap: () => _selectTab(context, 1),
),
AppBottomNavItem(
tabKey: const Key('tab-ranking'),
icon: Icons.leaderboard_outlined,
selectedIcon: Icons.leaderboard_rounded,
label: l10n.rankingTab,
selected: logic.tab == 3,
onTap: () => _selectTab(context, 3),
),
AppBottomNavItem(
tabKey: const Key('tab-my'),
icon: Icons.video_library_outlined,
+2 -8
View File
@@ -20,7 +20,6 @@ const _keys = [
Key('home-tabs-bar'),
Key('tab-home'),
Key('tab-discover'),
Key('tab-ranking'),
Key('tab-my'),
];
@@ -34,7 +33,7 @@ void main() {
});
});
testWidgets('should_theme_four_tabs_and_switch_selected_state_when_tapped', (
testWidgets('should_theme_three_tabs_and_switch_selected_state_when_tapped', (
tester,
) async {
final haptics = FakeHaptics();
@@ -96,14 +95,13 @@ void main() {
);
});
testWidgets('should_map_four_tabs_to_home_discover_ranking_and_me', (
testWidgets('should_map_three_tabs_to_home_discover_and_me', (
tester,
) async {
await _pumpApp(tester);
expect(find.byKey(const Key('tab-home')), findsOneWidget);
expect(find.byKey(const Key('tab-discover')), findsOneWidget);
expect(find.byKey(const Key('tab-ranking')), findsOneWidget);
expect(find.byKey(const Key('tab-my')), findsOneWidget);
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
@@ -111,10 +109,6 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
await tester.tap(find.byKey(const Key('tab-ranking')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('ranking-page')), findsOneWidget);
await tester.tap(find.byKey(const Key('tab-my')));
await tester.pumpAndSettle();
expect(find.text('Viewer'), findsOneWidget);
-88
View File
@@ -1,88 +0,0 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/app.dart';
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/pages/drama_detail/drama_detail_view.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';
import '../support/fake_catalog.dart';
import '../support/fake_category.dart';
import '../support/fake_haptics.dart';
import '../support/fake_interaction_repositories.dart';
import '../support/widget_player.dart';
void main() {
setUp(() {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.withData({});
});
testWidgets('should_render_real_section_order_when_ranking_tab_is_opened', (
tester,
) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('tab-ranking')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('ranking-page')), findsOneWidget);
expect(find.byKey(const Key('ranking-tab-hot')), findsOneWidget);
expect(find.byKey(const Key('ranking-tab-new')), findsOneWidget);
expect(
find.byKey(const Key('ranking-entry-the-signal-demo')),
findsOneWidget,
);
expect(
find.byKey(const Key('ranking-entry-city-lights-demo')),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('ranking-tab-new')));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('ranking-entry-the-signal-demo')),
findsOneWidget,
);
});
testWidgets('should_open_the_selected_drama_when_ranking_entry_is_tapped', (
tester,
) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('tab-ranking')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('ranking-entry-city-lights-demo')));
await tester.pumpAndSettle();
expect(find.byType(DramaDetailPage), findsOneWidget);
expect(find.text('City Lights & Velvet Nights'), findsWidgets);
});
}
Future<void> _pumpApp(WidgetTester tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final catalog = FakeCatalogRepository();
await tester.pumpWidget(
LumaDramaApp(
playerFactory: createWidgetPlayer,
catalogRepository: catalog,
categoryRepository: FakeCategoryRepository(catalog: catalog),
watchHistoryRepository: InMemoryWatchHistoryRepository(),
favoriteRepository: InMemoryFavoriteRepository(cards: catalog.dramas),
playbackRepository: FakePlaybackRepository(),
commentRepository: FakeCommentRepository(),
interactionRepository: FakeInteractionRepository(),
haptics: FakeHaptics(),
),
);
await tester.pumpAndSettle();
}