Skip to content

Commit 035d2a0

Browse files
committed
feat: improve responsive navigation, support drawer for tablet, and unify mobile/tablet app bar
1 parent 5fc167f commit 035d2a0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/demo/lib/example_browser.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ class _ExampleBrowserState extends State<ExampleBrowser> {
5858
// Navigate using GoRouter which will update the URL
5959
context.go('/$categoryId/${example.id}');
6060

61-
// Close drawer on mobile after selection
62-
if (Responsive.isMobile(context) &&
63-
_scaffoldKey.currentState?.isDrawerOpen == true) {
61+
// Close drawer on mobile/tablet after selection
62+
if (_scaffoldKey.currentState?.isDrawerOpen == true) {
6463
Navigator.of(context).pop();
6564
}
6665
}
@@ -69,15 +68,16 @@ class _ExampleBrowserState extends State<ExampleBrowser> {
6968
Widget build(BuildContext context) {
7069
final isMobile = Responsive.isMobile(context);
7170
final isTablet = Responsive.isTablet(context);
71+
final useDrawerNavigation = isMobile || isTablet;
7272

7373
return Scaffold(
7474
key: _scaffoldKey,
75-
appBar: isMobile ? _buildMobileAppBar() : null,
76-
drawer: (isMobile || isTablet) ? _buildDrawer() : null,
75+
appBar: useDrawerNavigation ? _buildCompactAppBar() : null,
76+
drawer: useDrawerNavigation ? _buildDrawer() : null,
7777
body: Row(
7878
children: [
7979
// Desktop: Show navigation sidebar
80-
if (!isMobile && !isTablet)
80+
if (!useDrawerNavigation)
8181
ExampleNavigation(
8282
categories: widget.categories,
8383
state: _navState,
@@ -91,7 +91,7 @@ class _ExampleBrowserState extends State<ExampleBrowser> {
9191
);
9292
}
9393

94-
PreferredSizeWidget _buildMobileAppBar() {
94+
PreferredSizeWidget _buildCompactAppBar() {
9595
final theme = Theme.of(context);
9696

9797
return AppBar(

0 commit comments

Comments
 (0)