Keep enlarged chat header controls reachable in short viewports
This commit is contained in:
@@ -107,24 +107,27 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
color: cupertino
|
color: cupertino
|
||||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||||
: Theme.of(context).colorScheme.surface,
|
: Theme.of(context).colorScheme.surface,
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
mainAxisSize: MainAxisSize.min,
|
primary: false,
|
||||||
children: [
|
child: Column(
|
||||||
bar,
|
mainAxisSize: MainAxisSize.min,
|
||||||
if (narrow && controls.isNotEmpty)
|
children: [
|
||||||
Padding(
|
bar,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
if (narrow && controls.isNotEmpty)
|
||||||
child: SegmentedPill(
|
Padding(
|
||||||
cupertino: cupertino,
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||||
child: _ControlIsland(
|
child: SegmentedPill(
|
||||||
key: const Key('chat-model-permission-island'),
|
cupertino: cupertino,
|
||||||
fill: true,
|
child: _ControlIsland(
|
||||||
vertical: constraints.maxWidth < 340,
|
key: const Key('chat-model-permission-island'),
|
||||||
children: controls,
|
fill: true,
|
||||||
|
vertical: constraints.maxWidth < 340,
|
||||||
|
children: controls,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,6 +38,47 @@ void _useNarrowText(WidgetTester tester) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
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]) {
|
for (final cupertino in [false, true]) {
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user