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:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../navigation_rail.dart';
|
||||
import 'window_focus.dart';
|
||||
import 'window_layer.dart';
|
||||
import 'window_manager.dart';
|
||||
@@ -18,7 +19,16 @@ import 'window_shortcuts.dart';
|
||||
///
|
||||
/// The host fills its parent and takes no input between windows.
|
||||
class WindowHost extends StatefulWidget {
|
||||
const WindowHost({super.key, required this.manager});
|
||||
const WindowHost({
|
||||
super.key,
|
||||
required this.manager,
|
||||
this.reservesRail = false,
|
||||
});
|
||||
|
||||
/// Whether the shell beside this host shows the destination rail on the
|
||||
/// window's left edge; the windows then keep to the right of it while the
|
||||
/// window is wide enough for the rail (see [showsNavigationRail]).
|
||||
final bool reservesRail;
|
||||
|
||||
final WindowManager manager;
|
||||
|
||||
@@ -119,24 +129,36 @@ class _WindowHostState extends State<WindowHost> {
|
||||
]),
|
||||
builder: (context, _) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final bounds = constraints.biggest;
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
for (final entry in windows)
|
||||
if (manager.kinds[entry.kind] case final kind?)
|
||||
WindowLayer(
|
||||
key: ValueKey(entry.id),
|
||||
manager: manager,
|
||||
kind: kind,
|
||||
entry: entry,
|
||||
visible:
|
||||
manager.isVisible(entry) &&
|
||||
bounds.width >= kind.minHostWidth,
|
||||
bounds: bounds,
|
||||
focus: _focus,
|
||||
),
|
||||
],
|
||||
// Beside the destination rail the windows keep to the page's
|
||||
// right, so they never sit under the rail.
|
||||
// The shell takes the rail and its divider (kNavigationRailSpace).
|
||||
final leading = widget.reservesRail && showsNavigationRail(context)
|
||||
? kNavigationRailSpace
|
||||
: 0.0;
|
||||
final bounds = Size(
|
||||
constraints.maxWidth - leading,
|
||||
constraints.maxHeight,
|
||||
);
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: leading),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
for (final entry in windows)
|
||||
if (manager.kinds[entry.kind] case final kind?)
|
||||
WindowLayer(
|
||||
key: ValueKey(entry.id),
|
||||
manager: manager,
|
||||
kind: kind,
|
||||
entry: entry,
|
||||
visible:
|
||||
manager.isVisible(entry) &&
|
||||
bounds.width >= kind.minHostWidth,
|
||||
bounds: bounds,
|
||||
focus: _focus,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user