Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions lib/config/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import '../screens/channel_detail_screen.dart';
import '../screens/video_player_screen.dart';
import '../screens/search_screen.dart';
import '../screens/queue_screen.dart';
import '../widgets/adaptive_layout.dart';
import 'theme.dart';

final _rootNavigatorKey = GlobalKey<NavigatorState>();
final _shellNavigatorKey = GlobalKey<NavigatorState>();
Expand Down Expand Up @@ -161,6 +163,34 @@ class _ScaffoldWithNav extends ConsumerWidget {
final destinations = _destinations;
final selectedIndex = _calculateSelectedIndex(context);

// Wide viewports (desktop/web, iPad landscape) get a side NavigationRail;
// phones keep the bottom nav.
if (AdaptiveLayout.isWide(context)) {
return Scaffold(
body: Row(
children: [
NavigationRail(
selectedIndex: selectedIndex,
onDestinationSelected: (index) =>
context.go(destinations[index].route),
labelType: NavigationRailLabelType.all,
backgroundColor: NullFeedTheme.surfaceColor,
destinations: [
for (final d in destinations)
NavigationRailDestination(
icon: Icon(d.icon),
selectedIcon: Icon(d.activeIcon),
label: Text(d.label),
),
],
),
const VerticalDivider(width: 1),
Expanded(child: child),
],
),
);
}

return Scaffold(
body: child,
bottomNavigationBar: BottomNavigationBar(
Expand Down
11 changes: 11 additions & 0 deletions lib/widgets/adaptive_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ class AdaptiveLayout extends StatelessWidget {
};
}

/// Breakpoint at/above which a side NavigationRail replaces the bottom nav
/// (desktop browsers, large windows, iPad landscape).
static const double wideBreakpoint = 900;

static bool isWide(BuildContext context) =>
MediaQuery.sizeOf(context).width >= wideBreakpoint;

static int gridCrossAxisCount(BuildContext context) {
// Make use of wide desktop/web viewports instead of capping at 3.
final width = MediaQuery.sizeOf(context).width;
if (width >= 1500) return 5;
if (width >= 1150) return 4;
return switch (getDeviceType(context)) {
DeviceType.tablet => 3,
DeviceType.phone => 2,
Expand Down
Loading