Smooth mobile chat swaps and measure the actual peek viewport
This commit is contained in:
@@ -157,3 +157,10 @@ The tree has an assets subfolder, a hidden folder, PNG/JPEG miniatures, text,
|
||||
JSON, CSV, PDF, archive, log and video entries. Image/text/table/archive files
|
||||
have bundled bytes; PDF and video entries demonstrate type labels and menus
|
||||
only. Use the real server for their external handlers and playback acceptance.
|
||||
|
||||
For mobile peek regression captures, `chatPaneScrollMetrics()` returns every
|
||||
retained transcript's `{id,pixels,min,max,viewport,top,height}` as a JSON array.
|
||||
Open a chat, use Add chat pane, then pick the other fixture chat. A wheel/swipe
|
||||
over the inactive pane must change its own offset without activating it;
|
||||
at its bottom `pixels` reaches `max` and its `viewport` equals the small
|
||||
visible height. Use `film=key:chat-peek-<pane-id>` to record the swap.
|
||||
|
||||
@@ -21,6 +21,9 @@ import 'package:pipelines_app/features/chat/ui/transcript/chat_injected_rows.dar
|
||||
@JS('chatScrollMetrics')
|
||||
external set _chatScrollMetrics(JSFunction probe);
|
||||
|
||||
@JS('chatPaneScrollMetrics')
|
||||
external set _chatPaneScrollMetrics(JSFunction probe);
|
||||
|
||||
@JS('chatScrollTargets')
|
||||
external set _chatScrollTargets(JSFunction probe);
|
||||
|
||||
@@ -29,6 +32,7 @@ external set _chatSidewaysOffsets(JSFunction probe);
|
||||
|
||||
void installChatScrollProbe() {
|
||||
_chatScrollMetrics = (() => _metrics()?.toJS).toJS;
|
||||
_chatPaneScrollMetrics = (() => _paneMetrics().toJS).toJS;
|
||||
_chatScrollTargets = (() => _targets().toJS).toJS;
|
||||
_chatSidewaysOffsets = (() => _sideways().toJS).toJS;
|
||||
}
|
||||
@@ -152,3 +156,44 @@ String? _metrics() {
|
||||
'viewport': position.viewportDimension,
|
||||
});
|
||||
}
|
||||
|
||||
/// All retained transcript viewports, so a capture can prove that the inactive
|
||||
/// peek reaches its actual bottom without activating a chat or mutating data.
|
||||
String _paneMetrics() {
|
||||
final panes = <Map<String, Object?>>[];
|
||||
void visit(Element element) {
|
||||
if (element.widget is ChatTranscriptScrollView) {
|
||||
ScrollPosition? position;
|
||||
void inside(Element child) {
|
||||
if (child is StatefulElement && child.state is ScrollableState) {
|
||||
final candidate = (child.state as ScrollableState).position;
|
||||
if (candidate.axis == Axis.vertical) position ??= candidate;
|
||||
}
|
||||
child.visitChildren(inside);
|
||||
}
|
||||
|
||||
element.visitChildren(inside);
|
||||
final scroll = position;
|
||||
final box = element.findRenderObject();
|
||||
if (scroll != null &&
|
||||
scroll.hasContentDimensions &&
|
||||
box is RenderBox &&
|
||||
box.hasSize) {
|
||||
panes.add({
|
||||
'id': (element.widget.key as ValueKey?)?.value.toString(),
|
||||
'pixels': scroll.pixels,
|
||||
'min': scroll.minScrollExtent,
|
||||
'max': scroll.maxScrollExtent,
|
||||
'viewport': scroll.viewportDimension,
|
||||
'top': box.localToGlobal(Offset.zero).dy,
|
||||
'height': box.size.height,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
element.visitChildren(visit);
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.rootElement?.visitChildren(visit);
|
||||
return jsonEncode(panes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user