Reserve chat list viewport above labeled navigation

This commit is contained in:
2026-11-07 21:10:23 +00:00
parent bbcfcd32a2
commit 0098662b06
7 changed files with 276 additions and 57 deletions
@@ -45,7 +45,11 @@ class ChatCompactSidebar extends StatelessWidget {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
return Semantics(
label: title,
button: true,
selected: selected,
onTap: onPressed,
excludeSemantics: true,
child: cupertino
? Tooltip(
message: title,
@@ -0,0 +1,17 @@
import 'package:flutter/widgets.dart';
/// The shell publishes its measured destination bar as bottom media padding.
/// Reserve that area instead of letting rows paint beneath its opaque captions.
/// SafeArea removes the consumed inset so the list cannot count it twice.
class ChatListViewport extends StatelessWidget {
const ChatListViewport({super.key, required this.builder});
final WidgetBuilder builder;
@override
Widget build(BuildContext context) => SafeArea(
top: false,
left: false,
right: false,
child: ClipRect(child: Builder(builder: builder)),
);
}
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import '../../../../core/api_gateway.dart';
import 'chat_adaptive.dart';
import 'chat_sessions_body.dart';
import 'chat_list_viewport.dart';
import 'session_list_items.dart';
import '../../../../ui/adaptive/floating_bar_layout.dart';
@@ -53,33 +54,40 @@ class CupertinoSessionList extends StatelessWidget {
final ValueChanged<String>? onDismissError;
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverPadding(
// Starts below a floating top bar (its height arrives as media top
// padding) and ends clear of a floating bottom bar.
padding: withFloatingBarClearance(
context,
EdgeInsets.only(top: MediaQuery.paddingOf(context).top, bottom: 24),
),
sliver: SliverMainAxisGroup(
slivers: [
for (final section in sections) _section(section),
if (emptyMessage != null)
SliverToBoxAdapter(
child: ChatCupertinoMessage(
message: emptyMessage!,
actionLabel: onClearSearch == null ? null : 'Clear search',
onAction: onClearSearch,
Widget build(BuildContext context) => ChatListViewport(
builder: (context) {
return CustomScrollView(
slivers: [
SliverPadding(
// Starts below a floating top bar (its height arrives as media top
// padding) and ends clear of a floating bottom bar.
padding: withFloatingBarClearance(
context,
EdgeInsets.only(
top: MediaQuery.paddingOf(context).top,
bottom: 24,
),
),
sliver: SliverMainAxisGroup(
slivers: [
for (final section in sections) _section(section),
if (emptyMessage != null)
SliverToBoxAdapter(
child: ChatCupertinoMessage(
message: emptyMessage!,
actionLabel: onClearSearch == null
? null
: 'Clear search',
onAction: onClearSearch,
),
),
),
],
],
),
),
),
],
);
}
],
);
},
);
Widget _section(ChatSessionSection section) => chatSessionSection(
section: section,
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import 'chat_sessions_body.dart';
import 'chat_list_viewport.dart';
import 'session_list_items.dart';
class MaterialSessionList extends StatelessWidget {
@@ -52,41 +53,42 @@ class MaterialSessionList extends StatelessWidget {
final ValueChanged<String>? onDismissError;
@override
Widget build(BuildContext context) {
// Clears the media padding above and below (a floating top bar's height
// arrives as top padding) and leaves only the side padding to the rows,
// as a ListView does.
final media = MediaQuery.of(context);
return CustomScrollView(
slivers: [
SliverPadding(
padding: media.padding.copyWith(left: 0, right: 0),
sliver: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: 0, bottom: 0),
),
child: SliverMainAxisGroup(
slivers: [
for (final section in sections) _section(context, section),
if (emptyMessage != null)
SliverToBoxAdapter(
child: ListTile(
title: Text(emptyMessage!),
trailing: onClearSearch == null
? null
: TextButton(
onPressed: onClearSearch,
child: const Text('Clear search'),
),
Widget build(BuildContext context) => ChatListViewport(
builder: (context) {
// The viewport has already consumed the bottom bar. Pad the list's
// start below its floating top bar, leaving side insets to the rows.
final media = MediaQuery.of(context);
return CustomScrollView(
slivers: [
SliverPadding(
padding: media.padding.copyWith(left: 0, right: 0),
sliver: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: 0, bottom: 0),
),
child: SliverMainAxisGroup(
slivers: [
for (final section in sections) _section(context, section),
if (emptyMessage != null)
SliverToBoxAdapter(
child: ListTile(
title: Text(emptyMessage!),
trailing: onClearSearch == null
? null
: TextButton(
onPressed: onClearSearch,
child: const Text('Clear search'),
),
),
),
),
],
],
),
),
),
),
],
);
}
],
);
},
);
Widget _section(BuildContext context, ChatSessionSection section) {
final heading = SectionHeadingStyle.of(context);