Working image rendering
This commit is contained in:
parent
2aae141c27
commit
8aae2c29cb
3 changed files with 33 additions and 18 deletions
|
|
@ -2,7 +2,7 @@ import "package:flutter/material.dart";
|
||||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
import "package:nexus/models/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/relation_type.dart";
|
import "package:nexus/models/relation_type.dart";
|
||||||
import "package:nexus/widgets/chat_page/event_text.dart";
|
import "package:nexus/widgets/chat_page/render_event.dart";
|
||||||
import "package:nexus/widgets/chat_page/lazy_loading/message_avatar.dart";
|
import "package:nexus/widgets/chat_page/lazy_loading/message_avatar.dart";
|
||||||
import "package:nexus/widgets/chat_page/lazy_loading/message_displayname.dart";
|
import "package:nexus/widgets/chat_page/lazy_loading/message_displayname.dart";
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ class RelationPreview extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: EventText(
|
child: RenderEvent(
|
||||||
relatedEvent!,
|
relatedEvent!,
|
||||||
textOnly: true,
|
textOnly: true,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@ import "package:nexus/widgets/loading.dart";
|
||||||
import "package:timeago/timeago.dart";
|
import "package:timeago/timeago.dart";
|
||||||
import "package:flutter_linkify/flutter_linkify.dart";
|
import "package:flutter_linkify/flutter_linkify.dart";
|
||||||
|
|
||||||
class EventText extends ConsumerWidget {
|
class RenderEvent extends ConsumerWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
final bool textOnly;
|
final bool textOnly;
|
||||||
final bool isGrouped;
|
final bool isGrouped;
|
||||||
final int? maxLines;
|
final int? maxLines;
|
||||||
final VoidCallback? onTapReply;
|
final VoidCallback? onTapReply;
|
||||||
final IList<PopupMenuEntry> Function(Event event)? getEventOptions;
|
final IList<PopupMenuEntry> Function(Event event)? getEventOptions;
|
||||||
const EventText(
|
const RenderEvent(
|
||||||
this.event, {
|
this.event, {
|
||||||
this.onTapReply,
|
this.onTapReply,
|
||||||
this.textOnly = false,
|
this.textOnly = false,
|
||||||
|
|
@ -64,14 +64,18 @@ class EventText extends ConsumerWidget {
|
||||||
onLongPressStart: contextMenuCallback,
|
onLongPressStart: contextMenuCallback,
|
||||||
child: switch (event.content) {
|
child: switch (event.content) {
|
||||||
MessageContent() => Row(
|
MessageContent() => Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
isGrouped ? SizedBox(width: 40) : MessageAvatar(event, height: 40),
|
isGrouped || textOnly
|
||||||
|
? SizedBox(width: 40)
|
||||||
|
: MessageAvatar(event, height: 40),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
spacing: 4,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (!isGrouped)
|
if (!isGrouped && !textOnly)
|
||||||
Row(
|
Row(
|
||||||
spacing: 4,
|
spacing: 4,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -123,6 +127,7 @@ class EventText extends ConsumerWidget {
|
||||||
:final formattedBody,
|
:final formattedBody,
|
||||||
:final format,
|
:final format,
|
||||||
) => Column(
|
) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
format == "org.matrix.custom.html" && !textOnly
|
format == "org.matrix.custom.html" && !textOnly
|
||||||
? Html(
|
? Html(
|
||||||
|
|
@ -191,14 +196,24 @@ class EventText extends ConsumerWidget {
|
||||||
width: info?.width,
|
width: info?.width,
|
||||||
height: info?.height,
|
height: info?.height,
|
||||||
loadingBuilder:
|
loadingBuilder:
|
||||||
(
|
(_, child, loadingProgress) =>
|
||||||
context,
|
loadingProgress == null
|
||||||
child,
|
? child
|
||||||
loadingProgress,
|
: switch (info?.blurHash) {
|
||||||
) => switch (info?.blurHash) {
|
final blurHash? =>
|
||||||
final blurHash? => BlurHash(
|
SizedBox(
|
||||||
|
width:
|
||||||
|
info?.width ??
|
||||||
|
info?.height ??
|
||||||
|
200,
|
||||||
|
height:
|
||||||
|
info?.height ??
|
||||||
|
info?.width ??
|
||||||
|
200,
|
||||||
|
child: BlurHash(
|
||||||
hash: blurHash,
|
hash: blurHash,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
_ => Loading(),
|
_ => Loading(),
|
||||||
},
|
},
|
||||||
errorBuilder:
|
errorBuilder:
|
||||||
|
|
@ -18,7 +18,7 @@ import "package:nexus/models/relation_type.dart";
|
||||||
import "package:nexus/models/requests/report_request.dart";
|
import "package:nexus/models/requests/report_request.dart";
|
||||||
import "package:nexus/widgets/chat_page/composer/chat_box.dart";
|
import "package:nexus/widgets/chat_page/composer/chat_box.dart";
|
||||||
import "package:nexus/widgets/chat_page/emoji_picker_button.dart";
|
import "package:nexus/widgets/chat_page/emoji_picker_button.dart";
|
||||||
import "package:nexus/widgets/chat_page/event_text.dart";
|
import "package:nexus/widgets/chat_page/render_event.dart";
|
||||||
import "package:nexus/widgets/chat_page/member_list.dart";
|
import "package:nexus/widgets/chat_page/member_list.dart";
|
||||||
import "package:nexus/widgets/chat_page/room_appbar.dart";
|
import "package:nexus/widgets/chat_page/room_appbar.dart";
|
||||||
import "package:nexus/widgets/chat_page/wrappers/event_wrapper.dart";
|
import "package:nexus/widgets/chat_page/wrappers/event_wrapper.dart";
|
||||||
|
|
@ -329,7 +329,7 @@ class RoomChat extends HookConsumerWidget {
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
child: EventWrapper(
|
child: EventWrapper(
|
||||||
value[index],
|
value[index],
|
||||||
EventText(
|
RenderEvent(
|
||||||
value[index],
|
value[index],
|
||||||
onTapReply: () =>
|
onTapReply: () =>
|
||||||
listController.value.animateToItem(
|
listController.value.animateToItem(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue