refactor(navigation): 移除全局两侧悬浮元素

This commit is contained in:
Zhou Weidong committed 2026-10-22 17:58:43 +08:00
1 parent 5cead7ce00
commit 9cf832b318
8 files changed
+103 -217

No files matched your search

+2
View File
@@ -71,6 +71,8 @@ void main() {
expect(find.text('Charts'), findsOneWidget);
expect(find.text('Costume'), findsOneWidget);
expect(find.text('Community'), findsOneWidget);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
});
testWidgets('should_hide_unmatched_content_sections', (tester) async {
+41
View File
@@ -3,6 +3,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/app.dart';
import 'package:fruitshorts/core/data/models/wallet.dart';
import 'package:fruitshorts/core/data/repositories/commerce_repository.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';
@@ -46,6 +48,10 @@ void main() {
for (final key in _keys) {
expect(find.byKey(key), findsOneWidget);
}
expect(find.byKey(const Key('home-wallet-entry')), findsOneWidget);
expect(find.byKey(const Key('home-wallet-badge')), findsOneWidget);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
for (final key in _keys.skip(1)) {
expect(tester.getSize(find.byKey(key)).height, greaterThanOrEqualTo(48));
}
@@ -214,6 +220,7 @@ void main() {
await tester.tap(find.byKey(const Key('tab-recommend')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
_expectNoFloatingOverlays();
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
@@ -226,6 +233,7 @@ void main() {
findsNothing,
);
expect(Navigator.canPop(tester.element(favorites)), isFalse);
_expectNoFloatingOverlays();
expect(
find.descendant(
of: find.byKey(const Key('tab-follow')),
@@ -241,6 +249,7 @@ void main() {
expect(find.byKey(const Key('mine-wallet')), findsOneWidget);
expect(find.byKey(const Key('mine-edit')), findsOneWidget);
expect(find.byKey(const Key('mine-library-tab-0')), findsNothing);
_expectNoFloatingOverlays();
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
@@ -287,6 +296,7 @@ Future<void> _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async {
playbackRepository: FakePlaybackRepository(),
commentRepository: FakeCommentRepository(),
interactionRepository: FakeInteractionRepository(),
commerceRepository: const _WalletCommerceRepository(),
haptics: haptics ?? FakeHaptics(),
),
);
@@ -294,3 +304,34 @@ Future<void> _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async {
await tester.tap(find.byKey(const Key('tab-home')));
await tester.pumpAndSettle();
}
class _WalletCommerceRepository implements CommerceRepository {
const _WalletCommerceRepository();
@override
Future<WalletSnapshot> fetchWallet() async {
return const WalletSnapshot(
wallet: CoinWallet(
coinBalance: 320,
totalRechargedCoin: 500,
totalConsumedCoin: 180,
totalRefundedCoin: 0,
),
);
}
@override
Future<UnlockResult> unlock(String episodeId) async {
return const UnlockResult(
unlocked: true,
accessType: 'UNLOCKED',
coinCost: 0,
coinBalance: 320,
);
}
}
void _expectNoFloatingOverlays() {
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
}
+9
View File
@@ -82,12 +82,14 @@ void main() {
expect(find.byKey(const Key('recommend-tab-playlist')), findsOneWidget);
expect(find.byKey(const Key('recommend-tab-all')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
_expectNoFloatingOverlays();
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
expect(find.byKey(const Key('recommend-section-new')), findsOneWidget);
expect(find.byKey(const Key('recommend-section-costume')), findsOneWidget);
_expectNoFloatingOverlays();
});
testWidgets('should_switch_playlist_and_all_dramas_in_recommend', (
@@ -101,6 +103,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
expect(find.byType(AppBottomNav), findsOneWidget);
_expectNoFloatingOverlays();
await tester.tap(find.byKey(const Key('recommend-tab-all')));
await tester.pumpAndSettle();
@@ -108,6 +111,7 @@ void main() {
for (var row = 0; row < 4; row++) {
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
}
_expectNoFloatingOverlays();
});
testWidgets('should_open_search_from_home_and_recommend', (tester) async {
@@ -159,6 +163,11 @@ const _tabKeys = [
Key('tab-mine'),
];
void _expectNoFloatingOverlays() {
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
}
bool _hasLightStatusBar(WidgetTester tester) => tester
.widgetList<AnnotatedRegion<SystemUiOverlayStyle>>(
find.byType(AnnotatedRegion<SystemUiOverlayStyle>),
+5 -18
View File
@@ -14,7 +14,6 @@ import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/auth/auth_view.dart';
import 'package:fruitshorts/pages/mine/mine_types.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_menu.dart';
import 'package:fruitshorts/pages/player/player_view.dart';
import 'package:fruitshorts/pages/store/vip_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';
@@ -105,7 +104,7 @@ void main() {
expect(find.byType(AuthPage), findsOneWidget);
});
testWidgets('should_render_signed_in_user_and_dismiss_mini_player', (
testWidgets('should_render_signed_in_user_without_floating_mini_player', (
tester,
) async {
await _pumpApp(
@@ -119,17 +118,8 @@ void main() {
expect(find.text('UID: U-100'), findsOneWidget);
expect(find.byKey(const Key('mine-edit')), findsOneWidget);
expect(find.byKey(const Key('mine-login')), findsNothing);
expect(find.byKey(const Key('mine-mini-player')), findsOneWidget);
expect(find.text('Recent drama'), findsOneWidget);
expect(find.text('Episode 3'), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('mine-mini-player'))),
const Size(AppDimens.mineMiniWidth, AppDimens.mineMiniHeight),
);
await tester.tap(find.byKey(const Key('mine-mini-close')));
await tester.pump();
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
await tester.tap(find.byKey(const Key('mine-edit')));
await tester.pumpAndSettle();
@@ -143,7 +133,7 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('should_open_vip_and_recent_player_from_mine_entries', (
testWidgets('should_open_vip_from_mine_without_floating_player', (
tester,
) async {
await _pumpApp(
@@ -158,11 +148,8 @@ void main() {
expect(find.byType(VipPage), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('mine-mini-player')));
await tester.pumpAndSettle();
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
expect(player.embedded, isFalse);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
});
testWidgets('should_expose_seven_menu_destinations_in_order', (tester) async {