feat(home): 使用胶片盘图片导航图标

This commit is contained in:
Zhou Weidong committed 2026-10-22 19:24:34 +08:00
1 parent c24518c1a4
commit f47e4dd298
6 files changed
+132 -47

No files matched your search

+25
View File
@@ -179,4 +179,29 @@ void main() {
findsWidgets,
);
});
testWidgets('should_fallback_when_asset_icon_is_missing', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
bottomNavigationBar: AppBottomNav(
items: [
AppBottomNavItem(
tabKey: const Key('tab-home'),
icon: Icons.theaters_outlined,
selectedIcon: Icons.theaters,
assetPath: 'assets/icon/missing_film_reel.png',
label: 'Home',
selected: true,
onTap: () {},
),
],
),
),
),
);
await tester.pumpAndSettle();
expect(find.byIcon(Icons.theaters_outlined), findsOneWidget);
});
}
+31 -6
View File
@@ -191,7 +191,7 @@ void main() {
expect(
find.descendant(
of: find.byKey(const Key('tab-home')),
matching: find.byIcon(Icons.theaters),
matching: find.byType(Image),
),
findsOneWidget,
);
@@ -218,14 +218,28 @@ void main() {
);
expect(
tester
.widget<Icon>(
.widget<ColorFiltered>(
find.descendant(
of: find.byKey(const Key('tab-home')),
matching: find.byIcon(Icons.theaters),
matching: find.byType(ColorFiltered),
),
)
.color,
AppColors.navSelected,
.colorFilter,
const ColorFilter.mode(AppColors.navSelected, BlendMode.srcIn),
);
final selectedHomeImage = tester.widget<Image>(
find.descendant(
of: find.byKey(const Key('tab-home')),
matching: find.byType(Image),
),
);
expect(
(selectedHomeImage.image as AssetImage).assetName,
'assets/icon/film_reel.png',
);
expect(
Size(selectedHomeImage.width!, selectedHomeImage.height!),
const Size.square(AppDimens.navIcon),
);
await tester.tap(find.byKey(const Key('tab-recommend')));
@@ -271,10 +285,21 @@ void main() {
expect(
find.descendant(
of: find.byKey(const Key('tab-home')),
matching: find.byIcon(Icons.theaters_outlined),
matching: find.byType(Image),
),
findsOneWidget,
);
expect(
tester
.widget<ColorFiltered>(
find.descendant(
of: find.byKey(const Key('tab-home')),
matching: find.byType(ColorFiltered),
),
)
.colorFilter,
const ColorFilter.mode(AppColors.navUnselected, BlendMode.srcIn),
);
});
testWidgets('should_map_four_tabs_to_home_recommend_following_and_me', (