Merge looping mobile tape and remembered peek resizing
This commit is contained in:
@@ -281,18 +281,33 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
position: DecorationPosition.foreground,
|
position: DecorationPosition.foreground,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: !showsListBesideDetail(context)
|
||||||
color: _workspace.paneCount > 1 && active
|
? Border(
|
||||||
? chatColorShade(
|
bottom: BorderSide(
|
||||||
context,
|
color: _workspace.paneCount > 1 && active
|
||||||
chatSessionColor(_rowFor(pane.sessionId)),
|
? chatColorShade(
|
||||||
) ??
|
context,
|
||||||
(chatControlsStyleOf(context) ==
|
chatSessionColor(_rowFor(pane.sessionId)),
|
||||||
ChatControlsStyle.cupertino
|
) ??
|
||||||
? CupertinoTheme.of(context).primaryColor
|
(chatControlsStyleOf(context) ==
|
||||||
: Theme.of(context).colorScheme.primary)
|
ChatControlsStyle.cupertino
|
||||||
: Colors.transparent,
|
? CupertinoTheme.of(context).primaryColor
|
||||||
),
|
: Theme.of(context).colorScheme.primary)
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Border.all(
|
||||||
|
color: _workspace.paneCount > 1 && active
|
||||||
|
? chatColorShade(
|
||||||
|
context,
|
||||||
|
chatSessionColor(_rowFor(pane.sessionId)),
|
||||||
|
) ??
|
||||||
|
(chatControlsStyleOf(context) ==
|
||||||
|
ChatControlsStyle.cupertino
|
||||||
|
? CupertinoTheme.of(context).primaryColor
|
||||||
|
: Theme.of(context).colorScheme.primary)
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: DetailPane(
|
child: DetailPane(
|
||||||
key: ValueKey('chat-pane-detail-${pane.id}'),
|
key: ValueKey('chat-pane-detail-${pane.id}'),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class ChatMobilePanes {
|
|||||||
required String activeId,
|
required String activeId,
|
||||||
required String? peekId,
|
required String? peekId,
|
||||||
required Size size,
|
required Size size,
|
||||||
|
double peekFraction = .2,
|
||||||
}) {
|
}) {
|
||||||
final active = panes.firstWhere((pane) => pane.id == activeId);
|
final active = panes.firstWhere((pane) => pane.id == activeId);
|
||||||
this.activeId = active.id;
|
this.activeId = active.id;
|
||||||
@@ -29,7 +30,9 @@ class ChatMobilePanes {
|
|||||||
this.activeId = active.id;
|
this.activeId = active.id;
|
||||||
const gap = 6.0;
|
const gap = 6.0;
|
||||||
final available = math.max(0.0, size.height - gap);
|
final available = math.max(0.0, size.height - gap);
|
||||||
final peekHeight = available * .2;
|
final maximum = available * .2;
|
||||||
|
final minimum = math.min(48.0, maximum);
|
||||||
|
final peekHeight = (available * peekFraction).clamp(minimum, maximum);
|
||||||
contentHeight = available - peekHeight;
|
contentHeight = available - peekHeight;
|
||||||
// Selection always promotes the active conversation to the top.
|
// Selection always promotes the active conversation to the top.
|
||||||
rects[active.id] = Rect.fromLTWH(0, 0, size.width, contentHeight);
|
rects[active.id] = Rect.fromLTWH(0, 0, size.width, contentHeight);
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// A transparent touch target centred on the active chat's coloured bottom
|
||||||
|
/// border. Height is bounded by the original 20% peek and a nonzero minimum.
|
||||||
|
class ChatMobilePeekDivider extends StatefulWidget {
|
||||||
|
const ChatMobilePeekDivider({
|
||||||
|
super.key,
|
||||||
|
required this.height,
|
||||||
|
required this.available,
|
||||||
|
required this.onChanged,
|
||||||
|
});
|
||||||
|
final double height;
|
||||||
|
final double available;
|
||||||
|
final ValueChanged<double> onChanged;
|
||||||
|
@override
|
||||||
|
State<ChatMobilePeekDivider> createState() => _ChatMobilePeekDividerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChatMobilePeekDividerState extends State<ChatMobilePeekDivider> {
|
||||||
|
double? _dragHeight;
|
||||||
|
double get _maximum => widget.available * .2;
|
||||||
|
double get _minimum => math.min(48.0, _maximum);
|
||||||
|
void _change(double value) {
|
||||||
|
if (widget.available <= 0) return;
|
||||||
|
widget.onChanged(value.clamp(_minimum, _maximum) / widget.available);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _step(double delta) => _change(widget.height + delta);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Semantics(
|
||||||
|
identifier: 'chat-mobile-peek-divider',
|
||||||
|
label: 'Resize inactive chat',
|
||||||
|
slider: true,
|
||||||
|
value: '${widget.height.round()} pixels',
|
||||||
|
increasedValue:
|
||||||
|
'${(widget.height + 16).clamp(_minimum, _maximum).round()} pixels',
|
||||||
|
decreasedValue:
|
||||||
|
'${(widget.height - 16).clamp(_minimum, _maximum).round()} pixels',
|
||||||
|
onIncrease: () => _step(16),
|
||||||
|
onDecrease: () => _step(-16),
|
||||||
|
child: Focus(
|
||||||
|
onKeyEvent: (_, event) {
|
||||||
|
if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
}
|
||||||
|
if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
|
||||||
|
_step(16);
|
||||||
|
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
||||||
|
_step(-16);
|
||||||
|
} else {
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
}
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
},
|
||||||
|
child: MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.resizeRow,
|
||||||
|
child: GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onVerticalDragStart: (_) => _dragHeight = widget.height,
|
||||||
|
onVerticalDragUpdate: (details) {
|
||||||
|
_dragHeight = (_dragHeight ?? widget.height) - details.delta.dy;
|
||||||
|
_change(_dragHeight!);
|
||||||
|
},
|
||||||
|
onVerticalDragEnd: (_) => _dragHeight = null,
|
||||||
|
onVerticalDragCancel: () => _dragHeight = null,
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,10 +2,9 @@ import 'dart:ui' as ui;
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
/// One bounded, temporary picture behind crossing panes. It fills vacated
|
/// One bounded, temporary picture for the outgoing tape segment. It avoids a
|
||||||
/// regions without a second live chat tree or per-frame capture. The current
|
/// second live chat tree or per-frame capture. Every old image is released
|
||||||
/// picture can seed an interrupted swap; every old image is released after
|
/// after its last painted frame. Pixel scale is capped at two (~9 MB at 560×1000).
|
||||||
/// its last painted frame. Pixel scale is capped at two (~9 MB at 560×1000).
|
|
||||||
class ChatPaneBackdrop extends ChangeNotifier {
|
class ChatPaneBackdrop extends ChangeNotifier {
|
||||||
ChatPaneBackdrop(this.motion) {
|
ChatPaneBackdrop(this.motion) {
|
||||||
motion.addStatusListener(_settled);
|
motion.addStatusListener(_settled);
|
||||||
@@ -16,22 +15,27 @@ class ChatPaneBackdrop extends ChangeNotifier {
|
|||||||
bool _scheduled = false;
|
bool _scheduled = false;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
|
||||||
void capture(BuildContext context) {
|
bool capture(BuildContext context) {
|
||||||
final boundary = pictureKey.currentContext?.findRenderObject();
|
final boundary = pictureKey.currentContext?.findRenderObject();
|
||||||
if (boundary is! _PictureBoundary || !boundary.hasPicture) {
|
if (boundary is! _PictureBoundary || !boundary.hasPicture) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
var ready = true;
|
var ready = true;
|
||||||
assert(() {
|
assert(() {
|
||||||
ready = !boundary.debugNeedsPaint;
|
ready = !boundary.debugNeedsPaint;
|
||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
if (!ready) return;
|
if (!ready) return false;
|
||||||
final old = image;
|
final old = image;
|
||||||
image = boundary.toImageSync(
|
try {
|
||||||
pixelRatio: MediaQuery.devicePixelRatioOf(context).clamp(1, 2),
|
image = boundary.toImageSync(
|
||||||
);
|
pixelRatio: MediaQuery.devicePixelRatioOf(context).clamp(1, 2),
|
||||||
|
);
|
||||||
|
} on Object {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (old != null) _release(old);
|
if (old != null) _release(old);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _settled(AnimationStatus status) {
|
void _settled(AnimationStatus status) {
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
/// A raised foreground while phone chats cross. The transcript still lays out
|
|
||||||
/// at its real animated height, so the settled peek can reach its final row.
|
|
||||||
class ChatPaneSwapCard extends StatelessWidget {
|
|
||||||
const ChatPaneSwapCard({
|
|
||||||
super.key,
|
|
||||||
required this.enabled,
|
|
||||||
required this.lift,
|
|
||||||
required this.child,
|
|
||||||
});
|
|
||||||
|
|
||||||
final bool enabled;
|
|
||||||
final double lift;
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
final amount = enabled ? lift : 0.0;
|
|
||||||
final radius = BorderRadius.circular(16 * amount);
|
|
||||||
return DecoratedBox(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: enabled ? theme.colorScheme.surface : null,
|
|
||||||
borderRadius: radius,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: theme.shadowColor.withValues(alpha: .24 * amount),
|
|
||||||
blurRadius: 24 * amount,
|
|
||||||
spreadRadius: 2 * amount,
|
|
||||||
offset: Offset(0, -6 * amount),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: ClipRRect(borderRadius: radius, child: child),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
import 'dart:ui' show lerpDouble;
|
import 'dart:ui' show lerpDouble;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
/// One continuous phone-pane swap. Both cards travel together; the incoming card grows
|
/// A looping vertical tape. The old active picture exits above the incoming
|
||||||
/// ahead of the outgoing card shrinking. Chrome follows the shared ease; an interrupted swap starts at their current values.
|
/// live chat, while its retained live view re-enters below at the peek height.
|
||||||
/// The app's scheduler speed preference scales this ticker once globally.
|
/// Every live transcript exists once and keeps its real visible viewport.
|
||||||
class ChatPaneSwitchMotion {
|
class ChatPaneSwitchMotion {
|
||||||
ChatPaneSwitchMotion({required TickerProvider vsync})
|
ChatPaneSwitchMotion({required TickerProvider vsync})
|
||||||
: _controller = AnimationController(
|
: _controller = AnimationController(
|
||||||
@@ -14,8 +13,8 @@ class ChatPaneSwitchMotion {
|
|||||||
value: 1,
|
value: 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
static const Duration duration = Duration(milliseconds: 480);
|
static const Duration duration = Duration(milliseconds: 560);
|
||||||
static const Curve curve = Cubic(.22, .7, .24, 1);
|
static const Curve curve = Cubic(.4, 0, .2, 1);
|
||||||
final AnimationController _controller;
|
final AnimationController _controller;
|
||||||
Animation<double> get animation => _controller.view;
|
Animation<double> get animation => _controller.view;
|
||||||
final Map<String, Animation<double>> _reveals = {};
|
final Map<String, Animation<double>> _reveals = {};
|
||||||
@@ -24,8 +23,9 @@ class ChatPaneSwitchMotion {
|
|||||||
Map<String, double> _barFrom = const {};
|
Map<String, double> _barFrom = const {};
|
||||||
Map<String, double> _barTo = const {};
|
Map<String, double> _barTo = const {};
|
||||||
Size? _size;
|
Size? _size;
|
||||||
String? _incomingId;
|
String? _activeId;
|
||||||
Map<String, double> _liftFrom = const {};
|
String? _outgoingId;
|
||||||
|
Rect? outgoingSourceRect;
|
||||||
bool get isAnimating => _controller.isAnimating;
|
bool get isAnimating => _controller.isAnimating;
|
||||||
double get _progress => curve.transform(_controller.value);
|
double get _progress => curve.transform(_controller.value);
|
||||||
|
|
||||||
@@ -41,22 +41,29 @@ class ChatPaneSwitchMotion {
|
|||||||
required bool switching,
|
required bool switching,
|
||||||
required bool animate,
|
required bool animate,
|
||||||
}) {
|
}) {
|
||||||
final travel = switching && animate && _size == size && _to.isNotEmpty;
|
final travel =
|
||||||
|
switching &&
|
||||||
|
animate &&
|
||||||
|
_size == size &&
|
||||||
|
_to.length > 1 &&
|
||||||
|
rects.length > 1 &&
|
||||||
|
_activeId != activeId;
|
||||||
_size = size;
|
_size = size;
|
||||||
if (travel) {
|
if (travel) {
|
||||||
final ids = {..._to.keys, ...rects.keys};
|
_outgoingId = _activeId;
|
||||||
_liftFrom = {for (final id in ids) id: liftFor(id)};
|
outgoingSourceRect = _to[_outgoingId];
|
||||||
_from = {for (final id in ids) id: rectFor(id) ?? rects[id]!};
|
final peek = rects.values.firstWhere((rect) => rect.top > 0);
|
||||||
_barFrom = {for (final id in ids) id: _reveal(id)};
|
_from = {..._to, activeId: _to[activeId] ?? peek};
|
||||||
_incomingId = activeId;
|
|
||||||
_to = rects;
|
_to = rects;
|
||||||
|
_barFrom = {for (final id in rects.keys) id: 0};
|
||||||
_barTo = {for (final id in rects.keys) id: id == activeId ? 1 : 0};
|
_barTo = {for (final id in rects.keys) id: id == activeId ? 1 : 0};
|
||||||
|
_activeId = activeId;
|
||||||
_controller.forward(from: 0);
|
_controller.forward(from: 0);
|
||||||
} else if (!mapEquals(rects, _to) || !animate) {
|
} else if (!mapEquals(rects, _to) || !animate) {
|
||||||
_incomingId = null;
|
_from = _to = rects;
|
||||||
_liftFrom = const {};
|
_activeId = activeId;
|
||||||
_from = rects;
|
_outgoingId = null;
|
||||||
_to = rects;
|
outgoingSourceRect = null;
|
||||||
_barFrom = _barTo = {
|
_barFrom = _barTo = {
|
||||||
for (final id in rects.keys) id: id == activeId ? 1 : 0,
|
for (final id in rects.keys) id: id == activeId ? 1 : 0,
|
||||||
};
|
};
|
||||||
@@ -69,41 +76,33 @@ class ChatPaneSwitchMotion {
|
|||||||
_from = _to = const {};
|
_from = _to = const {};
|
||||||
_barFrom = _barTo = const {};
|
_barFrom = _barTo = const {};
|
||||||
_size = null;
|
_size = null;
|
||||||
_incomingId = null;
|
_activeId = _outgoingId = null;
|
||||||
_liftFrom = const {};
|
outgoingSourceRect = null;
|
||||||
_controller.value = 1;
|
_controller.value = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect? rectFor(String id) {
|
Rect? rectFor(String id) {
|
||||||
final to = _to[id];
|
final to = _to[id];
|
||||||
if (to == null) return null;
|
if (to == null) return null;
|
||||||
final from = _from[id] ?? to;
|
if (_outgoingId == id && outgoingSourceRect != null) {
|
||||||
final t = _progress;
|
// The old active's snapshot owns its top exit. Its single live tree is
|
||||||
// Separate travel from resizing: overlapping cards should read as passing
|
// already a true small viewport and loops in from below the screen.
|
||||||
// over/under each other rather than collapsing into the same small strip.
|
final gap = to.top - _to[_activeId]!.bottom;
|
||||||
final sizeT = id == _incomingId ? Curves.easeOut.transform(t) : t * t;
|
return to.translate(0, (_size!.height + gap - to.top) * (1 - _progress));
|
||||||
return Rect.fromLTWH(
|
}
|
||||||
lerpDouble(from.left, to.left, t)!,
|
return Rect.lerp(_from[id] ?? to, to, _progress);
|
||||||
lerpDouble(from.top, to.top, t)!,
|
|
||||||
lerpDouble(from.width, to.width, t)!,
|
|
||||||
lerpDouble(from.height, to.height, sizeT)!,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A short lift on the foreground card; interruptions keep the current
|
Rect? get exitingRect {
|
||||||
/// elevation before handing the foreground to the newly selected pane.
|
final source = outgoingSourceRect;
|
||||||
double liftFor(String id) {
|
final incoming = _from[_activeId];
|
||||||
final t = _controller.value;
|
if (!isAnimating || source == null || incoming == null) return null;
|
||||||
final previous = (_liftFrom[id] ?? 0) * (1 - _progress);
|
return source.translate(0, -incoming.top * _progress);
|
||||||
final lift = id == _incomingId ? math.sin(math.pi * t) : 0.0;
|
|
||||||
return (previous + lift).clamp(0.0, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() => _controller.dispose();
|
void dispose() => _controller.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stable per-pane listenable: a role swap never replaces the reveal animation
|
|
||||||
/// or jumps its opacity back to an endpoint when a switch is interrupted.
|
|
||||||
class _PaneReveal extends Animation<double> {
|
class _PaneReveal extends Animation<double> {
|
||||||
_PaneReveal(this.motion, this.id);
|
_PaneReveal(this.motion, this.id);
|
||||||
final ChatPaneSwitchMotion motion;
|
final ChatPaneSwitchMotion motion;
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import 'dart:ui' as ui;
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Only the top exit is a picture. The looping chat below remains one retained
|
||||||
|
/// live tree; the picture is released when the tape completes.
|
||||||
|
class ChatTapeExit extends CustomPainter {
|
||||||
|
const ChatTapeExit({
|
||||||
|
required this.image,
|
||||||
|
required this.source,
|
||||||
|
required this.workspace,
|
||||||
|
});
|
||||||
|
final ui.Image image;
|
||||||
|
final Rect source;
|
||||||
|
final Size workspace;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final scale = image.width / workspace.width;
|
||||||
|
canvas.drawImageRect(
|
||||||
|
image,
|
||||||
|
Rect.fromLTRB(
|
||||||
|
source.left * scale,
|
||||||
|
source.top * scale,
|
||||||
|
source.right * scale,
|
||||||
|
source.bottom * scale,
|
||||||
|
),
|
||||||
|
Offset.zero & size,
|
||||||
|
Paint(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(ChatTapeExit oldDelegate) =>
|
||||||
|
image != oldDelegate.image ||
|
||||||
|
source != oldDelegate.source ||
|
||||||
|
workspace != oldDelegate.workspace;
|
||||||
|
}
|
||||||
@@ -4,12 +4,11 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'chat_workspace_controller.dart';
|
import 'chat_workspace_controller.dart';
|
||||||
import 'chat_workspace_divider.dart';
|
|
||||||
import 'chat_workspace_geometry.dart';
|
import 'chat_workspace_geometry.dart';
|
||||||
import 'chat_mobile_panes.dart';
|
import 'chat_mobile_panes.dart';
|
||||||
import 'chat_pane_switch_motion.dart';
|
import 'chat_pane_switch_motion.dart';
|
||||||
import 'chat_pane_backdrop.dart';
|
import 'chat_pane_backdrop.dart';
|
||||||
import 'chat_pane_swap_card.dart';
|
import 'chat_workspace_surface.dart';
|
||||||
|
|
||||||
export 'chat_workspace_controller.dart';
|
export 'chat_workspace_controller.dart';
|
||||||
export 'chat_workspace_geometry.dart' show ChatPaneDirection;
|
export 'chat_workspace_geometry.dart' show ChatPaneDirection;
|
||||||
@@ -29,6 +28,7 @@ class ChatWorkspace extends StatefulWidget {
|
|||||||
this.singlePane = false,
|
this.singlePane = false,
|
||||||
this.mobilePeeks = false,
|
this.mobilePeeks = false,
|
||||||
this.paneTitle,
|
this.paneTitle,
|
||||||
|
this.onVisibleSessionIdsChanged,
|
||||||
});
|
});
|
||||||
final ChatWorkspaceController controller;
|
final ChatWorkspaceController controller;
|
||||||
final ChatWorkspacePaneBuilder paneBuilder;
|
final ChatWorkspacePaneBuilder paneBuilder;
|
||||||
@@ -38,6 +38,7 @@ class ChatWorkspace extends StatefulWidget {
|
|||||||
final bool singlePane;
|
final bool singlePane;
|
||||||
final bool mobilePeeks;
|
final bool mobilePeeks;
|
||||||
final String Function(ChatWorkspacePane)? paneTitle;
|
final String Function(ChatWorkspacePane)? paneTitle;
|
||||||
|
final ValueChanged<Set<String>>? onVisibleSessionIdsChanged;
|
||||||
|
|
||||||
/// Keyboard navigation only: the owner can focus the target composer.
|
/// Keyboard navigation only: the owner can focus the target composer.
|
||||||
/// Pointer activation leaves text-selection and pointer focus alone.
|
/// Pointer activation leaves text-selection and pointer focus alone.
|
||||||
@@ -54,6 +55,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
late final ChatPaneSwitchMotion _motion;
|
late final ChatPaneSwitchMotion _motion;
|
||||||
ChatWorkspaceGeometry? _geometry;
|
ChatWorkspaceGeometry? _geometry;
|
||||||
String? _lastActiveId;
|
String? _lastActiveId;
|
||||||
|
Set<String> _visibleSessionIds = const {};
|
||||||
String? _peekId;
|
String? _peekId;
|
||||||
late final ChatPaneBackdrop _backdrop;
|
late final ChatPaneBackdrop _backdrop;
|
||||||
void _backdropChanged() {
|
void _backdropChanged() {
|
||||||
@@ -64,11 +66,31 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_motion = ChatPaneSwitchMotion(vsync: this);
|
_motion = ChatPaneSwitchMotion(vsync: this);
|
||||||
|
_motion.animation.addStatusListener(_motionSettled);
|
||||||
_backdrop = ChatPaneBackdrop(_motion.animation)
|
_backdrop = ChatPaneBackdrop(_motion.animation)
|
||||||
..addListener(_backdropChanged);
|
..addListener(_backdropChanged);
|
||||||
HardwareKeyboard.instance.addHandler(_key);
|
HardwareKeyboard.instance.addHandler(_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _reportVisible(Set<String> ids) {
|
||||||
|
if (setEquals(ids, _visibleSessionIds)) return;
|
||||||
|
_visibleSessionIds = Set.unmodifiable(ids);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted && setEquals(ids, _visibleSessionIds)) {
|
||||||
|
widget.onVisibleSessionIdsChanged?.call(_visibleSessionIds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _motionSettled(AnimationStatus status) {
|
||||||
|
if (status != AnimationStatus.completed) return;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted && widget.controller.activePaneId != _lastActiveId) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool _key(KeyEvent event) {
|
bool _key(KeyEvent event) {
|
||||||
if (!widget.shortcutsEnabled ||
|
if (!widget.shortcutsEnabled ||
|
||||||
widget.controller.paneCount <= 1 ||
|
widget.controller.paneCount <= 1 ||
|
||||||
@@ -116,6 +138,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
HardwareKeyboard.instance.removeHandler(_key);
|
HardwareKeyboard.instance.removeHandler(_key);
|
||||||
_backdrop.dispose();
|
_backdrop.dispose();
|
||||||
|
_motion.animation.removeStatusListener(_motionSettled);
|
||||||
_motion.dispose();
|
_motion.dispose();
|
||||||
_focus.dispose();
|
_focus.dispose();
|
||||||
for (final node in _panes.values) {
|
for (final node in _panes.values) {
|
||||||
@@ -132,12 +155,21 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
builder: (context, _) => LayoutBuilder(
|
builder: (context, _) => LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final root = widget.controller.root;
|
final root = widget.controller.root;
|
||||||
if (root == null) return const SizedBox.shrink();
|
if (root == null) {
|
||||||
|
_reportVisible({});
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
final geometry = ChatWorkspaceGeometry(root, constraints.biggest);
|
final geometry = ChatWorkspaceGeometry(root, constraints.biggest);
|
||||||
_geometry = geometry;
|
_geometry = geometry;
|
||||||
final collapsed = widget.singlePane || geometry.collapsed;
|
final collapsed = widget.singlePane || geometry.collapsed;
|
||||||
final panes = widget.controller.panes;
|
final panes = widget.controller.panes;
|
||||||
final activeId = widget.controller.activePaneId;
|
// Finish one joined loop before taking the latest requested role.
|
||||||
|
// Repeated taps/chords never tear the tape or duplicate a live chat.
|
||||||
|
final activeId =
|
||||||
|
_motion.isAnimating &&
|
||||||
|
panes.any((pane) => pane.id == _lastActiveId)
|
||||||
|
? _lastActiveId
|
||||||
|
: widget.controller.activePaneId;
|
||||||
final switching = _lastActiveId != activeId;
|
final switching = _lastActiveId != activeId;
|
||||||
if (switching) {
|
if (switching) {
|
||||||
_peekId = _lastActiveId;
|
_peekId = _lastActiveId;
|
||||||
@@ -149,12 +181,14 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
activeId: activeId,
|
activeId: activeId,
|
||||||
peekId: _peekId,
|
peekId: _peekId,
|
||||||
size: constraints.biggest,
|
size: constraints.biggest,
|
||||||
|
peekFraction: widget.controller.mobilePeekFraction,
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
if (mobile != null &&
|
var animate = !MediaQuery.disableAnimationsOf(context);
|
||||||
switching &&
|
if (mobile != null && switching && animate) {
|
||||||
!MediaQuery.disableAnimationsOf(context)) {
|
// The top exit requires a fresh picture. If painting is not ready,
|
||||||
_backdrop.capture(context);
|
// settle safely instead of moving the only live tree offscreen.
|
||||||
|
animate = _backdrop.capture(context);
|
||||||
}
|
}
|
||||||
if (mobile == null) {
|
if (mobile == null) {
|
||||||
_motion.rest();
|
_motion.rest();
|
||||||
@@ -164,59 +198,33 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
size: constraints.biggest,
|
size: constraints.biggest,
|
||||||
activeId: activeId!,
|
activeId: activeId!,
|
||||||
switching: switching,
|
switching: switching,
|
||||||
animate: !MediaQuery.disableAnimationsOf(context),
|
animate: animate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
_reportVisible({
|
||||||
|
for (final pane in panes)
|
||||||
|
if (mobile != null
|
||||||
|
? mobile.rects.containsKey(pane.id)
|
||||||
|
: !collapsed || pane.id == activeId)
|
||||||
|
pane.sessionId,
|
||||||
|
});
|
||||||
final existing = panes.map((p) => p.id).toSet();
|
final existing = panes.map((p) => p.id).toSet();
|
||||||
for (final id
|
for (final id
|
||||||
in _panes.keys.where((id) => !existing.contains(id)).toList()) {
|
in _panes.keys.where((id) => !existing.contains(id)).toList()) {
|
||||||
final node = _panes.remove(id)!;
|
final node = _panes.remove(id)!;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => node.dispose());
|
WidgetsBinding.instance.addPostFrameCallback((_) => node.dispose());
|
||||||
}
|
}
|
||||||
final ordered = mobile?.paintOrder(panes) ?? panes;
|
return chatWorkspaceSurface(
|
||||||
return ChatPanePicture(
|
context: context,
|
||||||
key: _backdrop.pictureKey,
|
backdrop: _backdrop,
|
||||||
child: Stack(
|
motion: _motion,
|
||||||
fit: StackFit.expand,
|
controller: widget.controller,
|
||||||
clipBehavior: Clip.hardEdge,
|
geometry: geometry,
|
||||||
children: [
|
mobile: mobile,
|
||||||
if (_backdrop.image != null)
|
collapsed: collapsed,
|
||||||
IgnorePointer(
|
size: constraints.biggest,
|
||||||
child: RawImage(image: _backdrop.image, fit: BoxFit.fill),
|
panes: panes,
|
||||||
),
|
paneView: (pane) => _paneView(pane, mobile, collapsed, activeId),
|
||||||
for (final pane in ordered)
|
|
||||||
// A switch moves the retained pane view; the view itself is
|
|
||||||
// built once per layout; ticks resize its real scroll viewport.
|
|
||||||
AnimatedBuilder(
|
|
||||||
key: ValueKey('chat-workspace-${pane.id}'),
|
|
||||||
animation: _motion.animation,
|
|
||||||
child: _paneView(pane, mobile, collapsed, activeId),
|
|
||||||
builder: (context, child) => Positioned.fromRect(
|
|
||||||
rect:
|
|
||||||
_motion.rectFor(pane.id) ??
|
|
||||||
(collapsed
|
|
||||||
? Offset.zero & constraints.biggest
|
|
||||||
: geometry.panes[pane.id]!),
|
|
||||||
child: ChatPaneSwapCard(
|
|
||||||
enabled: mobile != null,
|
|
||||||
lift: _motion.liftFor(pane.id),
|
|
||||||
child: child!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!collapsed && mobile == null)
|
|
||||||
for (final divider in geometry.dividers)
|
|
||||||
Positioned.fromRect(
|
|
||||||
key: ValueKey('chat-workspace-${divider.split.id}'),
|
|
||||||
rect: divider.rect,
|
|
||||||
child: ChatWorkspaceDivider(
|
|
||||||
geometry: divider,
|
|
||||||
onChanged: (ratio) =>
|
|
||||||
widget.controller.resize(divider.split.id, ratio),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ export 'chat_workspace_nodes.dart';
|
|||||||
class ChatWorkspaceController extends ChangeNotifier {
|
class ChatWorkspaceController extends ChangeNotifier {
|
||||||
ChatWorkspaceNode? _root;
|
ChatWorkspaceNode? _root;
|
||||||
String? _active;
|
String? _active;
|
||||||
|
double _mobilePeekFraction = .2;
|
||||||
|
double get mobilePeekFraction => _mobilePeekFraction;
|
||||||
|
void resizeMobilePeek(double fraction) {
|
||||||
|
if (!fraction.isFinite) return;
|
||||||
|
final next = fraction.clamp(.02, .2);
|
||||||
|
if (next == _mobilePeekFraction) return;
|
||||||
|
_mobilePeekFraction = next;
|
||||||
|
_changed();
|
||||||
|
}
|
||||||
|
|
||||||
int _serial = 0;
|
int _serial = 0;
|
||||||
int _revision = 0;
|
int _revision = 0;
|
||||||
int get revision => _revision;
|
int get revision => _revision;
|
||||||
@@ -51,6 +61,7 @@ class ChatWorkspaceController extends ChangeNotifier {
|
|||||||
if (expectedRevision != null && expectedRevision != _revision) return false;
|
if (expectedRevision != null && expectedRevision != _revision) return false;
|
||||||
_root = snapshot.root;
|
_root = snapshot.root;
|
||||||
_active = snapshot.activePaneId;
|
_active = snapshot.activePaneId;
|
||||||
|
_mobilePeekFraction = snapshot.mobilePeekFraction;
|
||||||
_serial = 0;
|
_serial = 0;
|
||||||
_changed();
|
_changed();
|
||||||
return true;
|
return true;
|
||||||
@@ -61,6 +72,7 @@ class ChatWorkspaceController extends ChangeNotifier {
|
|||||||
_root,
|
_root,
|
||||||
_active,
|
_active,
|
||||||
sidebarMode: sidebarMode,
|
sidebarMode: sidebarMode,
|
||||||
|
mobilePeekFraction: _mobilePeekFraction,
|
||||||
);
|
);
|
||||||
|
|
||||||
void _changed() {
|
void _changed() {
|
||||||
|
|||||||
@@ -10,27 +10,42 @@ const chatWorkspaceSidebarModes = {'expanded', 'compact', 'hidden'};
|
|||||||
/// Validated local presentation state. It contains identities and geometry only,
|
/// Validated local presentation state. It contains identities and geometry only,
|
||||||
/// never credentials, messages, drafts, or commands to create/reopen a session.
|
/// never credentials, messages, drafts, or commands to create/reopen a session.
|
||||||
class ChatWorkspaceSnapshot {
|
class ChatWorkspaceSnapshot {
|
||||||
const ChatWorkspaceSnapshot._(this.root, this.activePaneId, this.sidebarMode);
|
const ChatWorkspaceSnapshot._(
|
||||||
|
this.root,
|
||||||
|
this.activePaneId,
|
||||||
|
this.sidebarMode,
|
||||||
|
this.mobilePeekFraction,
|
||||||
|
);
|
||||||
|
|
||||||
final ChatWorkspaceNode? root;
|
final ChatWorkspaceNode? root;
|
||||||
final String? activePaneId;
|
final String? activePaneId;
|
||||||
final String sidebarMode;
|
final String sidebarMode;
|
||||||
|
final double mobilePeekFraction;
|
||||||
|
|
||||||
static ChatWorkspaceSnapshot? fromLayout(
|
static ChatWorkspaceSnapshot? fromLayout(
|
||||||
ChatWorkspaceNode? root,
|
ChatWorkspaceNode? root,
|
||||||
String? activePaneId, {
|
String? activePaneId, {
|
||||||
String sidebarMode = 'expanded',
|
String sidebarMode = 'expanded',
|
||||||
|
double mobilePeekFraction = .2,
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
final codec = _NodeCodec();
|
final codec = _NodeCodec();
|
||||||
if (root != null) codec.write(root, 1);
|
if (root != null) codec.write(root, 1);
|
||||||
if (!chatWorkspaceSidebarModes.contains(sidebarMode) ||
|
if (!mobilePeekFraction.isFinite ||
|
||||||
|
mobilePeekFraction < .02 ||
|
||||||
|
mobilePeekFraction > .2 ||
|
||||||
|
!chatWorkspaceSidebarModes.contains(sidebarMode) ||
|
||||||
(root == null
|
(root == null
|
||||||
? activePaneId != null
|
? activePaneId != null
|
||||||
: !codec.paneIds.contains(activePaneId))) {
|
: !codec.paneIds.contains(activePaneId))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final snapshot = ChatWorkspaceSnapshot._(root, activePaneId, sidebarMode);
|
final snapshot = ChatWorkspaceSnapshot._(
|
||||||
|
root,
|
||||||
|
activePaneId,
|
||||||
|
sidebarMode,
|
||||||
|
mobilePeekFraction,
|
||||||
|
);
|
||||||
return snapshot.encode().length <= chatWorkspaceSnapshotMaxLength
|
return snapshot.encode().length <= chatWorkspaceSnapshotMaxLength
|
||||||
? snapshot
|
? snapshot
|
||||||
: null;
|
: null;
|
||||||
@@ -44,6 +59,7 @@ class ChatWorkspaceSnapshot {
|
|||||||
'root': root == null ? null : _NodeCodec().write(root!, 1),
|
'root': root == null ? null : _NodeCodec().write(root!, 1),
|
||||||
'active_pane': activePaneId,
|
'active_pane': activePaneId,
|
||||||
'sidebar_mode': sidebarMode,
|
'sidebar_mode': sidebarMode,
|
||||||
|
'mobile_peek_fraction': mobilePeekFraction,
|
||||||
});
|
});
|
||||||
|
|
||||||
static ChatWorkspaceSnapshot? decode(String source) {
|
static ChatWorkspaceSnapshot? decode(String source) {
|
||||||
@@ -60,10 +76,17 @@ class ChatWorkspaceSnapshot {
|
|||||||
final root = data['root'] == null ? null : codec.read(data['root'], 1);
|
final root = data['root'] == null ? null : codec.read(data['root'], 1);
|
||||||
final active = data['active_pane'];
|
final active = data['active_pane'];
|
||||||
final sidebar = data['sidebar_mode'] ?? 'expanded';
|
final sidebar = data['sidebar_mode'] ?? 'expanded';
|
||||||
|
final peek = data['mobile_peek_fraction'] ?? .2;
|
||||||
|
if (peek is! num) return null;
|
||||||
if (active != null && active is! String || sidebar is! String) {
|
if (active != null && active is! String || sidebar is! String) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return fromLayout(root, active as String?, sidebarMode: sidebar);
|
return fromLayout(
|
||||||
|
root,
|
||||||
|
active as String?,
|
||||||
|
sidebarMode: sidebar,
|
||||||
|
mobilePeekFraction: peek.toDouble(),
|
||||||
|
);
|
||||||
} on Object {
|
} on Object {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'chat_mobile_panes.dart';
|
||||||
|
import 'chat_mobile_peek_divider.dart';
|
||||||
|
import 'chat_pane_backdrop.dart';
|
||||||
|
import 'chat_pane_switch_motion.dart';
|
||||||
|
import 'chat_tape_exit.dart';
|
||||||
|
import 'chat_workspace_controller.dart';
|
||||||
|
import 'chat_workspace_divider.dart';
|
||||||
|
import 'chat_workspace_geometry.dart';
|
||||||
|
|
||||||
|
/// Rendering only: retained live panes stay stable siblings, while the outgoing
|
||||||
|
/// picture and mobile drag target sit alongside them in the same clipped stack.
|
||||||
|
Widget chatWorkspaceSurface({
|
||||||
|
required BuildContext context,
|
||||||
|
required ChatPaneBackdrop backdrop,
|
||||||
|
required ChatPaneSwitchMotion motion,
|
||||||
|
required ChatWorkspaceController controller,
|
||||||
|
required ChatWorkspaceGeometry geometry,
|
||||||
|
required ChatMobilePanes? mobile,
|
||||||
|
required bool collapsed,
|
||||||
|
required Size size,
|
||||||
|
required List<ChatWorkspacePane> panes,
|
||||||
|
required Widget Function(ChatWorkspacePane) paneView,
|
||||||
|
}) {
|
||||||
|
final ordered = mobile?.paintOrder(panes) ?? panes;
|
||||||
|
return ChatPanePicture(
|
||||||
|
key: backdrop.pictureKey,
|
||||||
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
children: [
|
||||||
|
if (mobile != null)
|
||||||
|
ColoredBox(color: Theme.of(context).colorScheme.surface),
|
||||||
|
if (backdrop.image != null && mobile != null)
|
||||||
|
AnimatedBuilder(
|
||||||
|
animation: motion.animation,
|
||||||
|
builder: (context, _) {
|
||||||
|
final rect = motion.exitingRect;
|
||||||
|
final source = motion.outgoingSourceRect;
|
||||||
|
if (rect == null || source == null) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
return Positioned.fromRect(
|
||||||
|
key: const ValueKey('chat-tape-exit'),
|
||||||
|
rect: rect,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: ChatTapeExit(
|
||||||
|
image: backdrop.image!,
|
||||||
|
source: source,
|
||||||
|
workspace: size,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
for (final pane in ordered)
|
||||||
|
// A switch moves the retained pane view; the view itself is
|
||||||
|
// built once per layout; ticks resize its real scroll viewport.
|
||||||
|
AnimatedBuilder(
|
||||||
|
key: ValueKey('chat-workspace-${pane.id}'),
|
||||||
|
animation: motion.animation,
|
||||||
|
child: paneView(pane),
|
||||||
|
builder: (context, child) => Positioned.fromRect(
|
||||||
|
rect:
|
||||||
|
motion.rectFor(pane.id) ??
|
||||||
|
(collapsed ? Offset.zero & size : geometry.panes[pane.id]!),
|
||||||
|
child: child!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (mobile?.peekId != null && !motion.isAnimating)
|
||||||
|
Positioned(
|
||||||
|
top: mobile!.contentHeight - 12,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: 24,
|
||||||
|
child: ChatMobilePeekDivider(
|
||||||
|
height: mobile.rects[mobile.peekId]!.height,
|
||||||
|
available: size.height - 6,
|
||||||
|
onChanged: controller.resizeMobilePeek,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!collapsed && mobile == null)
|
||||||
|
for (final divider in geometry.dividers)
|
||||||
|
Positioned.fromRect(
|
||||||
|
key: ValueKey('chat-workspace-${divider.split.id}'),
|
||||||
|
rect: divider.rect,
|
||||||
|
child: ChatWorkspaceDivider(
|
||||||
|
geometry: divider,
|
||||||
|
onChanged: (ratio) =>
|
||||||
|
controller.resize(divider.split.id, ratio),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Mobile tape switch and remembered peek height
|
||||||
|
|
||||||
|
Both chats move upward as one joined tape. The old active exits above the
|
||||||
|
incoming live pane as a bounded snapshot; its single retained live tree loops
|
||||||
|
in from below with a real small scroll viewport. This avoids duplicating live
|
||||||
|
chat state. The default is 560 ms, globally scaled by the animation setting.
|
||||||
|
Repeated activations queue the latest role until the current loop finishes.
|
||||||
|
Reduced motion, first layout, or an unavailable fresh picture settle directly.
|
||||||
|
The crossing-card rounded/shadow effect and its source file are removed.
|
||||||
|
|
||||||
|
Small layouts keep only the active chat's coloured bottom border. A 24 px touch
|
||||||
|
and mouse target centred on that border adjusts the inactive height. The range
|
||||||
|
is 48 logical pixels through the previous 20% maximum (the minimum yields to
|
||||||
|
20% on extremely short viewports). The saved fraction remains per-server in the
|
||||||
|
existing workspace preference; old snapshots default to 20%, and keyboard or
|
||||||
|
orientation changes constrain presentation without rewriting the preference.
|
||||||
|
|
||||||
|
The workspace exposes a deduplicated post-frame visible-session callback based
|
||||||
|
on the actual mobile pair, collapsed active pane, or desktop split leaves.
|
||||||
|
Retained offstage chats are excluded. Root integration wires this into sidebar
|
||||||
|
visibility indicators.
|
||||||
|
|
||||||
|
Checks:
|
||||||
|
- `tool/memwatch/full.sh test/features/chat`: 962 passed, zero failed/skipped,
|
||||||
|
peak 1989 MB, 63 seconds. `/tmp/memwatch/out.Pi7Bqo`.
|
||||||
|
- `tool/analyze.sh`: clean. `/tmp/flutter-analyze` output path is recorded in
|
||||||
|
agent tool logs (final run `flutter-analyze.zX3NNQ`).
|
||||||
|
- Fixture web build succeeded. Actual browser actions/captures inspected:
|
||||||
|
`/tmp/review/mobile-tape-material/02-film-label-Expand-Fixture-chat-1-sheet.png`,
|
||||||
|
`/tmp/review/mobile-tape-material/04-small.png` and return film.
|
||||||
|
The 140px separator drag changed peek198.8 to58.8; reported viewport equals
|
||||||
|
visible height58.8 and scroll pixels=max688.6. Chrome/private fixture server
|
||||||
|
are cleaned by the capture kit on completion.
|
||||||
|
- Tests cover joined tape edges and top exit/bottom wrap, queued reversal,
|
||||||
|
retained drafts, min/max drag, snapshot cold restore/legacy validation,
|
||||||
|
bottom-only phone borders, reduced motion and real small viewport scroll end.
|
||||||
|
|
||||||
|
These captures are browser evidence, not native Android device verification.
|
||||||
@@ -78,7 +78,7 @@ void _expectComposerBottom(WidgetTester tester, double expected) {
|
|||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _border(WidgetTester tester, String id) {
|
Border _paneBorder(WidgetTester tester, String id) {
|
||||||
final box = tester.widget<DecoratedBox>(
|
final box = tester.widget<DecoratedBox>(
|
||||||
find
|
find
|
||||||
.ancestor(
|
.ancestor(
|
||||||
@@ -93,9 +93,12 @@ Color _border(WidgetTester tester, String id) {
|
|||||||
)
|
)
|
||||||
.first,
|
.first,
|
||||||
);
|
);
|
||||||
return ((box.decoration as BoxDecoration).border! as Border).top.color;
|
return (box.decoration as BoxDecoration).border! as Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color _border(WidgetTester tester, String id) =>
|
||||||
|
_paneBorder(tester, id).top.color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Android pushed chat clears gesture bar once and keyboard correctly',
|
'Android pushed chat clears gesture bar once and keyboard correctly',
|
||||||
@@ -152,4 +155,33 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
});
|
});
|
||||||
|
testWidgets('mobile pair keeps only its coloured draggable bottom boundary', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await _mount(tester, const Size(1800, 1000));
|
||||||
|
final controller = tester
|
||||||
|
.widget<ChatWorkspace>(find.byType(ChatWorkspace))
|
||||||
|
.controller;
|
||||||
|
controller.splitActive('b', ChatSplitAxis.horizontal);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
tester.view.physicalSize = const Size(390, 844);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final border = _paneBorder(tester, 'b');
|
||||||
|
expect(border.left.style, BorderStyle.none);
|
||||||
|
expect(border.right.style, BorderStyle.none);
|
||||||
|
expect(border.top.style, BorderStyle.none);
|
||||||
|
expect(
|
||||||
|
border.bottom.color,
|
||||||
|
chatColorShade(tester.element(_thread('b')), 'teal'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
find.byWidgetPredicate(
|
||||||
|
(widget) =>
|
||||||
|
widget is Semantics &&
|
||||||
|
widget.properties.label == 'Resize inactive chat',
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_pane_presentation.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_pane_presentation.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/workspace/chat_pane_backdrop.dart';
|
||||||
import 'package:pipelines_app/features/chat/workspace/chat_pane_switch_motion.dart';
|
import 'package:pipelines_app/features/chat/workspace/chat_pane_switch_motion.dart';
|
||||||
import 'package:pipelines_app/features/chat/workspace/chat_pane_swap_card.dart';
|
import 'package:pipelines_app/features/chat/workspace/chat_mobile_peek_divider.dart';
|
||||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ Widget _host(
|
|||||||
bool mobile = true,
|
bool mobile = true,
|
||||||
bool reduced = false,
|
bool reduced = false,
|
||||||
ChatWorkspacePaneBuilder? paneBuilder,
|
ChatWorkspacePaneBuilder? paneBuilder,
|
||||||
|
ValueChanged<Set<String>>? onVisible,
|
||||||
}) => MaterialApp(
|
}) => MaterialApp(
|
||||||
home: MediaQuery(
|
home: MediaQuery(
|
||||||
data: MediaQueryData(disableAnimations: reduced),
|
data: MediaQueryData(disableAnimations: reduced),
|
||||||
@@ -22,6 +24,7 @@ Widget _host(
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
singlePane: mobile,
|
singlePane: mobile,
|
||||||
mobilePeeks: mobile,
|
mobilePeeks: mobile,
|
||||||
|
onVisibleSessionIdsChanged: onVisible,
|
||||||
paneBuilder:
|
paneBuilder:
|
||||||
paneBuilder ??
|
paneBuilder ??
|
||||||
(_, pane, active) => _Draft(key: ValueKey(pane.sessionId)),
|
(_, pane, active) => _Draft(key: ValueKey(pane.sessionId)),
|
||||||
@@ -134,7 +137,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'crossing cards overlap with incoming on top; interruption retains state',
|
'tape exits above incoming, wraps below, queues reversal and retains drafts',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
phone(tester);
|
phone(tester);
|
||||||
final controller = ChatWorkspaceController()..open('a');
|
final controller = ChatWorkspaceController()..open('a');
|
||||||
@@ -148,67 +151,120 @@ void main() {
|
|||||||
bState.controller.text = 'Retained draft';
|
bState.controller.text = 'Retained draft';
|
||||||
controller.activate(a);
|
controller.activate(a);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(milliseconds: 120));
|
await tester.pump(const Duration(milliseconds: 140));
|
||||||
final t = ChatPaneSwitchMotion.curve.transform(.25);
|
final t = ChatPaneSwitchMotion.curve.transform(.25);
|
||||||
expect(tester.getRect(rect(a)).top, closeTo(_peekTop * (1 - t), .5));
|
|
||||||
expect(tester.getRect(rect(b)).top, closeTo(_peekTop * t, .5));
|
|
||||||
expect(
|
|
||||||
tester.getSize(find.byKey(const ValueKey('a'))).height,
|
|
||||||
closeTo(tester.getRect(rect(a)).height, .5),
|
|
||||||
);
|
|
||||||
final incoming = tester.getRect(rect(a));
|
final incoming = tester.getRect(rect(a));
|
||||||
final outgoing = tester.getRect(rect(b));
|
final wrapped = tester.getRect(rect(b));
|
||||||
expect(incoming.overlaps(outgoing), isTrue);
|
final exiting = tester.getRect(
|
||||||
expect(incoming.height + outgoing.height, greaterThan(800));
|
find.byKey(const ValueKey('chat-tape-exit')),
|
||||||
final cards = tester
|
|
||||||
.widgetList<ChatPaneSwapCard>(find.byType(ChatPaneSwapCard))
|
|
||||||
.toList();
|
|
||||||
expect(cards.last.lift, greaterThan(.5));
|
|
||||||
expect(cards.first.lift, 0);
|
|
||||||
final stack = tester.widget<Stack>(
|
|
||||||
find
|
|
||||||
.descendant(
|
|
||||||
of: find.byType(ChatWorkspace),
|
|
||||||
matching: find.byType(Stack),
|
|
||||||
)
|
|
||||||
.first,
|
|
||||||
);
|
);
|
||||||
expect(stack.children.last.key, ValueKey('chat-workspace-$a'));
|
expect(incoming.top, closeTo(_peekTop * (1 - t), .5));
|
||||||
final beforeA = tester.getRect(rect(a));
|
expect(exiting.top, lessThan(0));
|
||||||
final beforeB = tester.getRect(rect(b));
|
expect(exiting.bottom + 6, closeTo(incoming.top, .5));
|
||||||
double reveal(String session) => tester
|
expect(incoming.bottom + 6, closeTo(wrapped.top, .5));
|
||||||
.widget<ChatPanePresentation>(
|
expect(wrapped.top, greaterThan(_peekTop));
|
||||||
find
|
|
||||||
.ancestor(
|
|
||||||
of: find.byKey(ValueKey(session)),
|
|
||||||
matching: find.byType(ChatPanePresentation),
|
|
||||||
)
|
|
||||||
.first,
|
|
||||||
)
|
|
||||||
.barReveal
|
|
||||||
.value;
|
|
||||||
final bar = reveal('a');
|
|
||||||
controller.activate(b);
|
|
||||||
await tester.pump();
|
|
||||||
expect(tester.getRect(rect(a)), beforeA);
|
|
||||||
expect(tester.getRect(rect(b)), beforeB);
|
|
||||||
expect(reveal('a'), closeTo(bar, .001));
|
|
||||||
await tester.pump(const Duration(milliseconds: 90));
|
|
||||||
expect(tester.getRect(rect(a)).top, greaterThan(beforeA.top));
|
|
||||||
expect(reveal('a'), lessThan(bar));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(tester.getRect(rect(a)).top, _peekTop);
|
|
||||||
expect(
|
expect(
|
||||||
tester.getSize(find.byKey(const ValueKey('a'))).height,
|
tester.getSize(find.byKey(const ValueKey('b'))).height,
|
||||||
closeTo((800 - 6) * .2, .5),
|
closeTo((800 - 6) * .2, .5),
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
tester.getSize(find.byKey(const ValueKey('a'))).height,
|
||||||
|
closeTo(incoming.height, .5),
|
||||||
|
);
|
||||||
|
controller.activate(b);
|
||||||
|
await tester.pump();
|
||||||
|
expect(tester.getRect(rect(a)), incoming);
|
||||||
|
expect(tester.getRect(rect(b)), wrapped);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.getRect(rect(a)).top, _peekTop);
|
||||||
|
expect(tester.getRect(rect(b)).top, 0);
|
||||||
expect(tester.state(find.byKey(const ValueKey('a'))), same(aState));
|
expect(tester.state(find.byKey(const ValueKey('a'))), same(aState));
|
||||||
expect(tester.state(find.byKey(const ValueKey('b'))), same(bState));
|
expect(tester.state(find.byKey(const ValueKey('b'))), same(bState));
|
||||||
expect(bState.controller.text, 'Retained draft');
|
expect(bState.controller.text, 'Retained draft');
|
||||||
|
expect(find.byKey(const ValueKey('chat-tape-exit')), findsNothing);
|
||||||
await tester.pumpWidget(const SizedBox());
|
await tester.pumpWidget(const SizedBox());
|
||||||
controller.dispose();
|
controller.dispose();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'bottom separator shrinks peek, clamps both ends and retains size',
|
||||||
|
(tester) async {
|
||||||
|
phone(tester);
|
||||||
|
final controller = ChatWorkspaceController()..open('a');
|
||||||
|
final a = controller.activePaneId!;
|
||||||
|
controller.splitActive('b', ChatSplitAxis.horizontal);
|
||||||
|
await tester.pumpWidget(_host(controller));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.drag(
|
||||||
|
find.byType(ChatMobilePeekDivider),
|
||||||
|
const Offset(0, 220),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.getRect(rect(a)).height, closeTo(48, .5));
|
||||||
|
final saved = controller.snapshot()!;
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
final restored = ChatWorkspaceController()..restoreLayout(saved);
|
||||||
|
await tester.pumpWidget(_host(restored));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.getRect(rect(a)).height, closeTo(48, .5));
|
||||||
|
await tester.drag(
|
||||||
|
find.byType(ChatMobilePeekDivider),
|
||||||
|
const Offset(0, -500),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.getRect(rect(a)).height, closeTo((800 - 6) * .2, .5));
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
controller.dispose();
|
||||||
|
restored.dispose();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
testWidgets('unpainted snapshot cannot start a tape exit', (tester) async {
|
||||||
|
final motion = AnimationController(vsync: tester);
|
||||||
|
final picture = ChatPaneBackdrop(motion);
|
||||||
|
late BuildContext context;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Builder(
|
||||||
|
builder: (value) {
|
||||||
|
context = value;
|
||||||
|
return const SizedBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(picture.capture(context), isFalse);
|
||||||
|
expect(picture.image, isNull);
|
||||||
|
picture.dispose();
|
||||||
|
motion.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'visibility reports only the mobile pair, not retained third pane',
|
||||||
|
(tester) async {
|
||||||
|
phone(tester);
|
||||||
|
final controller = ChatWorkspaceController()..open('a');
|
||||||
|
controller.splitActive('b', ChatSplitAxis.horizontal);
|
||||||
|
controller.splitActive('c', ChatSplitAxis.horizontal);
|
||||||
|
final seen = <Set<String>>[];
|
||||||
|
await tester.pumpWidget(_host(controller, onVisible: seen.add));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(seen.last, {'a', 'c'});
|
||||||
|
controller.activate(
|
||||||
|
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(seen.last, {'b', 'c'});
|
||||||
|
for (final pane in controller.panes.toList()) {
|
||||||
|
controller.close(pane.id);
|
||||||
|
}
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(seen.last, isEmpty);
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
controller.dispose();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
testWidgets('reduced motion settles immediately', (tester) async {
|
testWidgets('reduced motion settles immediately', (tester) async {
|
||||||
phone(tester);
|
phone(tester);
|
||||||
final controller = ChatWorkspaceController()..open('a');
|
final controller = ChatWorkspaceController()..open('a');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ ChatWorkspaceController _layout() {
|
|||||||
(controller.root as ChatWorkspaceSplit).second as ChatWorkspaceSplit;
|
(controller.root as ChatWorkspaceSplit).second as ChatWorkspaceSplit;
|
||||||
controller.resize(vertical.id, .64);
|
controller.resize(vertical.id, .64);
|
||||||
controller.activate(controller.panes.first.id);
|
controller.activate(controller.panes.first.id);
|
||||||
|
controller.resizeMobilePeek(.085);
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +78,8 @@ void main() {
|
|||||||
expect((root.second as ChatWorkspaceSplit).axis, ChatSplitAxis.vertical);
|
expect((root.second as ChatWorkspaceSplit).axis, ChatSplitAxis.vertical);
|
||||||
expect((root.second as ChatWorkspaceSplit).ratio, .64);
|
expect((root.second as ChatWorkspaceSplit).ratio, .64);
|
||||||
expect(restored.sidebarMode, 'hidden');
|
expect(restored.sidebarMode, 'hidden');
|
||||||
|
expect(restored.mobilePeekFraction, .085);
|
||||||
|
expect(fresh.mobilePeekFraction, .085);
|
||||||
fresh.splitActive('session-d', ChatSplitAxis.vertical);
|
fresh.splitActive('session-d', ChatSplitAxis.vertical);
|
||||||
final ids = <String>[];
|
final ids = <String>[];
|
||||||
void collect(ChatWorkspaceNode node) {
|
void collect(ChatWorkspaceNode node) {
|
||||||
@@ -210,6 +213,22 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'legacy snapshots retain the original peek and invalid peek fractions reject',
|
||||||
|
() {
|
||||||
|
final legacy = _json(_pane('a', 'session-a'));
|
||||||
|
expect(ChatWorkspaceSnapshot.decode(legacy)!.mobilePeekFraction, .2);
|
||||||
|
for (final value in [0, -.1, .21, 'large', null]) {
|
||||||
|
final data = jsonDecode(legacy) as Map<String, dynamic>;
|
||||||
|
data['mobile_peek_fraction'] = value;
|
||||||
|
// Explicit null keeps backwards-compatible default semantics.
|
||||||
|
if (value != null) {
|
||||||
|
expect(ChatWorkspaceSnapshot.decode(jsonEncode(data)), isNull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'unknown ordinary fields are forward compatible but nesting and size are bounded',
|
'unknown ordinary fields are forward compatible but nesting and size are bounded',
|
||||||
() {
|
() {
|
||||||
|
|||||||
Reference in New Issue
Block a user