d1ffa7c79b
Follow the web chat layout on both hosts without changing request shapes or
bubble/composer behaviour.
- Session rows (Material and Cupertino): title with trailing relative
recency, muted `directory · model` line with the `New`/`Closed` word at
the trailing edge. Shared row content keeps one arrangement; native tiles
keep their own padding, separators and subtitle size. The state word keeps
its intrinsic width and the metadata ellipsises first, so it is never
clipped at 320px/2x.
- Thread header: one row of compact icon-only Back, ellipsised title,
bounded model control and Chat information. Back keeps the destination as
its accessible name and both hosts share `Key('chat-back')`.
- Share the epoch-millis parser as `chatSessionMillis`, and match the web's
relative-time words, including `Sept`.
- Cover the row content, status word at narrow widths, header layout and
Back accessibility in widget tests; update existing tests for the
separate trailing status word.
107 lines
3.3 KiB
Dart
107 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// The title line of a chat session row: the session's name, with its relative
|
|
/// recency at the trailing edge. Shared by the Material and Cupertino rows so
|
|
/// both hosts arrange the same facts the same way.
|
|
///
|
|
/// The recency takes at most 45% of the text column and ellipsises there, so a
|
|
/// long title keeps the larger share and a short row never overflows. The
|
|
/// recency is supplementary: at very large text scales it is the part that
|
|
/// gives way, while the session's name and state word stay whole.
|
|
class ChatSessionRowTitle extends StatelessWidget {
|
|
const ChatSessionRowTitle({
|
|
super.key,
|
|
required this.title,
|
|
required this.time,
|
|
required this.timeStyle,
|
|
});
|
|
|
|
final String title;
|
|
final String time;
|
|
final TextStyle timeStyle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) => Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
),
|
|
if (time.isNotEmpty) ...[
|
|
const SizedBox(width: 8),
|
|
ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: constraints.maxWidth * 0.45,
|
|
),
|
|
child: Text(
|
|
time,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: timeStyle,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The muted second line of a chat session row: the recorded directory and
|
|
/// model, with the unread/closed word at the trailing edge.
|
|
///
|
|
/// The directory/model is the part that ellipsises; the state word is the row's
|
|
/// only unread marker, so it keeps its intrinsic width and the metadata shrinks
|
|
/// first. If even the whole text column cannot hold the word at the current
|
|
/// text scale it is scaled down rather than clipped, so `New`/`Closed` is never
|
|
/// replaced by an ellipsis.
|
|
class ChatSessionRowMeta extends StatelessWidget {
|
|
const ChatSessionRowMeta({
|
|
super.key,
|
|
required this.meta,
|
|
required this.status,
|
|
required this.metaStyle,
|
|
required this.statusStyle,
|
|
});
|
|
|
|
final String meta;
|
|
final String? status;
|
|
final TextStyle metaStyle;
|
|
final TextStyle statusStyle;
|
|
|
|
/// The trailing word's intrinsic width is measured against the full text
|
|
/// column, minus this gap, so the row can never overflow the line.
|
|
static const _statusGap = 8.0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) => Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
meta,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: metaStyle,
|
|
),
|
|
),
|
|
if (status != null)
|
|
ConstrainedBox(
|
|
constraints: BoxConstraints(maxWidth: constraints.maxWidth),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.only(start: _statusGap),
|
|
child: FittedBox(
|
|
fit: BoxFit.scaleDown,
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
child: Text(status!, maxLines: 1, style: statusStyle),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|