102 lines
2.7 KiB
Dart
102 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Hierarchical row copy shared by the Material and Cupertino list variants.
|
|
/// Each server-recorded fact keeps its own line; recency is visually anchored
|
|
/// at the end of its own line rather than competing with the other metadata.
|
|
class ChatSessionRowContent extends StatelessWidget {
|
|
const ChatSessionRowContent({
|
|
super.key,
|
|
required this.title,
|
|
required this.status,
|
|
required this.recency,
|
|
required this.meta,
|
|
required this.titleStyle,
|
|
required this.metaStyle,
|
|
required this.statusStyle,
|
|
});
|
|
|
|
final String title;
|
|
final String? status;
|
|
final String? recency;
|
|
final List<String> meta;
|
|
final TextStyle titleStyle;
|
|
final TextStyle metaStyle;
|
|
final TextStyle statusStyle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
title,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: titleStyle,
|
|
),
|
|
if (status != null) ...[
|
|
const SizedBox(height: 2),
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: _StatusLabel(status: status!, style: statusStyle),
|
|
),
|
|
],
|
|
if (recency != null && recency!.isNotEmpty) ...[
|
|
const SizedBox(height: 3),
|
|
Align(
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
child: Text(
|
|
recency!,
|
|
maxLines: 2,
|
|
textAlign: TextAlign.end,
|
|
style: metaStyle,
|
|
),
|
|
),
|
|
],
|
|
for (final line in meta)
|
|
Text(
|
|
line,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: metaStyle,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StatusLabel extends StatelessWidget {
|
|
const _StatusLabel({required this.status, required this.style});
|
|
|
|
final String status;
|
|
final TextStyle style;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (status != 'New') {
|
|
return Text(
|
|
status,
|
|
maxLines: 2,
|
|
style: style.copyWith(fontWeight: FontWeight.w600),
|
|
);
|
|
}
|
|
final color = style.color ?? Theme.of(context).colorScheme.primary;
|
|
return DecoratedBox(
|
|
key: const Key('chat-row-unread'),
|
|
decoration: ShapeDecoration(color: color, shape: const StadiumBorder()),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 1),
|
|
child: Text(
|
|
status,
|
|
maxLines: 2,
|
|
style: style.copyWith(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|