Merge commit '148b3e790560f14d97c6ebfee69b0bf578c9d11d' into pipelines/run-20261111-0216-cupertino-out-templates-29f5
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'graph_viewport.dart';
|
||||
import 'graph_viewport_controller.dart';
|
||||
@@ -100,23 +98,6 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
Expanded(child: viewport),
|
||||
],
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: SegmentedBackButton(cupertino: true, onPressed: _close),
|
||||
title: widget.title,
|
||||
actions: [
|
||||
_GraphFitButton(
|
||||
cupertino: true,
|
||||
onPressed: _controller.fitToViewport,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: BelowTopBar(child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
@@ -124,12 +105,7 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
title: widget.title,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: _close),
|
||||
actions: [
|
||||
_GraphFitButton(
|
||||
cupertino: false,
|
||||
onPressed: _controller.fitToViewport,
|
||||
),
|
||||
],
|
||||
actions: [_GraphFitButton(onPressed: _controller.fitToViewport)],
|
||||
),
|
||||
body: BelowTopBar(child: body),
|
||||
);
|
||||
@@ -137,9 +113,8 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
}
|
||||
|
||||
class _GraphFitButton extends StatelessWidget {
|
||||
const _GraphFitButton({required this.cupertino, required this.onPressed});
|
||||
const _GraphFitButton({required this.onPressed});
|
||||
|
||||
final bool cupertino;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
@@ -147,22 +122,15 @@ class _GraphFitButton extends StatelessWidget {
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: graphFitLabel,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('graph-fit'),
|
||||
padding: const EdgeInsets.all(8),
|
||||
onPressed: onPressed,
|
||||
child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)),
|
||||
)
|
||||
: Tooltip(
|
||||
message: graphFitLabel,
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: const Key('graph-fit'),
|
||||
onPressed: onPressed,
|
||||
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: graphFitLabel,
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: const Key('graph-fit'),
|
||||
onPressed: onPressed,
|
||||
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -190,8 +158,9 @@ Future<void> openGraphExpanded(
|
||||
selectedStage: selectedStage,
|
||||
header: header,
|
||||
);
|
||||
final route = usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(fullscreenDialog: true, builder: (_) => page)
|
||||
: MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page);
|
||||
final route = MaterialPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => page,
|
||||
);
|
||||
return Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/glass_pill.dart';
|
||||
import 'graph_viewport_controller.dart';
|
||||
|
||||
@@ -121,20 +119,20 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
top: 8,
|
||||
end: 8,
|
||||
child: GlassPill(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
child: Wrap(
|
||||
spacing: 2,
|
||||
children: [
|
||||
_ViewportButton(
|
||||
buttonKey: const Key('graph-fit'),
|
||||
icon: _fitIcon(context),
|
||||
icon: Icons.fit_screen,
|
||||
label: graphFitLabel,
|
||||
onPressed: widget.controller.fitToViewport,
|
||||
),
|
||||
if (widget.onExpand != null)
|
||||
_ViewportButton(
|
||||
buttonKey: const Key('graph-expand'),
|
||||
icon: _expandIcon(context),
|
||||
icon: Icons.fullscreen,
|
||||
label: graphExpandLabel,
|
||||
onPressed: widget.onExpand,
|
||||
),
|
||||
@@ -147,12 +145,6 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
IconData _fitIcon(BuildContext context) =>
|
||||
usesCupertinoHost(context) ? CupertinoIcons.resize : Icons.fit_screen;
|
||||
|
||||
IconData _expandIcon(BuildContext context) =>
|
||||
usesCupertinoHost(context) ? CupertinoIcons.fullscreen : Icons.fullscreen;
|
||||
}
|
||||
|
||||
/// One native graph control inside the shared floating glass pill.
|
||||
@@ -160,7 +152,7 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
/// The label and the button's own tap action must reach the same semantics
|
||||
/// node: the icon is the only excluded child, and [MergeSemantics] folds the
|
||||
/// host button's action into the labelled node, so a screen reader can activate
|
||||
/// Fit and Expand on either host. A hand-written `Semantics` sibling around an
|
||||
/// Fit and Expand. A hand-written `Semantics` sibling around an
|
||||
/// excluded button would announce the control with no action at all.
|
||||
class _ViewportButton extends StatelessWidget {
|
||||
const _ViewportButton({
|
||||
@@ -181,24 +173,17 @@ class _ViewportButton extends StatelessWidget {
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
child: usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: buttonKey,
|
||||
padding: const EdgeInsets.all(8),
|
||||
onPressed: onPressed,
|
||||
child: ExcludeSemantics(child: Icon(icon)),
|
||||
)
|
||||
: Tooltip(
|
||||
message: label,
|
||||
// The merged node already carries the label; the tooltip is
|
||||
// only the pointer affordance.
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
icon: ExcludeSemantics(child: Icon(icon)),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: label,
|
||||
// The merged node already carries the label; the tooltip is
|
||||
// only the pointer affordance.
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
icon: ExcludeSemantics(child: Icon(icon)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../layout/layout_models.dart';
|
||||
import '../routing/route_models.dart';
|
||||
|
||||
@@ -32,9 +30,9 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig(
|
||||
/// The native theme roles one definition graph canvas needs.
|
||||
///
|
||||
/// No palette, font family or size is defined here: every value comes from the
|
||||
/// ambient Material or Cupertino theme, so light/dark and text scaling follow
|
||||
/// the host exactly. Edge labels and diagnostics are metadata, so they use the
|
||||
/// host's secondary-label role rather than the node's own label style.
|
||||
/// ambient Material theme, so light/dark and text scaling follow the host
|
||||
/// exactly. Edge labels and diagnostics are metadata, so they use the host's
|
||||
/// secondary-label role rather than the node's own label style.
|
||||
class GraphCanvasStyle {
|
||||
const GraphCanvasStyle({
|
||||
required this.labelStyle,
|
||||
@@ -44,20 +42,6 @@ class GraphCanvasStyle {
|
||||
});
|
||||
|
||||
factory GraphCanvasStyle.of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
return GraphCanvasStyle(
|
||||
labelStyle: theme.textTheme.tabLabelTextStyle.copyWith(
|
||||
color: secondary,
|
||||
),
|
||||
messageStyle: theme.textTheme.textStyle.copyWith(color: secondary),
|
||||
edgeColor: CupertinoColors.separator.resolveFrom(context),
|
||||
// Cupertino has no divider-thickness token; its separators are one
|
||||
// logical pixel hairlines, so the stroke keeps that native default.
|
||||
edgeWidth: 1,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
final secondary = theme.colorScheme.onSurfaceVariant;
|
||||
return GraphCanvasStyle(
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
|
||||
@@ -37,7 +35,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
/// Reports [node.key] exactly as the definition recorded it.
|
||||
final ValueChanged<String> onSelected;
|
||||
|
||||
/// Content inset shared by both hosts. It is spacing, not a size: the control
|
||||
/// Content inset for a graph node. It is spacing, not a size: the control
|
||||
/// still takes its size from its label, and the inset keeps wrapped glyphs
|
||||
/// clear of a rounded surface's corners.
|
||||
static const EdgeInsets _contentPadding = EdgeInsets.all(16);
|
||||
@@ -61,9 +59,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: _label,
|
||||
child: usesCupertinoHost(context)
|
||||
? _cupertinoButton(onPressed, content)
|
||||
: _materialCard(onPressed, content),
|
||||
child: _materialCard(onPressed, content),
|
||||
),
|
||||
);
|
||||
return active ? StageActivityHalo(child: control) : control;
|
||||
@@ -106,12 +102,6 @@ class GraphStageNode extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is
|
||||
/// still a visible node body; filled raises the selected one.
|
||||
Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected
|
||||
? CupertinoButton.filled(onPressed: onPressed, child: content)
|
||||
: CupertinoButton.tinted(onPressed: onPressed, child: content);
|
||||
|
||||
Widget _content(BuildContext context) {
|
||||
final status = _status;
|
||||
// The recorded status reads apart from the name: a coloured dot and
|
||||
@@ -215,10 +205,7 @@ class _StageActivityHaloState extends State<StageActivityHalo>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final color = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final color = Theme.of(context).colorScheme.primary;
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) => CustomPaint(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart' show listEquals;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
import '../domain/run_graph_state.dart';
|
||||
import '../layout/layout_models.dart';
|
||||
@@ -200,10 +198,7 @@ class RunGraphCanvas extends StatelessWidget {
|
||||
final executedIds = {for (final route in executed) route.id};
|
||||
final size = Size(routing.width, routing.height);
|
||||
final activeStage = state.activeStage;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final executedColor = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final executedColor = Theme.of(context).colorScheme.primary;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_graph_state.dart';
|
||||
import 'graph_canvas_style.dart';
|
||||
|
||||
@@ -31,10 +29,7 @@ class RunGraphHeader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final executedColor = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final executedColor = Theme.of(context).colorScheme.primary;
|
||||
final mutedColor = style.edgeColor;
|
||||
final active = state.activeStage;
|
||||
return Padding(
|
||||
@@ -53,14 +48,12 @@ class RunGraphHeader extends StatelessWidget {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
_LegendEntry(
|
||||
icon: cupertino
|
||||
? CupertinoIcons.arrow_right
|
||||
: Icons.arrow_forward,
|
||||
icon: Icons.arrow_forward,
|
||||
label: runGraphExecuted,
|
||||
color: executedColor,
|
||||
),
|
||||
_LegendEntry(
|
||||
icon: cupertino ? CupertinoIcons.minus : Icons.remove,
|
||||
icon: Icons.remove,
|
||||
label: runGraphNotExecuted,
|
||||
color: mutedColor,
|
||||
),
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/text/markdown_source_view.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/graph_protocol.dart';
|
||||
import '../domain/stage_definition.dart';
|
||||
|
||||
@@ -159,30 +157,14 @@ Future<void> openStageDefinition(
|
||||
// A terminal is a definition target, not its protocol key: the web pane
|
||||
// titles it with `nodeDisplayLabel` (`Failure`/`Success`).
|
||||
final title = '${nodeDisplayLabel(stageKey)} definition';
|
||||
final route = usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
title: title,
|
||||
subtitle: identity,
|
||||
),
|
||||
child: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: title,
|
||||
subtitle: identity,
|
||||
),
|
||||
body: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
);
|
||||
final route = MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: title, subtitle: identity),
|
||||
body: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
);
|
||||
return Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
@@ -263,22 +245,6 @@ class _StageDefinitionStyle {
|
||||
});
|
||||
|
||||
factory _StageDefinitionStyle.of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
return _StageDefinitionStyle(
|
||||
label: theme.textTheme.tabLabelTextStyle.copyWith(color: secondary),
|
||||
// SelectableText needs a style it can merge into the default text
|
||||
// style; Cupertino's textStyle is a complete style with `inherit: false`
|
||||
// and no baseline.
|
||||
value: theme.textTheme.textStyle.copyWith(inherit: true),
|
||||
muted: theme.textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
color: secondary,
|
||||
),
|
||||
heading: theme.textTheme.navTitleTextStyle,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return _StageDefinitionStyle(
|
||||
label: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith(
|
||||
|
||||
@@ -55,6 +55,16 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
final GlobalKey _navigator = GlobalKey();
|
||||
late final LocalKey _rootPage = ValueKey('window-root-${widget.entry.id}');
|
||||
|
||||
/// The page-transition theme handed to the window's navigator, rebuilt only
|
||||
/// when the app's theme itself changes.
|
||||
ThemeData? _themeSource;
|
||||
ThemeData? _pageTheme;
|
||||
|
||||
/// The root page kept across builds: a new page object would rebuild the
|
||||
/// window's content on every move and resize.
|
||||
WindowKind? _pageKind;
|
||||
Page<void>? _page;
|
||||
|
||||
String get _id => widget.entry.id;
|
||||
|
||||
@override
|
||||
@@ -160,6 +170,22 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
widget.manager.raise(_id);
|
||||
}
|
||||
|
||||
ThemeData _pageThemeFor(ThemeData theme) {
|
||||
if (identical(theme, _themeSource)) return _pageTheme!;
|
||||
_themeSource = theme;
|
||||
return _pageTheme = WindowNavigator.themeData(theme);
|
||||
}
|
||||
|
||||
Page<void> _rootPageFor(WindowKind kind) {
|
||||
final page = _page;
|
||||
if (page != null && identical(kind, _pageKind)) return page;
|
||||
_pageKind = kind;
|
||||
return _page = MaterialPage<void>(
|
||||
key: _rootPage,
|
||||
child: _WindowContent(kind: kind),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = widget.manager;
|
||||
@@ -174,6 +200,7 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
frame.bottom,
|
||||
);
|
||||
final title = kind.title(context, entry);
|
||||
final pageTheme = _pageThemeFor(Theme.of(context));
|
||||
final hiding = !widget.visible;
|
||||
final content = Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -185,17 +212,21 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
explicitChildNodes: true,
|
||||
label: 'Window: $title',
|
||||
identifier: 'window-${entry.kind}',
|
||||
child: WindowFrame(
|
||||
title: title,
|
||||
icon: kind.icon,
|
||||
actions: kind.actions(context, entry),
|
||||
maximized: entry.maximized,
|
||||
onMove: _move,
|
||||
onMoveEnd: _moveEnded,
|
||||
onMinimize: () => manager.setMinimized(_id, true),
|
||||
onToggleMaximized: () =>
|
||||
manager.setMaximized(_id, !entry.maximized),
|
||||
onClose: () => manager.close(_id),
|
||||
// Its own layer: moving the window moves the title bar without
|
||||
// repainting it.
|
||||
child: RepaintBoundary(
|
||||
child: WindowFrame(
|
||||
title: title,
|
||||
icon: kind.icon,
|
||||
actions: kind.actions(context, entry),
|
||||
maximized: entry.maximized,
|
||||
onMove: _move,
|
||||
onMoveEnd: _moveEnded,
|
||||
onMinimize: () => manager.setMinimized(_id, true),
|
||||
onToggleMaximized: () =>
|
||||
manager.setMaximized(_id, !entry.maximized),
|
||||
onClose: () => manager.close(_id),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -210,19 +241,16 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
child: WindowScope(
|
||||
manager: manager,
|
||||
entry: entry,
|
||||
body: body,
|
||||
child: ScaffoldMessenger(
|
||||
child: WindowNavigator.theme(
|
||||
context,
|
||||
child: WindowNavigator(
|
||||
key: _navigator,
|
||||
pages: [
|
||||
MaterialPage<void>(
|
||||
key: _rootPage,
|
||||
child: _WindowContent(kind: kind),
|
||||
),
|
||||
],
|
||||
onDidRemovePage: (_) {},
|
||||
child: WindowBodyScope(
|
||||
body: body,
|
||||
child: ScaffoldMessenger(
|
||||
child: Theme(
|
||||
data: pageTheme,
|
||||
child: WindowNavigator(
|
||||
key: _navigator,
|
||||
pages: [_rootPageFor(kind)],
|
||||
onDidRemovePage: (_) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,23 +18,21 @@ import 'window_scope.dart';
|
||||
class WindowNavigator extends Navigator {
|
||||
const WindowNavigator({super.key, super.pages, super.onDidRemovePage});
|
||||
|
||||
/// [child] with page transitions that keep every `MaterialPageRoute` of a
|
||||
/// window navigator below it inside the window's content area.
|
||||
static Widget theme(BuildContext context, {required Widget child}) {
|
||||
final theme = Theme.of(context);
|
||||
/// [theme] with page transitions that keep every `MaterialPageRoute` of a
|
||||
/// window navigator inside the window's content area. The caller keeps the
|
||||
/// result, so rebuilding a window layer does not hand its contents a new
|
||||
/// theme.
|
||||
static ThemeData themeData(ThemeData theme) {
|
||||
final builders = theme.pageTransitionsTheme.builders;
|
||||
return Theme(
|
||||
data: theme.copyWith(
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: {
|
||||
for (final platform in TargetPlatform.values)
|
||||
platform: _WindowPageTransitions(
|
||||
builders[platform] ?? const ZoomPageTransitionsBuilder(),
|
||||
),
|
||||
},
|
||||
),
|
||||
return theme.copyWith(
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: {
|
||||
for (final platform in TargetPlatform.values)
|
||||
platform: _WindowPageTransitions(
|
||||
builders[platform] ?? const ZoomPageTransitionsBuilder(),
|
||||
),
|
||||
},
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,9 +115,8 @@ class WindowPageBox extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scope = WindowScope.maybeOf(context);
|
||||
if (scope == null) return child;
|
||||
final body = scope.body;
|
||||
final body = WindowBodyScope.maybeOf(context);
|
||||
if (body == null) return child;
|
||||
const radius = Radius.circular(windowCornerRadius);
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -140,7 +137,9 @@ class WindowPageBox extends StatelessWidget {
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
primary: false,
|
||||
body: child,
|
||||
// Its own layer: moving or resizing the window repositions the
|
||||
// page without repainting it.
|
||||
body: RepaintBoundary(child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'window_entry.dart';
|
||||
import 'window_manager.dart';
|
||||
|
||||
/// The floating window some content is in: its entry, the manager, and where
|
||||
/// the content area is drawn in the window host. Absent outside a window, so
|
||||
/// shared content can tell the tiled app from a window.
|
||||
/// The floating window some content is in: its entry and the manager. Absent
|
||||
/// outside a window, so shared content can tell the tiled app from a window.
|
||||
///
|
||||
/// Content depends on what it can read of the entry, not on where the window
|
||||
/// is drawn: moving, resizing, minimising or maximising a window keeps its
|
||||
/// content as it is.
|
||||
class WindowScope extends InheritedWidget {
|
||||
const WindowScope({
|
||||
super.key,
|
||||
required this.manager,
|
||||
required this.entry,
|
||||
required this.body,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
final WindowManager manager;
|
||||
final WindowEntry entry;
|
||||
|
||||
/// The content area (the window less its title bar), in the host's
|
||||
/// coordinates.
|
||||
final Rect body;
|
||||
|
||||
static WindowScope? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<WindowScope>();
|
||||
|
||||
@@ -30,6 +29,26 @@ class WindowScope extends InheritedWidget {
|
||||
@override
|
||||
bool updateShouldNotify(WindowScope oldWidget) =>
|
||||
oldWidget.manager != manager ||
|
||||
oldWidget.entry != entry ||
|
||||
oldWidget.body != body;
|
||||
oldWidget.entry.id != entry.id ||
|
||||
oldWidget.entry.kind != entry.kind ||
|
||||
oldWidget.entry.contentId != entry.contentId ||
|
||||
oldWidget.entry.serverKey != entry.serverKey ||
|
||||
!mapEquals(oldWidget.entry.data, entry.data);
|
||||
}
|
||||
|
||||
/// Where a window's content area is drawn in the window host. Kept apart from
|
||||
/// [WindowScope] so a move or a resize repositions the page without rebuilding
|
||||
/// what the page shows.
|
||||
class WindowBodyScope extends InheritedWidget {
|
||||
const WindowBodyScope({super.key, required this.body, required super.child});
|
||||
|
||||
/// The content area (the window less its title bar), in the host's
|
||||
/// coordinates.
|
||||
final Rect body;
|
||||
|
||||
static Rect? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<WindowBodyScope>()?.body;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(WindowBodyScope oldWidget) => oldWidget.body != body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user