diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index 793682b7787b..6ff69f593d36 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.4 + +* Use Material 3 NavigationBar instead of BottomNavigationBar + ## 0.1.3 * Fixes `groupAlignment` property not available in `standardNavigationRail` - [flutter/flutter#121994](https://github.com/flutter/flutter/issues/121994) diff --git a/packages/flutter_adaptive_scaffold/example/test/adaptive_scaffold_demo_test.dart b/packages/flutter_adaptive_scaffold/example/test/adaptive_scaffold_demo_test.dart index 41df6dffcfdf..c22f9ebab733 100644 --- a/packages/flutter_adaptive_scaffold/example/test/adaptive_scaffold_demo_test.dart +++ b/packages/flutter_adaptive_scaffold/example/test/adaptive_scaffold_demo_test.dart @@ -33,7 +33,7 @@ void main() { expect(smallBody, findsOneWidget); expect(bnav, findsOneWidget); expect(tester.getTopLeft(smallBody), Offset.zero); - expect(tester.getTopLeft(bnav), const Offset(0, 744)); + expect(tester.getTopLeft(bnav), const Offset(0, 720)); expect(body, findsNothing); expect(largeBody, findsNothing); expect(pnav, findsNothing); @@ -73,22 +73,22 @@ void main() { expect(tester.getTopLeft(b), const Offset(17.6, 0)); expect(tester.getBottomRight(b), - offsetMoreOrLessEquals(const Offset(778.2, 755.2), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(778.2, 736), epsilon: 1.0)); expect(tester.getTopLeft(sBody), offsetMoreOrLessEquals(const Offset(778.2, 0), epsilon: 1.0)); expect(tester.getBottomRight(sBody), - offsetMoreOrLessEquals(const Offset(1178.2, 755.2), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(1178.2, 736), epsilon: 1.0)); await tester.pump(); await tester.pump(const Duration(milliseconds: 600)); expect(tester.getTopLeft(b), const Offset(70.4, 0)); expect(tester.getBottomRight(b), - offsetMoreOrLessEquals(const Offset(416.0, 788.8), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(416.0, 784), epsilon: 1.0)); expect(tester.getTopLeft(sBody), offsetMoreOrLessEquals(const Offset(416, 0), epsilon: 1.0)); expect(tester.getBottomRight(sBody), - offsetMoreOrLessEquals(const Offset(816, 788.8), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(816, 784), epsilon: 1.0)); await tester.pump(); await tester.pump(const Duration(milliseconds: 200)); diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart index 3eb9ee6435e4..028f47e7cad7 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -316,15 +316,24 @@ class AdaptiveScaffold extends StatefulWidget { ValueChanged? onDestinationSelected, }) { return Builder( - builder: (_) { - return BottomNavigationBar( - currentIndex: currentIndex ?? 0, - iconSize: iconSize, - items: destinations - .map((NavigationDestination e) => _toBottomNavItem(e)) - .toList(), - onTap: onDestinationSelected, - ); + builder: (BuildContext context) { + final NavigationBarThemeData currentNavBarTheme = + NavigationBarTheme.of(context); + return NavigationBarTheme( + data: currentNavBarTheme.copyWith( + iconTheme: MaterialStateProperty.resolveWith( + (Set states) { + return currentNavBarTheme.iconTheme + ?.resolve(states) + ?.copyWith(size: iconSize) ?? + IconTheme.of(context).copyWith(size: iconSize); + }), + ), + child: NavigationBar( + selectedIndex: currentIndex ?? 0, + destinations: destinations, + onDestinationSelected: onDestinationSelected, + )); }, ); } @@ -644,14 +653,6 @@ class _AdaptiveScaffoldState extends State { } } -BottomNavigationBarItem _toBottomNavItem(NavigationDestination destination) { - return BottomNavigationBarItem( - label: destination.label, - icon: destination.icon, - activeIcon: destination.selectedIcon, - ); -} - class _BrickLayout extends StatelessWidget { const _BrickLayout({ this.columns = 1, diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml index 8157ffb287b7..d988420a2221 100644 --- a/packages/flutter_adaptive_scaffold/pubspec.yaml +++ b/packages/flutter_adaptive_scaffold/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_adaptive_scaffold description: Widgets to easily build adaptive layouts, including navigation elements. -version: 0.1.3 +version: 0.1.4 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_adaptive_scaffold%22 repository: https://github.com/flutter/packages/tree/main/packages/flutter_adaptive_scaffold diff --git a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart index 65035389659e..325628645522 100644 --- a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart +++ b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart @@ -33,7 +33,7 @@ void main() { expect(tester.getTopLeft(smallBody), Offset.zero); expect(tester.getTopLeft(smallSBody), const Offset(200, 0)); - expect(tester.getTopLeft(bottomNav), const Offset(0, 744)); + expect(tester.getTopLeft(bottomNav), const Offset(0, 720)); await tester.binding.setSurfaceSize(SimulatedLayout.medium.size); await tester.pumpWidget(SimulatedLayout.medium.app()); @@ -83,22 +83,22 @@ void main() { expect(tester.getTopLeft(b), const Offset(17.6, 0)); expect(tester.getBottomRight(b), - offsetMoreOrLessEquals(const Offset(778.2, 755.2), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(778.2, 736), epsilon: 1.0)); expect(tester.getTopLeft(sBody), offsetMoreOrLessEquals(const Offset(778.2, 0), epsilon: 1.0)); expect(tester.getBottomRight(sBody), - offsetMoreOrLessEquals(const Offset(1178.2, 755.2), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(1178.2, 736), epsilon: 1.0)); await tester.pump(); await tester.pump(const Duration(milliseconds: 600)); expect(tester.getTopLeft(b), const Offset(70.4, 0)); expect(tester.getBottomRight(b), - offsetMoreOrLessEquals(const Offset(416.0, 788.8), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(416.0, 784), epsilon: 1.0)); expect(tester.getTopLeft(sBody), offsetMoreOrLessEquals(const Offset(416, 0), epsilon: 1.0)); expect(tester.getBottomRight(sBody), - offsetMoreOrLessEquals(const Offset(816, 788.8), epsilon: 1.0)); + offsetMoreOrLessEquals(const Offset(816, 784), epsilon: 1.0)); await tester.pump(); await tester.pump(const Duration(milliseconds: 200));