chore: Follow up mark messages

pull/754/head
krille-chan 2 years ago
parent 8f66cad58b
commit bfb3fa0f30
No known key found for this signature in database

@ -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(
child: Container( color: noBubble ? Colors.transparent : color,
decoration: BoxDecoration( clipBehavior: Clip.antiAlias,
borderRadius: elevation: highlightMarker || selected ? 10 : 0,
BorderRadius.circular(AppConfig.borderRadius), shape: RoundedRectangleBorder(
), borderRadius: borderRadius,
padding: noBubble || noPadding side: BorderSide(
? EdgeInsets.zero width: highlightMarker || selected ? 1 : 0,
: const EdgeInsets.symmetric( color: selected
horizontal: 16, ? Theme.of(context).colorScheme.onBackground
vertical: 8, : highlightMarker
), ? Theme.of(context).colorScheme.primary
constraints: const BoxConstraints( : Colors.transparent,
maxWidth: FluffyThemes.columnWidth * 1.5, ),
), ),
child: Column( child: Container(
mainAxisSize: MainAxisSize.min, decoration: BoxDecoration(
crossAxisAlignment: CrossAxisAlignment.start, borderRadius: BorderRadius.circular(
children: <Widget>[ AppConfig.borderRadius,
if (event.relationshipType == ),
RelationshipTypes.reply) ),
FutureBuilder<Event?>( padding: noBubble || noPadding
future: event.getReplyEvent(timeline), ? EdgeInsets.zero
builder: (BuildContext context, snapshot) { : const EdgeInsets.symmetric(
final replyEvent = snapshot.hasData horizontal: 16,
? snapshot.data! vertical: 8,
: Event( ),
eventId: constraints: const BoxConstraints(
event.relationshipEventId!, maxWidth: FluffyThemes.columnWidth * 1.5,
content: { ),
'msgtype': 'm.text', child: Column(
'body': '...', mainAxisSize: MainAxisSize.min,
}, crossAxisAlignment: CrossAxisAlignment.start,
senderId: event.senderId, children: <Widget>[
type: 'm.room.message', if (event.relationshipType ==
room: event.room, RelationshipTypes.reply)
status: EventStatus.sent, FutureBuilder<Event?>(
originServerTs: DateTime.now(), future: event.getReplyEvent(timeline),
); builder:
return Padding( (BuildContext context, snapshot) {
padding: final replyEvent = snapshot.hasData
const EdgeInsets.only(bottom: 4.0), ? snapshot.data!
child: InkWell( : Event(
borderRadius: eventId:
ReplyContent.borderRadius, event.relationshipEventId!,
onTap: () => scrollToEventId( content: {
replyEvent.eventId, 'msgtype': 'm.text',
'body': '...',
},
senderId: event.senderId,
type: 'm.room.message',
room: event.room,
status: EventStatus.sent,
originServerTs: DateTime.now(),
);
return Padding(
padding: const EdgeInsets.only(
bottom: 4.0,
), ),
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(),
),
], ],
), ],
), ),
), ),
], ),
), ],
), ),
), ),
), ),

Loading…
Cancel
Save