Skip to content

Commit

Permalink
Add edited marker
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz committed Jun 5, 2024
1 parent 3bcde77 commit deab62c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>

int index = 0;

late bool edited;

@override
void initState() {
currentUserIdentifier = widget.timeline.client.self!.identifier;
Expand All @@ -77,6 +79,7 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>
showSender: showSender,
formattedContent: formattedContent,
timestamp: timestampToString(sentTime),
edited: edited,
attachments: attachments != null
? TimelineEventViewAttachments(attachments: attachments!)
: null,
Expand Down Expand Up @@ -125,6 +128,7 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>

showSender = shouldShowSender(eventIndex);

edited = event.edited;
if (event.type == EventType.encrypted) {
formattedContent = tiamat.Text.error(messageFailedToDecrypt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:commet/diagnostic/benchmark_values.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart';
import 'package:tiamat/tiamat.dart' as tiamat;

class TimelineEventLayoutMessage extends StatelessWidget {
Expand All @@ -17,6 +18,7 @@ class TimelineEventLayoutMessage extends StatelessWidget {
this.reactions,
this.timestamp,
this.urlPreviews,
this.edited = false,
this.avatarSize = 32,
this.showSender = true});
final String senderName;
Expand All @@ -28,10 +30,15 @@ class TimelineEventLayoutMessage extends StatelessWidget {
final Widget? reactions;
final Widget? urlPreviews;
final bool showSender;
final bool edited;
final String? timestamp;

final double avatarSize;

String get messageEditedMarker => Intl.message("(Edited)",
name: "messageEditedMarker",
desc: "Short text to mark that a message has been edited");

@override
Widget build(BuildContext context) {
BenchmarkValues.numTimelineMessageBodyBuilt += 1;
Expand Down Expand Up @@ -63,6 +70,7 @@ class TimelineEventLayoutMessage extends StatelessWidget {
),
if (formattedContent != null)
RepaintBoundary(child: formattedContent!),
if (edited) tiamat.Text.labelLow(messageEditedMarker),
if (attachments != null) attachments!,
if (urlPreviews != null) urlPreviews!,
if (reactions != null)
Expand Down

0 comments on commit deab62c

Please sign in to comment.