show timestamps for state events
This commit is contained in:
parent
f23a35384d
commit
cfab803fa0
4 changed files with 35 additions and 17 deletions
|
|
@ -24,6 +24,7 @@ import "package:nexus/widgets/renderers/message.dart";
|
|||
import "package:nexus/widgets/reaction_row.dart";
|
||||
import "package:nexus/widgets/renderers/membership.dart";
|
||||
import "package:nexus/widgets/renderers/generic_event.dart";
|
||||
import "package:nexus/widgets/timestamp.dart";
|
||||
|
||||
class const EventRenderer(
|
||||
final Event event, {
|
||||
|
|
@ -196,7 +197,18 @@ class const EventRenderer(
|
|||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8)
|
||||
.copyWith(top: isGrouped ? 0 : 8),
|
||||
child: child,
|
||||
child: Row(
|
||||
mainAxisSize: .min,
|
||||
spacing: 6,
|
||||
children: [
|
||||
Flexible(child: child),
|
||||
if (child is! MessageRenderer)
|
||||
Flexible(
|
||||
flex: 0,
|
||||
child: Timestamp(event.timestamp),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -204,10 +216,7 @@ class const EventRenderer(
|
|||
),
|
||||
|
||||
...[
|
||||
if (event.content is! MessageContent &&
|
||||
event.content is! StickerContent &&
|
||||
event.content is! EncryptedContent)
|
||||
ReactionRow(event),
|
||||
if (child is! MessageRenderer) ReactionRow(event),
|
||||
|
||||
if (event.sendError != null && event.sendError != "not sent")
|
||||
Padding(
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ class const GenericEventRenderer(
|
|||
padding: .symmetric(vertical: 4),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
Padding(padding: .symmetric(horizontal: 4), child: Icon(icon)),
|
||||
Expanded(child: Wrap(spacing: 4, children: children)),
|
||||
Flexible(child: Wrap(spacing: 4, children: children)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import "package:nexus/widgets/lazy_loading/message_displayname.dart";
|
|||
import "package:nexus/widgets/linkified_text.dart";
|
||||
import "package:nexus/widgets/message_image.dart";
|
||||
import "package:nexus/widgets/reaction_row.dart";
|
||||
import "package:nexus/widgets/timestamp.dart";
|
||||
import "package:nexus/widgets/url_preview.dart";
|
||||
import "package:timeago/timeago.dart";
|
||||
import "package:nexus/widgets/event_preview.dart";
|
||||
|
|
@ -35,16 +36,6 @@ class const MessageRenderer(
|
|||
final colorScheme = theme.colorScheme;
|
||||
final errorStyle = TextStyle(color: colorScheme.error);
|
||||
|
||||
final timestamp = Tooltip(
|
||||
message: event.timestamp.toString(),
|
||||
child: Text(
|
||||
format(event.timestamp),
|
||||
maxLines: 1,
|
||||
overflow: .ellipsis,
|
||||
style: theme.textTheme.labelSmall?.copyWith(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
|
||||
final textStyle = TextStyle(
|
||||
fontSize: event.localContent?.bigEmoji == true ? 32 : null,
|
||||
fontStyle: event.content is EmoteMessageContent ? .italic : null,
|
||||
|
|
@ -70,7 +61,7 @@ class const MessageRenderer(
|
|||
spacing: 4,
|
||||
children: [
|
||||
Flexible(child: MessageDisplayname(event)),
|
||||
Flexible(flex: 0, child: timestamp),
|
||||
Flexible(flex: 0, child: Timestamp(event.timestamp)),
|
||||
],
|
||||
),
|
||||
Card(
|
||||
|
|
|
|||
17
lib/widgets/timestamp.dart
Normal file
17
lib/widgets/timestamp.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:timeago/timeago.dart";
|
||||
|
||||
class const Timestamp(final DateTime timestamp, {super.key})
|
||||
extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => Tooltip(
|
||||
message: timestamp.toString(),
|
||||
child: Text(
|
||||
format(timestamp),
|
||||
maxLines: 1,
|
||||
overflow: .ellipsis,
|
||||
style: Theme.of(context).textTheme.labelSmall
|
||||
?.copyWith(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue