Merge commit '98c985e27f938eb80378a16995bfe31e16ea9631' into pipelines/run-20261111-0141-cupertino-out-graph-4ef1
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Asks for one machine's own password. [signIn] returns null on success,
|
||||
/// otherwise the sentence to show; the dialog stays open for a retry.
|
||||
Future<void> showMachineSignIn(
|
||||
@@ -11,9 +8,7 @@ Future<void> showMachineSignIn(
|
||||
required Future<String?> Function(String password) signIn,
|
||||
}) {
|
||||
final dialog = MachineSignInDialog(name: name, signIn: signIn);
|
||||
return usesCupertinoHost(context)
|
||||
? showCupertinoDialog<void>(context: context, builder: (_) => dialog)
|
||||
: showDialog<void>(context: context, builder: (_) => dialog);
|
||||
return showDialog<void>(context: context, builder: (_) => dialog);
|
||||
}
|
||||
|
||||
class MachineSignInDialog extends StatefulWidget {
|
||||
@@ -68,24 +63,14 @@ class _MachineSignInDialogState extends State<MachineSignInDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final field = cupertino
|
||||
? CupertinoTextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
placeholder: 'Password',
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
)
|
||||
: TextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
);
|
||||
final field = TextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
);
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -103,36 +88,20 @@ class _MachineSignInDialogState extends State<MachineSignInDialog> {
|
||||
],
|
||||
);
|
||||
final title = Text('Sign in to ${widget.name}');
|
||||
return cupertino
|
||||
? CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
);
|
||||
return AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'machine_elevation.dart';
|
||||
|
||||
/// The app's elevation prompt: the native password dialog over whatever
|
||||
@@ -21,12 +19,10 @@ Future<bool> showElevationDialog(
|
||||
MachineElevation machine,
|
||||
) async {
|
||||
final dialog = ElevationDialog(name: machine.name, submit: machine.submit);
|
||||
final result = usesCupertinoHost(context)
|
||||
? await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => dialog,
|
||||
)
|
||||
: await showDialog<bool>(context: context, builder: (_) => dialog);
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@@ -74,24 +70,14 @@ class _ElevationDialogState extends State<ElevationDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final field = cupertino
|
||||
? CupertinoTextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
placeholder: 'Password',
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
)
|
||||
: TextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
);
|
||||
final field = TextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
);
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -111,37 +97,20 @@ class _ElevationDialogState extends State<ElevationDialog> {
|
||||
);
|
||||
const title = Text('Confirm password');
|
||||
final confirmLabel = Text(busy ? 'Confirming…' : 'Confirm');
|
||||
return cupertino
|
||||
? CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('elevation-confirm'),
|
||||
isDefaultAction: true,
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
)
|
||||
: AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('elevation-confirm'),
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
);
|
||||
return AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('elevation-confirm'),
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,9 +338,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
context,
|
||||
chatSessionColor(_rowFor(pane.sessionId)),
|
||||
) ??
|
||||
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary)
|
||||
Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent;
|
||||
return Semantics(
|
||||
selected: active,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Covers a chat beside the stage too narrow to use: its colour and title,
|
||||
/// running down the column. A press brings that chat to center stage. The
|
||||
/// retained chat underneath keeps its state.
|
||||
@@ -22,20 +19,13 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final accent =
|
||||
color ??
|
||||
(cupertino ? CupertinoTheme.of(context).primaryColor : scheme.primary);
|
||||
final accent = color ?? scheme.primary;
|
||||
final background = Color.alphaBlend(
|
||||
accent.withValues(alpha: .12),
|
||||
cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: scheme.surfaceContainer,
|
||||
scheme.surfaceContainer,
|
||||
);
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final style = Theme.of(context).textTheme.titleSmall;
|
||||
final label = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
@@ -62,25 +52,17 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
label: 'Show $title on center stage',
|
||||
excludeSemantics: true,
|
||||
onTap: onSelected,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
color: background,
|
||||
borderRadius: BorderRadius.zero,
|
||||
onPressed: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
)
|
||||
: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'chat_workspace_pane_scope.dart';
|
||||
|
||||
/// "Move up/down/left/right" for a tiled pane's actions (More) menu. A move
|
||||
/// swaps the pane with the one across that edge. A direction with no pane is
|
||||
/// disabled in the Material menu (and left out of a Cupertino action sheet).
|
||||
/// Nothing is offered when the panes are not tiled (one pane, or a phone).
|
||||
/// disabled in the menu. Nothing is offered when the panes are not tiled (one
|
||||
/// pane, or a phone).
|
||||
List<Widget> chatPaneMoveActions(
|
||||
ChatWorkspacePaneScope? scope, {
|
||||
required void Function(String targetPaneId) onMove,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// A named, explicit switch action above the inactive transcript. It occupies
|
||||
/// space rather than obscuring the small chat's readable content.
|
||||
@@ -17,20 +15,11 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxHeight < 44;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? (compact
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: CupertinoTheme.of(context).textTheme.textStyle)
|
||||
: (compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge);
|
||||
final foreground = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final background = cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainer;
|
||||
final textStyle = compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge;
|
||||
final foreground = Theme.of(context).colorScheme.onSurface;
|
||||
final background = Theme.of(context).colorScheme.surfaceContainer;
|
||||
final content = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -44,34 +33,23 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Text('Switch', style: textStyle?.copyWith(color: foreground)),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.arrow_up : Icons.arrow_upward,
|
||||
color: foreground,
|
||||
size: 18,
|
||||
),
|
||||
Icon(Icons.arrow_upward, color: foreground, size: 18),
|
||||
],
|
||||
);
|
||||
return ColoredBox(
|
||||
color: background,
|
||||
child: Tooltip(
|
||||
message: 'Switch to $title',
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
minimumSize: const Size(0, 44),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
)
|
||||
: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
child: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/motion/quick_switch_effect.dart';
|
||||
import 'chat_pane_switch_motion.dart';
|
||||
|
||||
@@ -24,12 +22,8 @@ class ChatSwitchCard extends StatelessWidget {
|
||||
motion.isAnimating ? motion.progress : 1,
|
||||
outgoing: outgoing,
|
||||
);
|
||||
final shadow = usesCupertinoHost(context)
|
||||
? CupertinoColors.black
|
||||
: Theme.of(context).shadowColor;
|
||||
final surface = usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
final shadow = Theme.of(context).shadowColor;
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => Opacity(
|
||||
opacity: pose.opacity,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_workspace_controller.dart';
|
||||
import '../../../ui/adaptive/resize_grip.dart';
|
||||
import 'chat_workspace_geometry.dart';
|
||||
@@ -50,9 +48,7 @@ class _ChatWorkspaceDividerState extends State<ChatWorkspaceDivider> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final verticalLine = _horizontal;
|
||||
final color = usesCupertinoHost(context)
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).dividerColor;
|
||||
final color = Theme.of(context).dividerColor;
|
||||
return Semantics(
|
||||
identifier: 'chat-divider-${widget.geometry.split.id}',
|
||||
label: 'Resize chat panes ${_horizontal ? 'horizontally' : 'vertically'}',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/motion/motion.dart';
|
||||
import '../../../ui/motion/surface_visibility.dart';
|
||||
@@ -78,23 +78,16 @@ class _ChatWorkspaceEntranceState extends State<ChatWorkspaceEntrance>
|
||||
),
|
||||
),
|
||||
);
|
||||
final transition = widget.cupertino
|
||||
? CupertinoPageTransition(
|
||||
primaryRouteAnimation: _controller,
|
||||
secondaryRouteAnimation: const AlwaysStoppedAnimation(0),
|
||||
linearTransition: false,
|
||||
child: content,
|
||||
)
|
||||
: FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
final transition = FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
child: transition,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_center_stage_motion.dart';
|
||||
import 'chat_center_stage_strip.dart';
|
||||
import 'chat_mobile_panes.dart';
|
||||
@@ -130,11 +128,7 @@ Widget chatWorkspaceSurface({
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
if (mobile != null)
|
||||
ColoredBox(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
ColoredBox(color: Theme.of(context).colorScheme.surface),
|
||||
picture,
|
||||
for (final pane in livePanes)
|
||||
if (motion.isTape ||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_models.dart';
|
||||
import 'health_widgets.dart';
|
||||
|
||||
@@ -46,12 +44,7 @@ class HealthHeader extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Semantics(
|
||||
label: 'Auto-refresh',
|
||||
child: usesCupertinoControls(context)
|
||||
? CupertinoSwitch(
|
||||
value: autoRefresh,
|
||||
onChanged: onAutoRefresh,
|
||||
)
|
||||
: Switch(value: autoRefresh, onChanged: onAutoRefresh),
|
||||
child: Switch(value: autoRefresh, onChanged: onAutoRefresh),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_page_body.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_controller.dart';
|
||||
import 'health_models.dart';
|
||||
import 'health_sections.dart';
|
||||
@@ -142,16 +140,9 @@ class _HealthScreenState extends State<HealthScreen>
|
||||
],
|
||||
],
|
||||
);
|
||||
return usesCupertinoControls(context)
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('Server health'),
|
||||
),
|
||||
child: SafeArea(child: content),
|
||||
)
|
||||
: Scaffold(
|
||||
appBar: AppBar(title: const Text('Server health')),
|
||||
body: content,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Server health')),
|
||||
body: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_models.dart';
|
||||
@@ -20,22 +19,7 @@ class HealthCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!usesCupertinoControls(context)) return Card(child: content);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
style: settingsTextStyle(context),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
return Card(child: content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,23 +31,13 @@ class HealthMeter extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final percent = value == null ? null : value! * 100;
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final normal = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: scheme.primary;
|
||||
final high = cupertino
|
||||
? CupertinoColors.systemOrange.resolveFrom(context)
|
||||
: scheme.tertiary;
|
||||
final critical = cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: scheme.error;
|
||||
final color = percent == null
|
||||
? scheme.outline
|
||||
: percent >= healthMeterCritical
|
||||
? critical
|
||||
? scheme.error
|
||||
: percent >= healthMeterHigh
|
||||
? high
|
||||
: normal;
|
||||
? scheme.tertiary
|
||||
: scheme.primary;
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -111,7 +85,6 @@ class HealthAction extends StatelessWidget {
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
@override
|
||||
Widget build(BuildContext context) => usesCupertinoControls(context)
|
||||
? CupertinoButton(onPressed: onPressed, child: Text(label))
|
||||
: TextButton(onPressed: onPressed, child: Text(label));
|
||||
Widget build(BuildContext context) =>
|
||||
TextButton(onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_row.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_screen.dart';
|
||||
|
||||
class SettingsHealthSection extends StatelessWidget {
|
||||
@@ -10,21 +8,13 @@ class SettingsHealthSection extends StatelessWidget {
|
||||
final ApiGateway gateway;
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.heart
|
||||
: Icons.monitor_heart_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.monitor_heart_outlined),
|
||||
title: const Text('Server health'),
|
||||
subtitle: const Text('CPU, memory, GPU, storage and process'),
|
||||
chevron: true,
|
||||
onTap: () {
|
||||
final page = HealthScreen(gateway: gateway);
|
||||
Navigator.of(context).push(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => page));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/session/server_session.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'session_security_api.dart';
|
||||
|
||||
/// The server's sign-in security: a warning when its password predates the
|
||||
@@ -72,28 +70,6 @@ class _SettingsSecuritySectionState extends State<SettingsSecuritySection> {
|
||||
'Every browser and device signed in to this server, this one '
|
||||
'included, must sign in again. Open connections close now.',
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: body,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('settings-revoke-all-confirm'),
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Sign out everywhere'),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
}
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -148,17 +124,11 @@ class _SettingsSecuritySectionState extends State<SettingsSecuritySection> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final security = _security;
|
||||
final button = usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
)
|
||||
: OutlinedButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
);
|
||||
final button = OutlinedButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_row.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'storage_screen.dart';
|
||||
|
||||
class SettingsStorageSection extends StatelessWidget {
|
||||
@@ -10,21 +8,13 @@ class SettingsStorageSection extends StatelessWidget {
|
||||
final ApiGateway gateway;
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.archivebox
|
||||
: Icons.storage_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.storage_outlined),
|
||||
title: const Text('Storage'),
|
||||
subtitle: const Text('Usage, worktrees and retention policy'),
|
||||
chevron: true,
|
||||
onTap: () {
|
||||
final page = StorageScreen(gateway: gateway);
|
||||
Navigator.of(context).push(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => page));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../settings_theme.dart';
|
||||
|
||||
class StorageAction extends StatelessWidget {
|
||||
const StorageAction({
|
||||
@@ -13,27 +11,15 @@ class StorageAction extends StatelessWidget {
|
||||
final VoidCallback? onPressed;
|
||||
final bool destructive;
|
||||
@override
|
||||
Widget build(BuildContext context) => usesCupertinoControls(context)
|
||||
? CupertinoButton(
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
label,
|
||||
style: destructive
|
||||
? TextStyle(
|
||||
color: CupertinoColors.destructiveRed.resolveFrom(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: onPressed,
|
||||
style: destructive
|
||||
? TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
)
|
||||
: null,
|
||||
child: Text(label),
|
||||
);
|
||||
Widget build(BuildContext context) => TextButton(
|
||||
onPressed: onPressed,
|
||||
style: destructive
|
||||
? TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
)
|
||||
: null,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
|
||||
class StorageSwitch extends StatelessWidget {
|
||||
@@ -52,9 +38,7 @@ class StorageSwitch extends StatelessWidget {
|
||||
Expanded(child: Text(label)),
|
||||
Semantics(
|
||||
label: label,
|
||||
child: usesCupertinoControls(context)
|
||||
? CupertinoSwitch(value: value, onChanged: onChanged)
|
||||
: Switch(value: value, onChanged: onChanged),
|
||||
child: Switch(value: value, onChanged: onChanged),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -77,35 +61,17 @@ class StorageInput extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final keyboard = TextInputType.numberWithOptions(decimal: decimal);
|
||||
return usesCupertinoControls(context)
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(label),
|
||||
const SizedBox(height: 8),
|
||||
Semantics(
|
||||
label: label,
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
placeholder: 'No limit',
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: TextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: 'No limit',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
return TextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: 'No limit',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_page_body.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'storage_cleanup.dart';
|
||||
import 'storage_controller.dart';
|
||||
import 'storage_controls.dart';
|
||||
@@ -93,45 +91,23 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
final preview = _controller.preview!;
|
||||
final message =
|
||||
'Permanently remove ${storageInt(preview['candidate_count'])} eligible items and reclaim up to ${storageBytes(storageInt(preview['reclaimable_bytes']))}? This cannot be undone.';
|
||||
final bool? confirmed;
|
||||
if (usesCupertinoControls(context)) {
|
||||
confirmed = await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed == true && mounted) await _controller.apply(policy);
|
||||
}
|
||||
|
||||
@@ -145,7 +121,6 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final content = SettingsPageBody(
|
||||
children: [
|
||||
if (_controller.busy)
|
||||
@@ -196,16 +171,9 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
),
|
||||
],
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('Storage'),
|
||||
),
|
||||
child: SafeArea(child: content),
|
||||
)
|
||||
: Scaffold(
|
||||
appBar: AppBar(title: const Text('Storage')),
|
||||
body: content,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Storage')),
|
||||
body: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../settings_group.dart';
|
||||
import 'storage_controls.dart';
|
||||
import 'storage_models.dart';
|
||||
@@ -67,10 +66,7 @@ class StorageUsage extends StatelessWidget {
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
);
|
||||
if (material != null) {
|
||||
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
|
||||
}
|
||||
final local = CupertinoLocalizations.of(context);
|
||||
return '${time.day} ${local.datePickerMonth(time.month)} ${time.year} · ${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
|
||||
if (material == null) return null;
|
||||
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# Performance round 5: moving a window does not rebuild its content
|
||||
|
||||
Round 5's candidate: every pointer event of a window drag rebuilt every
|
||||
window's whole content. `WindowScope` carried the body `Rect` and compared the
|
||||
whole `WindowEntry`, the navigator's `ThemeData` was rebuilt with `copyWith` on
|
||||
every build, and the root `MaterialPage` was a new object on every build.
|
||||
|
||||
## Change
|
||||
|
||||
`lib/shell/windows/`:
|
||||
|
||||
- `window_scope.dart`: `WindowScope` keeps only `manager` and `entry`, and
|
||||
notifies only when what content can read changes (id, kind, contentId,
|
||||
serverKey, `data`). A new `WindowBodyScope` (an `InheritedWidget` with the
|
||||
body `Rect`) carries the position and size that used to be in `WindowScope`.
|
||||
- `window_navigator.dart`: `WindowNavigator.theme(context, child:)` became
|
||||
`WindowNavigator.themeData(theme)`, so the layer can keep the
|
||||
page-transition `ThemeData`. `WindowPageBox` reads the body from
|
||||
`WindowBodyScope`, and its page child is a `RepaintBoundary`.
|
||||
- `window_layer.dart`: `_WindowLayerState` keeps the page-transition theme in a
|
||||
field and rebuilds it only when `Theme.of(context)` is a different object; it
|
||||
keeps the root `MaterialPage` in a field (same key) and rebuilds it only when
|
||||
the kind changes. `WindowFrame` is wrapped in a `RepaintBoundary`.
|
||||
|
||||
No behaviour change: frames, snapping, resize limits, popups, pushed pages,
|
||||
minimise/maximise, focus and the shell's APIs are as before.
|
||||
|
||||
`tool/capture/window_probe.dart`: `ProbeContentState.lastSize` records the
|
||||
`MediaQuery` size the content built at, so tests can see a resize reach it
|
||||
(no visual change).
|
||||
|
||||
## Deterministic build counts
|
||||
|
||||
`test/shell/windows/window_rebuild_test.dart`:
|
||||
|
||||
- dragging a window's title over 8 pointer moves: the dragged window's content
|
||||
and the other window's content keep their `builds` count (0 rebuilds);
|
||||
- resizing a window over 5 pointer moves: the other window keeps its count,
|
||||
the resized window's content rebuilds and sees the new `MediaQuery` size
|
||||
(360x380 -> 280x330 body);
|
||||
- `manager.setContent` retargets a content whose element is keyed stably: the
|
||||
same state rebuilds with the new contentId.
|
||||
|
||||
Against the old implementation (lib changes stashed, test run unchanged): 2
|
||||
failed — `dragged window rebuilt at move 0` (builds 2 -> 3) and `other window
|
||||
rebuilt at move 0` (2 -> 3). The new code passes all 3.
|
||||
|
||||
## Browser bench
|
||||
|
||||
Built twice: the old code (lib/shell/windows changes stashed) into
|
||||
`build/probe-before`, and this branch into `build/probe-app`:
|
||||
|
||||
```
|
||||
/Users/alan/development/flutter/bin/flutter build web \
|
||||
--target tool/search_selection_probe_entry.dart --output build/probe-before
|
||||
/Users/alan/development/flutter/bin/flutter build web \
|
||||
--target tool/search_selection_probe_entry.dart --output build/probe-app
|
||||
```
|
||||
|
||||
Run, from `app/`, against each build in turn:
|
||||
|
||||
```
|
||||
node tool/perf/interaction_bench.mjs --build build/probe-before --out /tmp/bench \
|
||||
--gpu --only 'desktop: drag a probe window' --repeat 3
|
||||
node tool/perf/interaction_bench.mjs --build build/probe-app --out /tmp/bench \
|
||||
--gpu --only 'desktop: drag a probe window' --repeat 3
|
||||
```
|
||||
|
||||
Three before/after rounds (the machine was shared with other pipeline test
|
||||
runs; load average 9-14 during these, so frame counts vary. `buildMs/frame =
|
||||
buildSum / frames`):
|
||||
|
||||
| round | code | frames | buildSum | ms/frame | buildMax | longest | over16 | rasterSum |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 1 | before | 50 | 952.2 | 19.0 | 63.5 | 73.9 | 31 | 107.4 |
|
||||
| 1 | after | 49 | 824.8 | 16.8 | 59.1 | 74.0 | 27 | 107.9 |
|
||||
| 2 | before | 49 | 615.6 | 12.6 | 25.5 | 28.4 | 15 | 62.1 |
|
||||
| 2 | after | 51 | 583.0 | 11.4 | 37.4 | 39.9 | 13 | 87.2 |
|
||||
| 3 | before | 51 | 527.9 | 10.4 | 16.2 | 20.3 | 9 | 68.3 |
|
||||
| 3 | after | 47 | 606.8 | 12.9 | 24.1 | 26.9 | 18 | 83.5 |
|
||||
|
||||
The browser numbers are inconclusive on this loaded machine: only round 1
|
||||
shows less build work, and the spread between rounds (10.4-19.0 ms/frame on the
|
||||
same code) is larger than the change. The reliable result is the build count:
|
||||
the drag went from one content build per pointer event per window (120 builds
|
||||
over a 40-move drag with three windows) to none. Window chrome and framework
|
||||
layout still run on every pointer event; that is the remaining build cost in
|
||||
this scenario, not content.
|
||||
|
||||
## Checks
|
||||
|
||||
- `tool/memwatch/full.sh 'test/shell/windows test/features/chat/chat_floating_pane_test.dart test/features/terminal'`:
|
||||
119 passed, 0 failed.
|
||||
- `tool/analyze.sh`: clean.
|
||||
|
||||
## Affected UI states (for ui-review)
|
||||
|
||||
`/runs?windows=2` at 1280x800 light: the windows after a title drag
|
||||
(`drag=250,132>300,150`), after a corner resize
|
||||
(`drag=483,523>120,80`), and a page pushed inside a window (click `page`) then
|
||||
dragged: the content must follow the window, stay inside it, and show no stale
|
||||
or clipped frame.
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -15,7 +14,7 @@ void main() {
|
||||
final navigator = GlobalKey<NavigatorState>();
|
||||
Future<JsonMap>? pending;
|
||||
|
||||
Future<void> pump(WidgetTester tester, {bool cupertino = false}) async {
|
||||
Future<void> pump(WidgetTester tester) async {
|
||||
machine = FakeMachine();
|
||||
gateway = ElevatingGateway(
|
||||
machine,
|
||||
@@ -35,12 +34,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(navigatorKey: navigator, home: home)
|
||||
: MaterialApp(
|
||||
navigatorKey: navigator,
|
||||
home: Scaffold(body: home),
|
||||
),
|
||||
MaterialApp(
|
||||
navigatorKey: navigator,
|
||||
home: Scaffold(body: home),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Run'));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -99,18 +96,6 @@ void main() {
|
||||
expect(machine.calls, ['chat_shell_run']);
|
||||
});
|
||||
|
||||
testWidgets('a Cupertino host gets the Cupertino dialog', (tester) async {
|
||||
await pump(tester, cupertino: true);
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('elevation-password')),
|
||||
'right',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('elevation-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
expect((await pending!)['type'], 'chat_shell_run_ok');
|
||||
});
|
||||
|
||||
testWidgets('without a mounted navigator the refusal is reported', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -34,61 +33,53 @@ class _Gateway extends FakeChatGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions
|
||||
.where(controller.isUnseen)
|
||||
.map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions.where(controller.isUnseen).map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
expect(find.byType(ChatCenterStageStrip), findsNWidgets(2));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(ChatCenterStageStrip).first,
|
||||
matching: find.byType(InkWell),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('draft'), findsOneWidget);
|
||||
|
||||
stage.value = false;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_mobile_panes.dart';
|
||||
@@ -36,54 +35,48 @@ class _ThreadState extends State<_Thread> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets(
|
||||
'peek title and switch fit $height height at 2x ($cupertino)',
|
||||
(tester) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets('peek title and switch fit $height height at 2x', (
|
||||
tester,
|
||||
) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: viewport))
|
||||
: MaterialApp(home: Scaffold(body: viewport)),
|
||||
);
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: viewport)));
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
expect(find.byType(TextButton), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
testWidgets('peek header reserves real body space and keeps reading state', (
|
||||
tester,
|
||||
|
||||
@@ -3,56 +3,47 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_entrance.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('retained entrance moves the same child ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: cupertino,
|
||||
child: Material(child: child),
|
||||
),
|
||||
testWidgets('retained entrance moves the same child', (tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: false,
|
||||
child: Material(child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(cupertino ? middle.dx : middle.dy, greaterThan(0));
|
||||
expect(
|
||||
cupertino ? middle.dx : middle.dy,
|
||||
lessThan(cupertino ? start.dx : start.dy),
|
||||
);
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(middle.dy, greaterThan(0));
|
||||
expect(middle.dy, lessThan(start.dy));
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/machine_access.dart';
|
||||
@@ -64,96 +63,90 @@ Future<void> addServer(
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('a new machine asks for its own password ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'mac',
|
||||
name: 'Mac',
|
||||
endpoints: ['ws://10.0.0.75:8083/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'mac',
|
||||
),
|
||||
testWidgets('a new machine asks for its own password', (tester) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'mac',
|
||||
name: 'Mac',
|
||||
endpoints: ['ws://10.0.0.75:8083/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'mac',
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final auth = FakeAuthenticator()
|
||||
..verdicts['mac'] = const MachineAccessResult(MachineAccess.connected);
|
||||
connections.authenticator = auth;
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: body)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
expect(find.text('Connected'), findsOneWidget);
|
||||
// The new machine is unknown to the authenticator until saved; a
|
||||
// password verdict arrives for whatever id the editor assigned.
|
||||
auth.verdicts.addAll({
|
||||
for (final id in ['pending']) id: const MachineAccessResult(
|
||||
MachineAccess.needsPassword,
|
||||
),
|
||||
});
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byKey(const Key('server-profile-name')), 'tank');
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'ws://10.0.0.100:8082/connect',
|
||||
);
|
||||
// Whatever id the editor chose, that machine wants a password.
|
||||
connections.addListener(() {
|
||||
for (final server in connections.catalog.servers) {
|
||||
auth.verdicts.putIfAbsent(
|
||||
server.id,
|
||||
() => const MachineAccessResult(MachineAccess.needsPassword),
|
||||
);
|
||||
auth.passwords.putIfAbsent(server.id, () => 'tank-secret');
|
||||
}
|
||||
});
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
final tank = connections.catalog.servers.firstWhere((s) => s.name == 'tank');
|
||||
expect(auth.probes, [tank.id]);
|
||||
// Saved, and the editor now asks this machine's password; the first
|
||||
// machine's sign-in is not reused.
|
||||
expect(find.byKey(const Key('server-profile-password')), findsOneWidget);
|
||||
expect(find.textContaining('asks for its own password'), findsOneWidget);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-password')),
|
||||
'wrong',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('server-profile-sign-in')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Wrong password.'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-profile-password')), findsOneWidget);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-password')),
|
||||
'tank-secret',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('server-profile-sign-in')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(auth.signIns, [(tank.id, 'wrong'), (tank.id, 'tank-secret')]);
|
||||
// Back on the list: both machines connected, each on its own sign-in.
|
||||
expect(find.byKey(const Key('server-profile-password')), findsNothing);
|
||||
expect(find.text('Connected'), findsNWidgets(2));
|
||||
expect(find.text('Address: ws://10.0.0.100:8082/connect'), findsOneWidget);
|
||||
expect(connections.catalog.active?.id, 'mac');
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final auth = FakeAuthenticator()
|
||||
..verdicts['mac'] = const MachineAccessResult(MachineAccess.connected);
|
||||
connections.authenticator = auth;
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
expect(find.text('Connected'), findsOneWidget);
|
||||
// The new machine is unknown to the authenticator until saved; a
|
||||
// password verdict arrives for whatever id the editor assigned.
|
||||
auth.verdicts.addAll({
|
||||
for (final id in ['pending'])
|
||||
id: const MachineAccessResult(MachineAccess.needsPassword),
|
||||
});
|
||||
}
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'tank',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'ws://10.0.0.100:8082/connect',
|
||||
);
|
||||
// Whatever id the editor chose, that machine wants a password.
|
||||
connections.addListener(() {
|
||||
for (final server in connections.catalog.servers) {
|
||||
auth.verdicts.putIfAbsent(
|
||||
server.id,
|
||||
() => const MachineAccessResult(MachineAccess.needsPassword),
|
||||
);
|
||||
auth.passwords.putIfAbsent(server.id, () => 'tank-secret');
|
||||
}
|
||||
});
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
final tank = connections.catalog.servers.firstWhere(
|
||||
(s) => s.name == 'tank',
|
||||
);
|
||||
expect(auth.probes, [tank.id]);
|
||||
// Saved, and the editor now asks this machine's password; the first
|
||||
// machine's sign-in is not reused.
|
||||
expect(find.byKey(const Key('server-profile-password')), findsOneWidget);
|
||||
expect(find.textContaining('asks for its own password'), findsOneWidget);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-password')),
|
||||
'wrong',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('server-profile-sign-in')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Wrong password.'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-profile-password')), findsOneWidget);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-password')),
|
||||
'tank-secret',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('server-profile-sign-in')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(auth.signIns, [(tank.id, 'wrong'), (tank.id, 'tank-secret')]);
|
||||
// Back on the list: both machines connected, each on its own sign-in.
|
||||
expect(find.byKey(const Key('server-profile-password')), findsNothing);
|
||||
expect(find.text('Connected'), findsNWidgets(2));
|
||||
expect(find.text('Address: ws://10.0.0.100:8082/connect'), findsOneWidget);
|
||||
expect(connections.catalog.active?.id, 'mac');
|
||||
});
|
||||
|
||||
testWidgets('an unreachable machine stays saved with the reason shown', (
|
||||
tester,
|
||||
@@ -172,7 +165,8 @@ void main() {
|
||||
server.id,
|
||||
() => const MachineAccessResult(
|
||||
MachineAccess.unreachable,
|
||||
detail: 'The HTTPS certificate of 100.85.25.33:8443 does not '
|
||||
detail:
|
||||
'The HTTPS certificate of 100.85.25.33:8443 does not '
|
||||
'cover an IP address.',
|
||||
),
|
||||
);
|
||||
@@ -198,7 +192,10 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('server-sign-in-later')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.servers.single.name, 'Mac by IP');
|
||||
expect(find.textContaining('Unreachable: The HTTPS certificate'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Unreachable: The HTTPS certificate'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a saved machine that wants a password offers Sign in', (
|
||||
@@ -218,7 +215,9 @@ void main() {
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final auth = FakeAuthenticator()
|
||||
..verdicts['tank'] = const MachineAccessResult(MachineAccess.needsPassword)
|
||||
..verdicts['tank'] = const MachineAccessResult(
|
||||
MachineAccess.needsPassword,
|
||||
)
|
||||
..passwords['tank'] = 'tank-secret';
|
||||
connections.authenticator = auth;
|
||||
await tester.pumpWidget(
|
||||
@@ -231,7 +230,10 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Sign in to tank'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byKey(const Key('machine-password')), 'tank-secret');
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('machine-password')),
|
||||
'tank-secret',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('machine-sign-in')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(auth.signIns, [('tank', 'tank-secret')]);
|
||||
@@ -248,7 +250,9 @@ void main() {
|
||||
endpoints: ['ws://10.0.0.75:8083/connect'],
|
||||
);
|
||||
final auth = FakeAuthenticator()
|
||||
..verdicts['mac'] = const MachineAccessResult(MachineAccess.needsPassword);
|
||||
..verdicts['mac'] = const MachineAccessResult(
|
||||
MachineAccess.needsPassword,
|
||||
);
|
||||
SavedServer? saved;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -269,7 +273,10 @@ void main() {
|
||||
);
|
||||
await tester.tap(find.text('Edit'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byKey(const Key('server-profile-name')), 'Studio');
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'Studio',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/storage/storage_screen.dart';
|
||||
@@ -7,8 +6,7 @@ import '../../../../tool/storage_probe_fixture.dart';
|
||||
|
||||
Future<void> _mount(
|
||||
WidgetTester tester,
|
||||
StorageProbeGateway gateway,
|
||||
bool cupertino, {
|
||||
StorageProbeGateway gateway, {
|
||||
double width = 900,
|
||||
double scale = 1,
|
||||
}) async {
|
||||
@@ -20,11 +18,7 @@ Future<void> _mount(
|
||||
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(builder: builder, home: screen)
|
||||
: MaterialApp(builder: builder, home: screen),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(builder: builder, home: screen));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -43,83 +37,72 @@ Finder _field(String label) => find.descendant(
|
||||
matching: find.byType(EditableText),
|
||||
);
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final style = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets(
|
||||
'$style usage and partial measurement remain honest at 2x narrow',
|
||||
(tester) async {
|
||||
final gateway = StorageProbeGateway();
|
||||
await _mount(tester, gateway, cupertino, width: 560, scale: 2);
|
||||
expect(find.text('At least 15.0 GiB used'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Measurement is incomplete. See details below.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Database'), findsOneWidget);
|
||||
expect(find.textContaining('6 November 2026'), findsOneWidget);
|
||||
expect(find.text('Worktrees'), findsOneWidget);
|
||||
await _tap(tester, 'Preview cleanup');
|
||||
expect(find.text('Cleanup preview'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Protected · worktree active-item · 4.00 GiB'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
testWidgets('usage and partial measurement remain honest at 2x narrow', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = StorageProbeGateway();
|
||||
await _mount(tester, gateway, width: 560, scale: 2);
|
||||
expect(find.text('At least 15.0 GiB used'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Measurement is incomplete. See details below.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
testWidgets(
|
||||
'$style cleanup cancellation does not mutate and confirmation uses token',
|
||||
(tester) async {
|
||||
final gateway = StorageProbeGateway();
|
||||
await _mount(tester, gateway, cupertino);
|
||||
await _tap(tester, 'Preview cleanup');
|
||||
await _tap(tester, 'Apply cleanup');
|
||||
expect(find.text('Apply cleanup?'), findsOneWidget);
|
||||
await _tap(tester, 'Cancel');
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'apply_storage_cleanup'),
|
||||
isEmpty,
|
||||
);
|
||||
await _tap(tester, 'Apply cleanup');
|
||||
await _tap(tester, 'Remove items');
|
||||
expect(
|
||||
gateway.calls
|
||||
.singleWhere((call) => call.type == 'apply_storage_cleanup')
|
||||
.fields['storage_cleanup_token'],
|
||||
'fixture-preview-token',
|
||||
);
|
||||
expect(find.text('Cleanup result'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Worktree became active and was kept.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
expect(find.text('Database'), findsOneWidget);
|
||||
expect(find.textContaining('6 November 2026'), findsOneWidget);
|
||||
expect(find.text('Worktrees'), findsOneWidget);
|
||||
await _tap(tester, 'Preview cleanup');
|
||||
expect(find.text('Cleanup preview'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Protected · worktree active-item · 4.00 GiB'),
|
||||
findsOneWidget,
|
||||
);
|
||||
testWidgets('$style invalid limits do not send a policy', (tester) async {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets(
|
||||
'cleanup cancellation does not mutate and confirmation uses token',
|
||||
(tester) async {
|
||||
final gateway = StorageProbeGateway();
|
||||
await _mount(tester, gateway, cupertino);
|
||||
await tester.ensureVisible(_field('Retain data for days'));
|
||||
await tester.enterText(_field('Retain data for days'), '-1');
|
||||
await _tap(tester, 'Save policy');
|
||||
await _mount(tester, gateway);
|
||||
await _tap(tester, 'Preview cleanup');
|
||||
await _tap(tester, 'Apply cleanup');
|
||||
expect(find.text('Apply cleanup?'), findsOneWidget);
|
||||
await _tap(tester, 'Cancel');
|
||||
expect(
|
||||
find.textContaining('Enter a whole number of days'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'set_storage_policy'),
|
||||
gateway.calls.where((call) => call.type == 'apply_storage_cleanup'),
|
||||
isEmpty,
|
||||
);
|
||||
});
|
||||
testWidgets(
|
||||
'$style unsupported server has an actionable error and no fake usage',
|
||||
(tester) async {
|
||||
final gateway = StorageProbeGateway()..unsupported = true;
|
||||
await _mount(tester, gateway, cupertino);
|
||||
expect(find.text('Unknown command: get_storage'), findsOneWidget);
|
||||
expect(find.text('Server storage'), findsNothing);
|
||||
expect(find.text('Refresh storage'), findsOneWidget);
|
||||
},
|
||||
await _tap(tester, 'Apply cleanup');
|
||||
await _tap(tester, 'Remove items');
|
||||
expect(
|
||||
gateway.calls
|
||||
.singleWhere((call) => call.type == 'apply_storage_cleanup')
|
||||
.fields['storage_cleanup_token'],
|
||||
'fixture-preview-token',
|
||||
);
|
||||
expect(find.text('Cleanup result'), findsOneWidget);
|
||||
expect(find.text('Worktree became active and was kept.'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
testWidgets('invalid limits do not send a policy', (tester) async {
|
||||
final gateway = StorageProbeGateway();
|
||||
await _mount(tester, gateway);
|
||||
await tester.ensureVisible(_field('Retain data for days'));
|
||||
await tester.enterText(_field('Retain data for days'), '-1');
|
||||
await _tap(tester, 'Save policy');
|
||||
expect(find.textContaining('Enter a whole number of days'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'set_storage_policy'),
|
||||
isEmpty,
|
||||
);
|
||||
}
|
||||
});
|
||||
testWidgets('unsupported server has an actionable error and no fake usage', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = StorageProbeGateway()..unsupported = true;
|
||||
await _mount(tester, gateway);
|
||||
expect(find.text('Unknown command: get_storage'), findsOneWidget);
|
||||
expect(find.text('Server storage'), findsNothing);
|
||||
expect(find.text('Refresh storage'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_entry.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_kind.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_layer.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
|
||||
import 'window_test_harness.dart';
|
||||
|
||||
/// A probe kind whose content keeps its element when the window is retargeted,
|
||||
/// so a rebuild is visible in the same state's counter.
|
||||
class _StableProbeKind extends WindowKind {
|
||||
@override
|
||||
String get key => 'stable';
|
||||
@override
|
||||
bool get serverScoped => false;
|
||||
@override
|
||||
IconData get icon => Icons.science_outlined;
|
||||
@override
|
||||
String title(BuildContext context, WindowEntry entry) =>
|
||||
'Probe ${entry.contentId}';
|
||||
@override
|
||||
Widget build(BuildContext context, WindowEntry entry) =>
|
||||
ProbeContent(key: const ValueKey('stable-content'), id: entry.contentId);
|
||||
}
|
||||
|
||||
void main() {
|
||||
late WindowManager manager;
|
||||
setUp(() => manager = probeManager());
|
||||
|
||||
Finder window(String title) => find.byWidgetPredicate(
|
||||
(w) => w is WindowLayer && 'Probe ${w.entry.contentId}' == title,
|
||||
);
|
||||
Finder inWindow(String title, Finder what) =>
|
||||
find.descendant(of: window(title), matching: what);
|
||||
ProbeContentState content(WidgetTester tester, String id) =>
|
||||
tester.state<ProbeContentState>(find.byKey(ValueKey('content-$id')));
|
||||
|
||||
Future<void> openTwo(WidgetTester tester) async {
|
||||
manager.open('probe', 'a', frame: const Rect.fromLTWH(100, 80, 360, 420));
|
||||
manager.open('probe', 'b', frame: const Rect.fromLTWH(600, 200, 360, 420));
|
||||
await pumpProbe(tester, manager);
|
||||
}
|
||||
|
||||
testWidgets('dragging a window moves it without rebuilding any content', (
|
||||
tester,
|
||||
) async {
|
||||
await openTwo(tester);
|
||||
final a = content(tester, 'a');
|
||||
final b = content(tester, 'b');
|
||||
final beforeA = a.builds;
|
||||
final beforeB = b.builds;
|
||||
final start = windowRect(tester, 'Probe a').topLeft;
|
||||
final fieldStart = tester
|
||||
.getRect(find.byKey(const ValueKey('a-field')))
|
||||
.topLeft;
|
||||
final gesture = await tester.startGesture(
|
||||
tester.getCenter(
|
||||
inWindow('Probe a', find.byKey(const ValueKey('window-title'))),
|
||||
),
|
||||
);
|
||||
for (var i = 0; i < 8; i++) {
|
||||
await gesture.moveBy(const Offset(12, 6));
|
||||
await tester.pump();
|
||||
expect(a.builds, beforeA, reason: 'dragged window rebuilt at move $i');
|
||||
expect(b.builds, beforeB, reason: 'other window rebuilt at move $i');
|
||||
}
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
// It really moved, and its content followed it.
|
||||
expect(windowRect(tester, 'Probe a').topLeft, start + const Offset(96, 48));
|
||||
expect(
|
||||
tester.getRect(find.byKey(const ValueKey('a-field'))).topLeft,
|
||||
fieldStart + const Offset(96, 48),
|
||||
);
|
||||
expect(content(tester, 'a').builds, beforeA);
|
||||
expect(content(tester, 'b').builds, beforeB);
|
||||
});
|
||||
|
||||
testWidgets('resizing a window keeps another window and sees the new size', (
|
||||
tester,
|
||||
) async {
|
||||
await openTwo(tester);
|
||||
final a = content(tester, 'a');
|
||||
final b = content(tester, 'b');
|
||||
final beforeA = a.builds;
|
||||
final beforeB = b.builds;
|
||||
final beforeSize = b.lastSize!;
|
||||
final gesture = await tester.startGesture(
|
||||
tester.getCenter(
|
||||
inWindow('Probe b', find.byKey(const ValueKey('window-resize'))),
|
||||
),
|
||||
);
|
||||
for (var i = 0; i < 5; i++) {
|
||||
await gesture.moveBy(const Offset(-16, -10));
|
||||
await tester.pump();
|
||||
expect(a.builds, beforeA, reason: 'other window rebuilt at move $i');
|
||||
}
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(content(tester, 'a').builds, beforeA);
|
||||
final state = content(tester, 'b');
|
||||
expect(state.builds, greaterThan(beforeB));
|
||||
expect(state.lastSize!.width, beforeSize.width - 80);
|
||||
expect(state.lastSize!.height, beforeSize.height - 50);
|
||||
});
|
||||
|
||||
testWidgets('content still rebuilds when its window is retargeted', (
|
||||
tester,
|
||||
) async {
|
||||
manager = WindowManager(
|
||||
kinds: WindowKinds()..register(_StableProbeKind()),
|
||||
);
|
||||
final entry = manager.open('stable', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
final state = tester.state<ProbeContentState>(
|
||||
find.byKey(const ValueKey('stable-content')),
|
||||
);
|
||||
final before = state.builds;
|
||||
manager.setContent(entry.id, 'c');
|
||||
await tester.pumpAndSettle();
|
||||
final after = tester.state<ProbeContentState>(
|
||||
find.byKey(const ValueKey('stable-content')),
|
||||
);
|
||||
expect(after, same(state));
|
||||
expect(after.builds, greaterThan(before));
|
||||
expect(after.widget.id, 'c');
|
||||
expect(find.text('Probe c'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -52,6 +52,10 @@ class ProbeContentState extends State<ProbeContent> {
|
||||
int builds = 0;
|
||||
String? picked;
|
||||
|
||||
/// The size the content was last laid out at (the window's content area),
|
||||
/// so tests can see a resize reach it.
|
||||
Size? lastSize;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
text.dispose();
|
||||
@@ -67,6 +71,7 @@ class ProbeContentState extends State<ProbeContent> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
builds++;
|
||||
lastSize = MediaQuery.sizeOf(context);
|
||||
final id = widget.id;
|
||||
return ListView(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user