Keep enlarged chat header controls reachable in short viewports
This commit is contained in:
@@ -107,24 +107,27 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
bar,
|
||||
if (narrow && controls.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
fill: true,
|
||||
vertical: constraints.maxWidth < 340,
|
||||
children: controls,
|
||||
child: SingleChildScrollView(
|
||||
primary: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
bar,
|
||||
if (narrow && controls.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
fill: true,
|
||||
vertical: constraints.maxWidth < 340,
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -38,6 +38,47 @@ void _useNarrowText(WidgetTester tester) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('short large-text header scrolls controls without overflow', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: 100,
|
||||
child: ChatThreadHeader(
|
||||
title: _title,
|
||||
folder: 'demo',
|
||||
onInfo: () {},
|
||||
showBack: true,
|
||||
onBack: () {},
|
||||
controls: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Current model'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Ask for permission'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.ensureVisible(find.text('Ask for permission'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Ask for permission').hitTestable(), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user