Add desktop navigation rail with Settings
Replace wide-layout floating destination controls with a full-height Material navigation rail, keeping badges and existing navigation behavior. Pin Settings to the rail and preserve the phone layout and pane/window clearance.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Marks the content beside the destination rail. A wide window's content
|
||||
/// lays out in the width left beside the rail, so list and detail panes read
|
||||
/// that width ([windowWidth]) instead of the window's. Outside the scope (a
|
||||
/// phone, a route pushed over the shell) the window's own width applies.
|
||||
class ShellRailScope extends InheritedWidget {
|
||||
const ShellRailScope({
|
||||
super.key,
|
||||
required this.shown,
|
||||
required this.bodyWidth,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
/// Whether the rail is shown beside this content.
|
||||
final bool shown;
|
||||
|
||||
/// The width beside the rail; null when no rail is shown.
|
||||
final double? bodyWidth;
|
||||
|
||||
/// Whether the rail is shown beside [context]'s content.
|
||||
static bool isShown(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ShellRailScope>()?.shown ??
|
||||
false;
|
||||
|
||||
/// The width the panes of [context] lay out in: the body beside the rail,
|
||||
/// or else the window.
|
||||
static double windowWidth(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ShellRailScope>()?.bodyWidth ??
|
||||
MediaQuery.sizeOf(context).width;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(ShellRailScope oldWidget) =>
|
||||
shown != oldWidget.shown || bodyWidth != oldWidget.bodyWidth;
|
||||
}
|
||||
Reference in New Issue
Block a user