fix(flutter): 回退底部导航为四槽
This commit is contained in:
1 parent
e448003f1b
commit
2f1a4c5c69
10 files changed
+21
-139
No files matched your search
@@ -7,8 +7,10 @@ import 'package:fruitshorts/core/theme/app_dimens.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_five_slots_with_center_action', (tester) async {
|
||||
var centerTaps = 0;
|
||||
testWidgets('should_render_four_slots_with_orange_selected_state', (
|
||||
tester,
|
||||
) async {
|
||||
var theaterTaps = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -27,7 +29,7 @@ void main() {
|
||||
icon: Icons.explore_outlined,
|
||||
selectedIcon: Icons.explore_rounded,
|
||||
label: 'Theater',
|
||||
onTap: () {},
|
||||
onTap: () => theaterTaps++,
|
||||
),
|
||||
AppBottomNavItem(
|
||||
tabKey: const Key('tab-create'),
|
||||
@@ -44,10 +46,6 @@ void main() {
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
centerAction: AppBottomNavCenterAction(
|
||||
label: 'Create',
|
||||
onTap: () => centerTaps++,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -55,14 +53,13 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('nav-center-action')), findsNothing);
|
||||
expect(find.text('Home'), findsOneWidget);
|
||||
final centers = [
|
||||
Key('tab-home'),
|
||||
Key('tab-theater'),
|
||||
Key('nav-center-action'),
|
||||
Key('tab-create'),
|
||||
Key('tab-mine'),
|
||||
].map((key) => tester.getCenter(find.byKey(key)).dx).toList();
|
||||
@@ -72,25 +69,17 @@ void main() {
|
||||
AppDimens.navHeight,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('nav-center-action'))),
|
||||
const Size.square(AppDimens.navCenter),
|
||||
);
|
||||
final ink = tester.widget<Ink>(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const Key('nav-center-action')),
|
||||
matching: find.byType(Ink),
|
||||
tester
|
||||
.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byIcon(Icons.movie_rounded),
|
||||
),
|
||||
)
|
||||
.first,
|
||||
.color,
|
||||
AppColors.blue,
|
||||
);
|
||||
final decoration = ink.decoration! as BoxDecoration;
|
||||
expect(decoration.shape, BoxShape.circle);
|
||||
expect((decoration.gradient! as LinearGradient).colors, const [
|
||||
AppColors.navCenterStart,
|
||||
AppColors.navCenterEnd,
|
||||
]);
|
||||
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
expect(centerTaps, 1);
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
expect(theaterTaps, 1);
|
||||
});
|
||||
}
|
||||
@@ -20,7 +20,6 @@ const _keys = [
|
||||
Key('home-tabs-bar'),
|
||||
Key('tab-home'),
|
||||
Key('tab-theater'),
|
||||
Key('nav-center-action'),
|
||||
Key('tab-create'),
|
||||
Key('tab-mine'),
|
||||
];
|
||||
@@ -139,7 +138,6 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-browse-page')), findsOneWidget);
|
||||
@@ -148,12 +146,6 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
@@ -33,9 +33,8 @@ void main() {
|
||||
for (final key in _tabKeys) {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
@@ -21,7 +21,6 @@ void main() {
|
||||
expect(AppDimens.primaryButtonHeight, 52);
|
||||
expect(AppDimens.tapTarget, 44);
|
||||
expect(AppDimens.navHeight, 64);
|
||||
expect(AppDimens.navCenter, 56);
|
||||
expect(AppDimens.progressHeight, 3);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user