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 reveal = presentation.barReveal;
|
||||||
final peek = presentation.peek;
|
final peek = presentation.peek;
|
||||||
// One tree in both roles, so the bar's element outlives a switch.
|
// One tree in both roles, so the bar's element outlives a switch.
|
||||||
return AnimatedBuilder(
|
// Overlay slots cap chrome at the pane height. A resting peek can be
|
||||||
animation: reveal,
|
// shorter than its retained composer (large text + keyboard). Give only
|
||||||
child: IgnorePointer(
|
// chrome its natural height before SizeTransition consumes that height;
|
||||||
ignoring: peek,
|
// the transcript itself always keeps the real pane constraints.
|
||||||
child: SizeTransition(
|
return Column(
|
||||||
alignment: Alignment.topCenter,
|
mainAxisSize: MainAxisSize.min,
|
||||||
sizeFactor: reveal,
|
children: [
|
||||||
child: FadeTransition(
|
AnimatedBuilder(
|
||||||
opacity: reveal,
|
animation: reveal,
|
||||||
child: SlideTransition(
|
child: IgnorePointer(
|
||||||
position: Tween<Offset>(
|
ignoring: peek,
|
||||||
begin: const Offset(0, -slide),
|
child: SizeTransition(
|
||||||
end: Offset.zero,
|
alignment: Alignment.topCenter,
|
||||||
).animate(reveal),
|
sizeFactor: reveal,
|
||||||
// The bar's own picture holds while it slides; only its offset
|
child: FadeTransition(
|
||||||
// and alpha change per tick.
|
opacity: reveal,
|
||||||
child: RepaintBoundary(child: bar),
|
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, {
|
WidgetTester tester, {
|
||||||
required bool peek,
|
required bool peek,
|
||||||
required double reveal,
|
required double reveal,
|
||||||
|
double? height,
|
||||||
}) async {
|
}) async {
|
||||||
final gateway = FakeChatGateway();
|
final gateway = FakeChatGateway();
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
@@ -31,14 +32,17 @@ Future<void> _pump(
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: ChatPanePresentation(
|
body: SizedBox(
|
||||||
peek: peek,
|
height: height,
|
||||||
barReveal: AlwaysStoppedAnimation(reveal),
|
child: ChatPanePresentation(
|
||||||
child: ChatThreadView(
|
peek: peek,
|
||||||
gateway: gateway,
|
barReveal: AlwaysStoppedAnimation(reveal),
|
||||||
sessionId: 's',
|
child: ChatThreadView(
|
||||||
title: 'Presented',
|
gateway: gateway,
|
||||||
onBack: () {},
|
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 {
|
testWidgets('without a presentation the bar is itself', (tester) async {
|
||||||
final gateway = FakeChatGateway();
|
final gateway = FakeChatGateway();
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
|
|||||||
Reference in New Issue
Block a user