chore: Follow up select event handling

pull/477/head
krille-chan 2 years ago
parent 809ee213b6
commit c313b03f71
No known key found for this signature in database

@ -98,8 +98,7 @@ class ChatEventList extends StatelessWidget {
child: event.isVisibleInGui child: event.isVisibleInGui
? Message( ? Message(
event, event,
onSwipe: (direction) => onSwipe: () => controller.replyAction(replyTo: event),
controller.replyAction(replyTo: event),
onInfoTab: controller.showEventInfo, onInfoTab: controller.showEventInfo,
onAvatarTab: (Event event) => showAdaptiveBottomSheet( onAvatarTab: (Event event) => showAdaptiveBottomSheet(
context: context, context: context,

@ -25,7 +25,7 @@ class Message extends StatelessWidget {
final void Function(Event)? onAvatarTab; final void Function(Event)? onAvatarTab;
final void Function(Event)? onInfoTab; final void Function(Event)? onInfoTab;
final void Function(String)? scrollToEventId; final void Function(String)? scrollToEventId;
final void Function(SwipeDirection) onSwipe; final void Function() onSwipe;
final bool longPressSelect; final bool longPressSelect;
final bool selected; final bool selected;
final Timeline timeline; final Timeline timeline;
@ -116,7 +116,6 @@ class Message extends StatelessWidget {
final row = InkWell( final row = InkWell(
onTap: longPressSelect ? () => onSelect!(event) : null, onTap: longPressSelect ? () => onSelect!(event) : null,
onLongPress: () => onSelect!(event),
child: HoverBuilder( child: HoverBuilder(
builder: (context, hovered) => Row( builder: (context, hovered) => Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -195,100 +194,102 @@ class Message extends StatelessWidget {
Container( Container(
alignment: alignment, alignment: alignment,
padding: const EdgeInsets.only(left: 8), padding: const EdgeInsets.only(left: 8),
child: Material( child: IgnorePointer(
color: noBubble ? Colors.transparent : color, child: Material(
borderRadius: borderRadius, color: noBubble ? Colors.transparent : color,
clipBehavior: Clip.antiAlias, borderRadius: borderRadius,
child: Container( clipBehavior: Clip.antiAlias,
decoration: BoxDecoration( child: Container(
borderRadius: decoration: BoxDecoration(
BorderRadius.circular(AppConfig.borderRadius), borderRadius:
), BorderRadius.circular(AppConfig.borderRadius),
padding: noBubble || noPadding ),
? EdgeInsets.zero padding: noBubble || noPadding
: const EdgeInsets.symmetric( ? EdgeInsets.zero
horizontal: 16, : const EdgeInsets.symmetric(
vertical: 8, horizontal: 16,
), vertical: 8,
constraints: const BoxConstraints( ),
maxWidth: FluffyThemes.columnWidth * 1.5, constraints: const BoxConstraints(
), maxWidth: FluffyThemes.columnWidth * 1.5,
child: Column( ),
mainAxisSize: MainAxisSize.min, child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min,
children: <Widget>[ crossAxisAlignment: CrossAxisAlignment.start,
if (event.relationshipType == children: <Widget>[
RelationshipTypes.reply) if (event.relationshipType ==
FutureBuilder<Event?>( RelationshipTypes.reply)
future: event.getReplyEvent(timeline), FutureBuilder<Event?>(
builder: (BuildContext context, snapshot) { future: event.getReplyEvent(timeline),
final replyEvent = snapshot.hasData builder: (BuildContext context, snapshot) {
? snapshot.data! final replyEvent = snapshot.hasData
: Event( ? snapshot.data!
eventId: event.relationshipEventId!, : Event(
content: { eventId: 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 InkWell( );
onTap: () { return InkWell(
if (scrollToEventId != null) { onTap: () {
scrollToEventId!(replyEvent.eventId); if (scrollToEventId != null) {
} scrollToEventId!(replyEvent.eventId);
}, }
child: AbsorbPointer( },
child: Container( child: AbsorbPointer(
margin: const EdgeInsets.symmetric( child: Container(
vertical: 4.0, margin: const EdgeInsets.symmetric(
), vertical: 4.0,
child: ReplyContent( ),
replyEvent, child: ReplyContent(
ownMessage: ownMessage, replyEvent,
timeline: timeline, ownMessage: ownMessage,
timeline: timeline,
),
), ),
), ),
), );
); },
},
),
MessageContent(
displayEvent,
textColor: textColor,
onInfoTab: onInfoTab,
),
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, ),
color: textColor.withAlpha(164), if (event.hasAggregatedEvents(
size: 14, timeline,
), RelationshipTypes.edit,
Text( ))
' - ${displayEvent.originServerTs.localizedTimeShort(context)}', Padding(
style: TextStyle( 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,
),
), ),
), ],
], ),
), ),
), ],
], ),
), ),
), ),
), ),
@ -392,11 +393,11 @@ class Message extends StatelessWidget {
background: const Padding( background: const Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0), padding: EdgeInsets.symmetric(horizontal: 12.0),
child: Center( child: Center(
child: Icon(Icons.reply_outlined), child: Icon(Icons.check_outlined),
), ),
), ),
direction: SwipeDirection.endToStart, direction: SwipeDirection.endToStart,
onSwipe: onSwipe, onSwipe: (_) => onSelect?.call(event),
child: Center( child: Center(
child: Container( child: Container(
color: selected color: selected

Loading…
Cancel
Save