Measure retained peek chrome without constraining its hidden contents
This commit is contained in:
@@ -47,29 +47,38 @@ class ChatPaneBarReveal extends StatelessWidget {
|
||||
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: SizeTransition(
|
||||
alignment: Alignment.topCenter,
|
||||
sizeFactor: reveal,
|
||||
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),
|
||||
// Overlay slots cap chrome at the pane height. A resting peek can be
|
||||
// shorter than its retained composer (large text + keyboard). Give only
|
||||
// chrome its natural height before SizeTransition consumes that height;
|
||||
// the transcript itself always keeps the real pane constraints.
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: reveal,
|
||||
child: IgnorePointer(
|
||||
ignoring: peek,
|
||||
child: SizeTransition(
|
||||
alignment: Alignment.topCenter,
|
||||
sizeFactor: reveal,
|
||||
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),
|
||||
),
|
||||
),
|
||||
builder: (context, child) =>
|
||||
Offstage(offstage: peek && reveal.value <= 0, child: child),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ Future<void> _pump(
|
||||
WidgetTester tester, {
|
||||
required bool peek,
|
||||
required double reveal,
|
||||
double? height,
|
||||
}) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
@@ -31,14 +32,17 @@ Future<void> _pump(
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatPanePresentation(
|
||||
peek: peek,
|
||||
barReveal: AlwaysStoppedAnimation(reveal),
|
||||
child: ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
title: 'Presented',
|
||||
onBack: () {},
|
||||
body: SizedBox(
|
||||
height: height,
|
||||
child: ChatPanePresentation(
|
||||
peek: peek,
|
||||
barReveal: AlwaysStoppedAnimation(reveal),
|
||||
child: ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
title: 'Presented',
|
||||
onBack: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -105,6 +109,24 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'a retained peek composer measures naturally in a tiny viewport',
|
||||
(tester) async {
|
||||
await _pump(tester, peek: true, reveal: 0, height: 60);
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is EditableText && !widget.readOnly,
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('chat-composer-s'), skipOffstage: false),
|
||||
findsOneWidget,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('without a presentation the bar is itself', (tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
|
||||
Reference in New Issue
Block a user