diff --git a/lib/core/widgets/app_bottom_nav.dart b/lib/core/widgets/app_bottom_nav.dart index 8905618..9081ebb 100644 --- a/lib/core/widgets/app_bottom_nav.dart +++ b/lib/core/widgets/app_bottom_nav.dart @@ -43,37 +43,35 @@ class AppBottomNav extends StatelessWidget { @override Widget build(BuildContext context) { + final bar = Container( + key: barKey, + height: AppDimens.navHeight, + decoration: BoxDecoration( + color: dark ? Colors.black : backgroundColor.withValues(alpha: 0.95), + border: Border( + top: BorderSide(color: dark ? Colors.white12 : AppColors.border), + ), + ), + child: Row( + children: [ + for (final item in items) + _NavDestination( + item: item, + unselectedColor: dark ? Colors.white70 : AppColors.navUnselected, + ), + ], + ), + ); + if (dark) { + return ColoredBox( + color: Colors.black, + child: SafeArea(top: false, child: bar), + ); + } return ClipRect( child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20), - child: SafeArea( - top: false, - child: Container( - key: barKey, - height: AppDimens.navHeight, - decoration: BoxDecoration( - color: dark - ? const Color(0xE6000000) - : backgroundColor.withValues(alpha: 0.95), - border: Border( - top: BorderSide( - color: dark ? Colors.white12 : AppColors.border, - ), - ), - ), - child: Row( - children: [ - for (final item in items) - _NavDestination( - item: item, - unselectedColor: dark - ? Colors.white70 - : AppColors.navUnselected, - ), - ], - ), - ), - ), + child: SafeArea(top: false, child: bar), ), ); } diff --git a/test/home/app_bottom_nav_test.dart b/test/home/app_bottom_nav_test.dart index df8a59e..f019a17 100644 --- a/test/home/app_bottom_nav_test.dart +++ b/test/home/app_bottom_nav_test.dart @@ -82,4 +82,68 @@ void main() { await tester.tap(find.byKey(const Key('tab-theater'))); expect(theaterTaps, 1); }); + + testWidgets('should_fill_dark_bottom_safe_area_with_black_background', ( + tester, + ) async { + const barKey = Key('dark-nav-bar'); + await tester.pumpWidget( + MaterialApp( + home: MediaQuery( + data: const MediaQueryData(padding: EdgeInsets.only(bottom: 34)), + child: Scaffold( + bottomNavigationBar: AppBottomNav( + dark: true, + barKey: barKey, + items: [ + AppBottomNavItem( + tabKey: const Key('tab-home'), + icon: Icons.movie_outlined, + selectedIcon: Icons.movie_rounded, + label: 'Home', + selected: true, + onTap: () {}, + ), + AppBottomNavItem( + tabKey: const Key('tab-theater'), + icon: Icons.explore_outlined, + selectedIcon: Icons.explore_rounded, + label: 'Theater', + onTap: () {}, + ), + AppBottomNavItem( + tabKey: const Key('tab-create'), + icon: Icons.add_box_outlined, + selectedIcon: Icons.add_box_rounded, + label: 'Create', + onTap: () {}, + ), + AppBottomNavItem( + tabKey: const Key('tab-mine'), + icon: Icons.person_outline_rounded, + selectedIcon: Icons.person_rounded, + label: 'Me', + onTap: () {}, + ), + ], + ), + ), + ), + ), + ); + + expect( + tester.getSize(find.byType(AppBottomNav)).height, + AppDimens.navHeight + 34, + ); + expect(tester.getSize(find.byKey(barKey)).height, AppDimens.navHeight); + + final coloredBox = tester.widget( + find.descendant( + of: find.byType(AppBottomNav), + matching: find.byType(ColoredBox), + ), + ); + expect(coloredBox.color, Colors.black); + }); } diff --git a/test/home/home_nav_ui_test.dart b/test/home/home_nav_ui_test.dart index 763eb84..1b61ce0 100644 --- a/test/home/home_nav_ui_test.dart +++ b/test/home/home_nav_ui_test.dart @@ -53,7 +53,7 @@ void main() { final decoration = bar.decoration as BoxDecoration; final border = decoration.border as Border; // 首页 feed 用深色导航。 - expect(decoration.color, const Color(0xE6000000)); + expect(decoration.color, Colors.black); expect(border.top.color, Colors.white12); expect( tester