import 'package:flutter/material.dart'; /// A chat session row line with the unread/closed word at its trailing edge: /// the row's title line, as on the web. /// /// 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), ), ), ), ], ), ); } }