Files
alan fbe1928f59 Remove Cupertino chat transcript branches
Keep the existing Material transcript path while preserving public Cupertino parameters for callers. Narrow transcript tests to the Material-only behavior and remove Cupertino-only fixtures.
2026-11-11 11:46:13 +00:00

48 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
/// The small, non-selectable metadata line for a recorded chat message time.
/// The visible value includes a local date so messages from different days are
/// not ambiguous; the tooltip and semantics expose the full localized value.
class ChatMessageTimestamp extends StatelessWidget {
const ChatMessageTimestamp({super.key, required this.createdAt});
final int? createdAt;
@override
Widget build(BuildContext context) {
final instant = createdAt == null
? null
: DateTime.fromMillisecondsSinceEpoch(
createdAt!,
isUtc: true,
).toLocal();
if (instant == null) return const SizedBox.shrink();
final material = MaterialLocalizations.of(context);
final time = material.formatTimeOfDay(
TimeOfDay.fromDateTime(instant),
alwaysUse24HourFormat: true,
);
final date = '${instant.day} ${material.formatMonthYear(instant)}';
final full = '$date, $time';
final style = (Theme.of(context).textTheme.bodySmall ?? const TextStyle())
.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 12,
);
final label = 'Sent $full';
final text = Text('$date · $time', style: style);
return SelectionContainer.disabled(
child: Tooltip(
message: full,
child: Semantics(
container: true,
label: label,
excludeSemantics: true,
child: text,
),
),
);
}
}