Phone chat peek: transcript-only peek, tap-or-scroll, animated switch
The inactive (peek) pane no longer shows the chat's bar: ChatPanePresentation tells the conversation its role and ChatPaneBarReveal keeps a resting peek's bar offstage (zero height, not painted), so the peek reads its transcript from the top. A drag on the peek scrolls that transcript; a tap anywhere on it, even over a button or link, activates the chat (ChatPeekTapRecognizer accepts on release ahead of the arena sweep and yields to drags past the slop). The 'chat-peek-<id>' semantics stay a labelled button. Switching animates (260 ms, Cubic(.2,.8,.2,1)): the tapped chat rises over the active one with its bottom edge pinned, then the covered chat slides up into the slot from the bottom edge; each bar fades and slides in or out over the rise. Content boxes keep their fixed size, so ticks move and clip retained pictures without laying a transcript out again. Reduced motion jumps. The old focus stripe is gone.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// How a retained chat presents itself where several share the screen.
|
||||
///
|
||||
/// The active chat shows its bar. A peek (the other chat glimpsed below it on
|
||||
/// a phone) shows transcript only, from its top edge, so the glimpse reads as
|
||||
/// conversation rather than as a second set of controls. [barReveal] runs
|
||||
/// once when the roles swap: 0 is a hidden bar and 1 a shown one, so the
|
||||
/// newly active chat's bar fades and slides in while the peek's fades out.
|
||||
class ChatPanePresentation extends InheritedWidget {
|
||||
const ChatPanePresentation({
|
||||
super.key,
|
||||
required this.peek,
|
||||
required this.barReveal,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
final bool peek;
|
||||
final Animation<double> barReveal;
|
||||
|
||||
static ChatPanePresentation? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ChatPanePresentation>();
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(ChatPanePresentation oldWidget) =>
|
||||
peek != oldWidget.peek || barReveal != oldWidget.barReveal;
|
||||
}
|
||||
|
||||
/// The conversation's bar under a [ChatPanePresentation].
|
||||
///
|
||||
/// Without one the bar is itself. As its chat becomes active the bar fades
|
||||
/// and slides down into place over the transcript, which already keeps clear
|
||||
/// of it. As its chat becomes the peek the bar fades out in place, keeping
|
||||
/// its height until it has gone (by then the arriving chat covers it). A
|
||||
/// resting peek keeps the bar offstage: not painted, taking no height, no
|
||||
/// pointers and no semantics, so its transcript starts at the top, yet still
|
||||
/// mounted, so the next switch fades the same bar rather than building a new
|
||||
/// one (whose pieces would replay their entrances).
|
||||
class ChatPaneBarReveal extends StatelessWidget {
|
||||
const ChatPaneBarReveal({super.key, required this.bar});
|
||||
|
||||
final Widget bar;
|
||||
|
||||
/// How far above its place the bar starts, as a share of its height.
|
||||
static const double slide = .12;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final presentation = ChatPanePresentation.maybeOf(context);
|
||||
if (presentation == null) return bar;
|
||||
final reveal = presentation.barReveal;
|
||||
final peek = presentation.peek;
|
||||
// One tree in both roles, so the bar's element outlives a switch.
|
||||
return AnimatedBuilder(
|
||||
animation: reveal,
|
||||
child: IgnorePointer(
|
||||
ignoring: peek,
|
||||
child: FadeTransition(
|
||||
opacity: reveal,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, -slide),
|
||||
end: Offset.zero,
|
||||
).animate(reveal),
|
||||
// The bar's own picture holds while it slides; only its offset
|
||||
// and alpha change per tick.
|
||||
child: RepaintBoundary(child: bar),
|
||||
),
|
||||
),
|
||||
),
|
||||
builder: (context, child) =>
|
||||
Offstage(offstage: peek && reveal.value <= 0, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../../ui/layout/wheel_scroll_forwarding.dart';
|
||||
import 'chat_reading_width.dart';
|
||||
import 'chat_pane_presentation.dart';
|
||||
import 'chat_thread_header.dart';
|
||||
import 'chat_transcript_anchor.dart';
|
||||
import 'chat_transcript_cache.dart';
|
||||
@@ -967,7 +968,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
final page = FloatingBarOverlay(
|
||||
bar: composerBar,
|
||||
child: SegmentedBarOverlay(
|
||||
bar: _header(context, inShellBar),
|
||||
bar: ChatPaneBarReveal(bar: _header(context, inShellBar)),
|
||||
child: NotificationListener<ScrollMetricsNotification>(
|
||||
onNotification: _onScrollMetrics,
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
|
||||
Reference in New Issue
Block a user