chore: Follow up mark messages

This commit is contained in:
krille-chan 2023-12-27 17:49:59 +01:00
parent 8f66cad58b
commit bfb3fa0f30
No known key found for this signature in database

View file

@ -125,6 +125,8 @@ class Message extends StatelessWidget {
final resetAnimateIn = this.resetAnimateIn; final resetAnimateIn = this.resetAnimateIn;
var animateIn = this.animateIn; var animateIn = this.animateIn;
TapDownDetails? lastTapDownDetails;
final row = StatefulBuilder( final row = StatefulBuilder(
builder: (context, setState) { builder: (context, setState) {
if (animateIn && resetAnimateIn != null) { if (animateIn && resetAnimateIn != null) {
@ -202,123 +204,141 @@ class Message extends StatelessWidget {
Container( Container(
alignment: alignment, alignment: alignment,
padding: const EdgeInsets.only(left: 8), padding: const EdgeInsets.only(left: 8),
child: AnimatedOpacity( child: GestureDetector(
opacity: animateIn onTapDown: (details) {
? 0 lastTapDownDetails = details;
: event.redacted || },
event.messageType == onTap: () {
MessageTypes.BadEncrypted || if (lastTapDownDetails?.kind ==
event.status.isSending PointerDeviceKind.mouse) {
? 0.5 return;
: 1, }
duration: FluffyThemes.animationDuration, onSelect(event);
curve: FluffyThemes.animationCurve, },
child: Material( onLongPress: event.messageType == MessageTypes.Text
color: noBubble ? Colors.transparent : color, ? null
clipBehavior: Clip.antiAlias, : () => onSelect(event),
elevation: highlightMarker || selected ? 10 : 0, child: AnimatedOpacity(
shape: RoundedRectangleBorder( opacity: animateIn
borderRadius: borderRadius, ? 0
side: BorderSide( : event.redacted ||
width: highlightMarker || selected ? 1 : 0, event.messageType ==
color: selected MessageTypes.BadEncrypted ||
? Theme.of(context).colorScheme.onBackground event.status.isSending
: highlightMarker ? 0.5
? Theme.of(context).colorScheme.primary : 1,
: Colors.transparent, duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: Material(
color: noBubble ? Colors.transparent : color,
clipBehavior: Clip.antiAlias,
elevation: highlightMarker || selected ? 10 : 0,
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
side: BorderSide(
width: highlightMarker || selected ? 1 : 0,
color: selected
? Theme.of(context).colorScheme.onBackground
: highlightMarker
? Theme.of(context).colorScheme.primary
: Colors.transparent,
),
), ),
), child: Container(
child: Container( decoration: BoxDecoration(
decoration: BoxDecoration( borderRadius: BorderRadius.circular(
borderRadius: AppConfig.borderRadius,
BorderRadius.circular(AppConfig.borderRadius), ),
), ),
padding: noBubble || noPadding padding: noBubble || noPadding
? EdgeInsets.zero ? EdgeInsets.zero
: const EdgeInsets.symmetric( : const EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
vertical: 8, vertical: 8,
), ),
constraints: const BoxConstraints( constraints: const BoxConstraints(
maxWidth: FluffyThemes.columnWidth * 1.5, maxWidth: FluffyThemes.columnWidth * 1.5,
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
if (event.relationshipType == if (event.relationshipType ==
RelationshipTypes.reply) RelationshipTypes.reply)
FutureBuilder<Event?>( FutureBuilder<Event?>(
future: event.getReplyEvent(timeline), future: event.getReplyEvent(timeline),
builder: (BuildContext context, snapshot) { builder:
final replyEvent = snapshot.hasData (BuildContext context, snapshot) {
? snapshot.data! final replyEvent = snapshot.hasData
: Event( ? snapshot.data!
eventId: : Event(
event.relationshipEventId!, eventId:
content: { event.relationshipEventId!,
'msgtype': 'm.text', content: {
'body': '...', 'msgtype': 'm.text',
}, 'body': '...',
senderId: event.senderId, },
type: 'm.room.message', senderId: event.senderId,
room: event.room, type: 'm.room.message',
status: EventStatus.sent, room: event.room,
originServerTs: DateTime.now(), status: EventStatus.sent,
); originServerTs: DateTime.now(),
return Padding( );
padding: return Padding(
const EdgeInsets.only(bottom: 4.0), padding: const EdgeInsets.only(
child: InkWell( bottom: 4.0,
borderRadius:
ReplyContent.borderRadius,
onTap: () => scrollToEventId(
replyEvent.eventId,
), ),
child: AbsorbPointer( child: InkWell(
child: ReplyContent( borderRadius:
replyEvent, ReplyContent.borderRadius,
ownMessage: ownMessage, onTap: () => scrollToEventId(
timeline: timeline, replyEvent.eventId,
),
child: AbsorbPointer(
child: ReplyContent(
replyEvent,
ownMessage: ownMessage,
timeline: timeline,
),
), ),
), ),
), );
); },
},
),
MessageContent(
displayEvent,
textColor: textColor,
onInfoTab: onInfoTab,
borderRadius: borderRadius,
),
if (event.hasAggregatedEvents(
timeline,
RelationshipTypes.edit,
))
Padding(
padding: const EdgeInsets.only(
top: 4.0,
), ),
child: Row( MessageContent(
mainAxisSize: MainAxisSize.min, displayEvent,
children: [ textColor: textColor,
Icon( onInfoTab: onInfoTab,
Icons.edit_outlined, borderRadius: borderRadius,
color: textColor.withAlpha(164), ),
size: 14, if (event.hasAggregatedEvents(
), timeline,
Text( RelationshipTypes.edit,
' - ${displayEvent.originServerTs.localizedTimeShort(context)}', ))
style: TextStyle( Padding(
padding: const EdgeInsets.only(
top: 4.0,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.edit_outlined,
color: textColor.withAlpha(164), color: textColor.withAlpha(164),
fontSize: 12, size: 14,
), ),
), Text(
], ' - ${displayEvent.originServerTs.localizedTimeShort(context)}',
style: TextStyle(
color: textColor.withAlpha(164),
fontSize: 12,
),
),
],
),
), ),
), ],
], ),
), ),
), ),
), ),
@ -413,8 +433,6 @@ class Message extends StatelessWidget {
container = row; container = row;
} }
TapDownDetails? lastTapDownDetails;
return Center( return Center(
child: Swipeable( child: Swipeable(
key: ValueKey(event.eventId), key: ValueKey(event.eventId),
@ -426,77 +444,64 @@ class Message extends StatelessWidget {
), ),
direction: SwipeDirection.endToStart, direction: SwipeDirection.endToStart,
onSwipe: (_) => onSwipe(), onSwipe: (_) => onSwipe(),
child: GestureDetector( child: HoverBuilder(
onTapDown: (details) { builder: (context, hovered) => Stack(
lastTapDownDetails = details; children: [
}, Container(
onTap: () { constraints: const BoxConstraints(
if (lastTapDownDetails?.kind == PointerDeviceKind.mouse) { maxWidth: FluffyThemes.columnWidth * 2.5,
return;
}
onSelect(event);
},
child: HoverBuilder(
builder: (context, hovered) => Stack(
children: [
Container(
constraints: const BoxConstraints(
maxWidth: FluffyThemes.columnWidth * 2.5,
),
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
child: container,
), ),
if (hovered || selected) padding: const EdgeInsets.symmetric(
Positioned( horizontal: 8.0,
left: 4, vertical: 4.0,
bottom: 4, ),
child: Material( child: container,
color: Theme.of(context) ),
.colorScheme if (hovered || selected)
.background Positioned(
.withOpacity(0.9), left: 4,
elevation: Theme.of(context) bottom: 4,
.appBarTheme child: Material(
.scrolledUnderElevation ?? color: Theme.of(context)
4, .colorScheme
borderRadius: .background
BorderRadius.circular(AppConfig.borderRadius), .withOpacity(0.9),
shadowColor: Theme.of(context).appBarTheme.shadowColor, elevation:
child: Row( Theme.of(context).appBarTheme.scrolledUnderElevation ??
mainAxisSize: MainAxisSize.min, 4,
children: [ borderRadius: BorderRadius.circular(AppConfig.borderRadius),
IconButton( shadowColor: Theme.of(context).appBarTheme.shadowColor,
icon: Icon( child: Row(
selected mainAxisSize: MainAxisSize.min,
? Icons.check_circle children: [
: longPressSelect IconButton(
? Icons.check_circle_outlined icon: Icon(
: Icons.check_circle_outlined, selected
size: 16, ? Icons.check_circle
), : longPressSelect
tooltip: L10n.of(context)!.select, ? Icons.check_circle_outlined
onPressed: () => onSelect(event), : Icons.check_circle_outlined,
size: 16,
), ),
if (hovered) ...[ tooltip: L10n.of(context)!.select,
if (event.room.canSendDefaultMessages) onPressed: () => onSelect(event),
IconButton( ),
icon: const Icon( if (hovered) ...[
Icons.reply_outlined, if (event.room.canSendDefaultMessages)
size: 16, IconButton(
), icon: const Icon(
tooltip: L10n.of(context)!.reply, Icons.reply_outlined,
onPressed: () => onSwipe(), size: 16,
), ),
], tooltip: L10n.of(context)!.reply,
onPressed: () => onSwipe(),
),
], ],
), ],
), ),
), ),
], ),
), ],
), ),
), ),
), ),