chore: Follow up select event

pull/652/head
krille-chan 2 years ago
parent 8148999512
commit c7bdd9269a
No known key found for this signature in database

@ -114,191 +114,187 @@ class Message extends StatelessWidget {
: Theme.of(context).colorScheme.primaryContainer; : Theme.of(context).colorScheme.primaryContainer;
} }
final row = InkWell( final row = HoverBuilder(
onTap: () => onSelect!(event), builder: (context, hovered) => Row(
child: HoverBuilder( crossAxisAlignment: CrossAxisAlignment.start,
builder: (context, hovered) => Row( mainAxisAlignment: rowMainAxisAlignment,
crossAxisAlignment: CrossAxisAlignment.start, children: [
mainAxisAlignment: rowMainAxisAlignment, if (hovered || selected)
children: [ SizedBox(
if (hovered || selected) width: Avatar.defaultSize,
SizedBox( height: Avatar.defaultSize - 8,
width: Avatar.defaultSize, child: Checkbox.adaptive(
height: Avatar.defaultSize - 8, value: selected,
child: Checkbox.adaptive( onChanged: (_) => onSelect?.call(event),
value: selected, ),
onChanged: (_) => onSelect?.call(event), )
), else if (sameSender || ownMessage)
) SizedBox(
else if (sameSender || ownMessage) width: Avatar.defaultSize,
SizedBox( child: Center(
width: Avatar.defaultSize, child: SizedBox(
child: Center( width: 16,
child: SizedBox( height: 16,
width: 16, child: event.status == EventStatus.sending
height: 16, ? const CircularProgressIndicator.adaptive(
child: event.status == EventStatus.sending strokeWidth: 2,
? const CircularProgressIndicator.adaptive( )
strokeWidth: 2, : event.status == EventStatus.error
) ? const Icon(Icons.error, color: Colors.red)
: event.status == EventStatus.error : null,
? const Icon(Icons.error, color: Colors.red)
: null,
),
), ),
)
else
FutureBuilder<User?>(
future: event.fetchSenderUser(),
builder: (context, snapshot) {
final user =
snapshot.data ?? event.senderFromMemoryOrFallback;
return Avatar(
mxContent: user.avatarUrl,
name: user.calcDisplayname(),
onTap: () => onAvatarTab!(event),
);
},
), ),
Expanded( )
child: Column( else
crossAxisAlignment: CrossAxisAlignment.start, FutureBuilder<User?>(
mainAxisSize: MainAxisSize.min, future: event.fetchSenderUser(),
children: [ builder: (context, snapshot) {
if (!sameSender) final user = snapshot.data ?? event.senderFromMemoryOrFallback;
Padding( return Avatar(
padding: const EdgeInsets.only(left: 8.0, bottom: 4), mxContent: user.avatarUrl,
child: ownMessage || event.room.isDirectChat name: user.calcDisplayname(),
? const SizedBox(height: 12) onTap: () => onAvatarTab!(event),
: FutureBuilder<User?>( );
future: event.fetchSenderUser(), },
builder: (context, snapshot) { ),
final displayname = Expanded(
snapshot.data?.calcDisplayname() ?? child: Column(
event.senderFromMemoryOrFallback crossAxisAlignment: CrossAxisAlignment.start,
.calcDisplayname(); mainAxisSize: MainAxisSize.min,
return Text( children: [
displayname, if (!sameSender)
style: TextStyle( Padding(
fontSize: 12, padding: const EdgeInsets.only(left: 8.0, bottom: 4),
fontWeight: FontWeight.bold, child: ownMessage || event.room.isDirectChat
color: (Theme.of(context).brightness == ? const SizedBox(height: 12)
Brightness.light : FutureBuilder<User?>(
? displayname.color future: event.fetchSenderUser(),
: displayname.lightColorText), builder: (context, snapshot) {
), final displayname =
); snapshot.data?.calcDisplayname() ??
}, event.senderFromMemoryOrFallback
), .calcDisplayname();
), return Text(
Container( displayname,
alignment: alignment, style: TextStyle(
padding: const EdgeInsets.only(left: 8), fontSize: 12,
child: IgnorePointer( fontWeight: FontWeight.bold,
child: Material( color: (Theme.of(context).brightness ==
color: noBubble ? Colors.transparent : color, Brightness.light
borderRadius: borderRadius, ? displayname.color
clipBehavior: Clip.antiAlias, : displayname.lightColorText),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(AppConfig.borderRadius),
),
padding: noBubble || noPadding
? EdgeInsets.zero
: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
), ),
constraints: const BoxConstraints( );
maxWidth: FluffyThemes.columnWidth * 1.5, },
), ),
child: Column( ),
mainAxisSize: MainAxisSize.min, Container(
crossAxisAlignment: CrossAxisAlignment.start, alignment: alignment,
children: <Widget>[ padding: const EdgeInsets.only(left: 8),
if (event.relationshipType == child: IgnorePointer(
RelationshipTypes.reply) child: Material(
FutureBuilder<Event?>( color: noBubble ? Colors.transparent : color,
future: event.getReplyEvent(timeline), borderRadius: borderRadius,
builder: (BuildContext context, snapshot) { clipBehavior: Clip.antiAlias,
final replyEvent = snapshot.hasData child: Container(
? snapshot.data! decoration: BoxDecoration(
: Event( borderRadius:
eventId: event.relationshipEventId!, BorderRadius.circular(AppConfig.borderRadius),
content: { ),
'msgtype': 'm.text', padding: noBubble || noPadding
'body': '...', ? EdgeInsets.zero
}, : const EdgeInsets.symmetric(
senderId: event.senderId, horizontal: 16,
type: 'm.room.message', vertical: 8,
room: event.room, ),
status: EventStatus.sent, constraints: const BoxConstraints(
originServerTs: DateTime.now(), maxWidth: FluffyThemes.columnWidth * 1.5,
); ),
return InkWell( child: Column(
onTap: () { mainAxisSize: MainAxisSize.min,
if (scrollToEventId != null) { crossAxisAlignment: CrossAxisAlignment.start,
scrollToEventId!(replyEvent.eventId); children: <Widget>[
} if (event.relationshipType ==
}, RelationshipTypes.reply)
child: AbsorbPointer( FutureBuilder<Event?>(
child: Container( future: event.getReplyEvent(timeline),
margin: const EdgeInsets.symmetric( builder: (BuildContext context, snapshot) {
vertical: 4.0, final replyEvent = snapshot.hasData
), ? snapshot.data!
child: ReplyContent( : Event(
replyEvent, eventId: event.relationshipEventId!,
ownMessage: ownMessage, content: {
timeline: timeline, 'msgtype': 'm.text',
), 'body': '...',
},
senderId: event.senderId,
type: 'm.room.message',
room: event.room,
status: EventStatus.sent,
originServerTs: DateTime.now(),
);
return InkWell(
onTap: () {
if (scrollToEventId != null) {
scrollToEventId!(replyEvent.eventId);
}
},
child: AbsorbPointer(
child: Container(
margin: const EdgeInsets.symmetric(
vertical: 4.0,
),
child: ReplyContent(
replyEvent,
ownMessage: ownMessage,
timeline: timeline,
), ),
), ),
); ),
}, );
), },
MessageContent(
displayEvent,
textColor: textColor,
onInfoTab: onInfoTab,
), ),
if (event.hasAggregatedEvents( MessageContent(
timeline, displayEvent,
RelationshipTypes.edit, textColor: textColor,
)) onInfoTab: onInfoTab,
Padding( ),
padding: const EdgeInsets.only( if (event.hasAggregatedEvents(
top: 4.0, timeline,
), RelationshipTypes.edit,
child: Row( ))
mainAxisSize: MainAxisSize.min, Padding(
children: [ padding: const EdgeInsets.only(
Icon( top: 4.0,
Icons.edit_outlined, ),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.edit_outlined,
color: textColor.withAlpha(164),
size: 14,
),
Text(
' - ${displayEvent.originServerTs.localizedTimeShort(context)}',
style: TextStyle(
color: textColor.withAlpha(164), color: textColor.withAlpha(164),
size: 14, fontSize: 12,
),
Text(
' - ${displayEvent.originServerTs.localizedTimeShort(context)}',
style: TextStyle(
color: textColor.withAlpha(164),
fontSize: 12,
),
), ),
], ),
), ],
), ),
], ),
), ],
), ),
), ),
), ),
), ),
], ),
), ],
), ),
], ),
), ],
), ),
); );
Widget container; Widget container;
@ -399,18 +395,22 @@ class Message extends StatelessWidget {
direction: SwipeDirection.endToStart, direction: SwipeDirection.endToStart,
onSwipe: (_) => onSwipe(), onSwipe: (_) => onSwipe(),
child: Center( child: Center(
child: Container( child: InkWell(
color: selected onTap: longPressSelect ? () => onSelect!(event) : null,
? Theme.of(context).primaryColor.withAlpha(100) onLongPress: () => onSelect!(event),
: Theme.of(context).primaryColor.withAlpha(0), child: Container(
constraints: const BoxConstraints( color: selected
maxWidth: FluffyThemes.columnWidth * 2.5, ? Theme.of(context).primaryColor.withAlpha(100)
), : Theme.of(context).primaryColor.withAlpha(0),
padding: const EdgeInsets.symmetric( constraints: const BoxConstraints(
horizontal: 8.0, maxWidth: FluffyThemes.columnWidth * 2.5,
vertical: 4.0, ),
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
child: container,
), ),
child: container,
), ),
), ),
); );

Loading…
Cancel
Save