Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_adaptive_scaffold] exchange BottomNavigationBar with NavigationBar #3746

Merged
merged 25 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d186e34
replaced BottomNavigationBar with NavigationBar
fmt-Println-MKO Apr 17, 2023
8d95eb6
fixed test to pass new NavigationBar design
fmt-Println-MKO Apr 17, 2023
29020c0
updated version to 0.1.4
fmt-Println-MKO Apr 17, 2023
1fe63ce
fixed formating
fmt-Println-MKO Apr 17, 2023
8be3ea6
fixed example test
fmt-Println-MKO Apr 17, 2023
f7f8d3f
fixed formatting in example unit test
fmt-Println-MKO Apr 17, 2023
7584b58
fixed formatting in example unit test
fmt-Println-MKO Apr 17, 2023
7891c11
Merge branch 'main' into main
fmt-Println-MKO Apr 17, 2023
90efd53
Merge branch 'main' into main
fmt-Println-MKO Apr 23, 2023
8f72413
Merge branch 'main' into main
fmt-Println-MKO May 6, 2023
9249a60
fixed new line at end of file
fmt-Println-MKO May 6, 2023
385690d
fixed, use iconSize property for NavigationBar
fmt-Println-MKO May 6, 2023
8d69ac3
fixed formating
fmt-Println-MKO May 6, 2023
19e37bd
Merge branch 'main' into main
fmt-Println-MKO May 9, 2023
d7245c8
fixed NavBarThemeData as base for new iconSize
fmt-Println-MKO May 9, 2023
591ce3f
fixed, added BuildContext type
fmt-Println-MKO May 9, 2023
456c326
Merge branch 'main' into main
fmt-Println-MKO May 9, 2023
876363f
Merge branch 'main' into main
fmt-Println-MKO May 11, 2023
e28664b
Merge branch 'main' into main
fmt-Println-MKO May 12, 2023
35a1361
Update packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
fmt-Println-MKO May 16, 2023
3099c95
Merge branch 'main' into main
fmt-Println-MKO May 16, 2023
bc45bd2
Merge branch 'main' into main
fmt-Println-MKO May 17, 2023
d404401
fixed formatting
fmt-Println-MKO May 17, 2023
5174e24
Merge branch 'main' into main
fmt-Println-MKO May 17, 2023
747ae4e
Merge branch 'main' into main
fmt-Println-MKO May 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/flutter_adaptive_scaffold/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
28 changes: 12 additions & 16 deletions packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,18 @@ class AdaptiveScaffold extends StatefulWidget {
}) {
return Builder(
builder: (_) {
return BottomNavigationBar(
currentIndex: currentIndex ?? 0,
iconSize: iconSize,
fmt-Println-MKO marked this conversation as resolved.
Show resolved Hide resolved
items: destinations
.map((NavigationDestination e) => _toBottomNavItem(e))
.toList(),
onTap: onDestinationSelected,
);
return NavigationBarTheme(
data: NavigationBarThemeData(
iconTheme: MaterialStateProperty.resolveWith(
(Set<MaterialState> states) {
return IconThemeData(size: iconSize);
fmt-Println-MKO marked this conversation as resolved.
Show resolved Hide resolved
}),
),
child: NavigationBar(
selectedIndex: currentIndex ?? 0,
destinations: destinations,
onDestinationSelected: onDestinationSelected,
));
},
);
}
Expand Down Expand Up @@ -644,14 +648,6 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
}
}

BottomNavigationBarItem _toBottomNavItem(NavigationDestination destination) {
return BottomNavigationBarItem(
label: destination.label,
icon: destination.icon,
activeIcon: destination.selectedIcon,
);
}

class _BrickLayout extends StatelessWidget {
const _BrickLayout({
this.columns = 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_adaptive_scaffold/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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));
Expand Down