mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 06:25:15 +00:00
chore: Follow up select event
This commit is contained in:
parent
8148999512
commit
c7bdd9269a
1 changed files with 184 additions and 184 deletions
|
@ -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(
|
|
||||||
width: Avatar.defaultSize,
|
|
||||||
child: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
child: event.status == EventStatus.sending
|
|
||||||
? const CircularProgressIndicator.adaptive(
|
|
||||||
strokeWidth: 2,
|
|
||||||
)
|
|
||||||
: event.status == EventStatus.error
|
|
||||||
? 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 if (sameSender || ownMessage)
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
SizedBox(
|
||||||
mainAxisSize: MainAxisSize.min,
|
width: Avatar.defaultSize,
|
||||||
children: [
|
child: Center(
|
||||||
if (!sameSender)
|
child: SizedBox(
|
||||||
Padding(
|
width: 16,
|
||||||
padding: const EdgeInsets.only(left: 8.0, bottom: 4),
|
height: 16,
|
||||||
child: ownMessage || event.room.isDirectChat
|
child: event.status == EventStatus.sending
|
||||||
? const SizedBox(height: 12)
|
? const CircularProgressIndicator.adaptive(
|
||||||
: FutureBuilder<User?>(
|
strokeWidth: 2,
|
||||||
future: event.fetchSenderUser(),
|
)
|
||||||
builder: (context, snapshot) {
|
: event.status == EventStatus.error
|
||||||
final displayname =
|
? const Icon(Icons.error, color: Colors.red)
|
||||||
snapshot.data?.calcDisplayname() ??
|
: null,
|
||||||
event.senderFromMemoryOrFallback
|
),
|
||||||
.calcDisplayname();
|
),
|
||||||
return Text(
|
)
|
||||||
displayname,
|
else
|
||||||
style: TextStyle(
|
FutureBuilder<User?>(
|
||||||
fontSize: 12,
|
future: event.fetchSenderUser(),
|
||||||
fontWeight: FontWeight.bold,
|
builder: (context, snapshot) {
|
||||||
color: (Theme.of(context).brightness ==
|
final user = snapshot.data ?? event.senderFromMemoryOrFallback;
|
||||||
Brightness.light
|
return Avatar(
|
||||||
? displayname.color
|
mxContent: user.avatarUrl,
|
||||||
: displayname.lightColorText),
|
name: user.calcDisplayname(),
|
||||||
),
|
onTap: () => onAvatarTab!(event),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Container(
|
child: Column(
|
||||||
alignment: alignment,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
padding: const EdgeInsets.only(left: 8),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: IgnorePointer(
|
children: [
|
||||||
child: Material(
|
if (!sameSender)
|
||||||
color: noBubble ? Colors.transparent : color,
|
Padding(
|
||||||
borderRadius: borderRadius,
|
padding: const EdgeInsets.only(left: 8.0, bottom: 4),
|
||||||
clipBehavior: Clip.antiAlias,
|
child: ownMessage || event.room.isDirectChat
|
||||||
child: Container(
|
? const SizedBox(height: 12)
|
||||||
decoration: BoxDecoration(
|
: FutureBuilder<User?>(
|
||||||
borderRadius:
|
future: event.fetchSenderUser(),
|
||||||
BorderRadius.circular(AppConfig.borderRadius),
|
builder: (context, snapshot) {
|
||||||
),
|
final displayname =
|
||||||
padding: noBubble || noPadding
|
snapshot.data?.calcDisplayname() ??
|
||||||
? EdgeInsets.zero
|
event.senderFromMemoryOrFallback
|
||||||
: const EdgeInsets.symmetric(
|
.calcDisplayname();
|
||||||
horizontal: 16,
|
return Text(
|
||||||
vertical: 8,
|
displayname,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: (Theme.of(context).brightness ==
|
||||||
|
Brightness.light
|
||||||
|
? displayname.color
|
||||||
|
: displayname.lightColorText),
|
||||||
),
|
),
|
||||||
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,
|
|
||||||
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(
|
constraints: const BoxConstraints(
|
||||||
timeline,
|
maxWidth: FluffyThemes.columnWidth * 1.5,
|
||||||
RelationshipTypes.edit,
|
),
|
||||||
))
|
child: Column(
|
||||||
Padding(
|
mainAxisSize: MainAxisSize.min,
|
||||||
padding: const EdgeInsets.only(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
top: 4.0,
|
children: <Widget>[
|
||||||
),
|
if (event.relationshipType ==
|
||||||
child: Row(
|
RelationshipTypes.reply)
|
||||||
mainAxisSize: MainAxisSize.min,
|
FutureBuilder<Event?>(
|
||||||
children: [
|
future: event.getReplyEvent(timeline),
|
||||||
Icon(
|
builder: (BuildContext context, snapshot) {
|
||||||
Icons.edit_outlined,
|
final replyEvent = snapshot.hasData
|
||||||
color: textColor.withAlpha(164),
|
? snapshot.data!
|
||||||
size: 14,
|
: Event(
|
||||||
),
|
eventId: event.relationshipEventId!,
|
||||||
Text(
|
content: {
|
||||||
' - ${displayEvent.originServerTs.localizedTimeShort(context)}',
|
'msgtype': 'm.text',
|
||||||
style: TextStyle(
|
'body': '...',
|
||||||
color: textColor.withAlpha(164),
|
},
|
||||||
fontSize: 12,
|
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(
|
||||||
|
timeline,
|
||||||
|
RelationshipTypes.edit,
|
||||||
|
))
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 4.0,
|
||||||
),
|
),
|
||||||
],
|
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),
|
||||||
|
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),
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: FluffyThemes.columnWidth * 2.5,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0,
|
||||||
|
vertical: 4.0,
|
||||||
|
),
|
||||||
|
child: container,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8.0,
|
|
||||||
vertical: 4.0,
|
|
||||||
),
|
|
||||||
child: container,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue