diff --git a/lib/widgets/chat_page/render_event.dart b/lib/widgets/chat_page/render_event.dart index b8e8b85..84b95fc 100644 --- a/lib/widgets/chat_page/render_event.dart +++ b/lib/widgets/chat_page/render_event.dart @@ -96,29 +96,21 @@ class RenderEvent extends ConsumerWidget { Flexible(child: timestamp), ], ), - ClipRRect( - borderRadius: textOnly - ? BorderRadius.zero - : BorderRadius.all(Radius.circular(8)), - child: Container( - padding: textOnly - ? EdgeInsets.zero - : EdgeInsets.symmetric(vertical: 8, horizontal: 12), - decoration: textOnly - ? null - : BoxDecoration( - color: - ref.watch( - ClientStateController.provider.select( - (value) => value?.userId, - ), - ) == - event.sender - ? (event.eventId.startsWith("~") - ? colorScheme.onPrimary - : colorScheme.primaryContainer) - : colorScheme.surfaceContainer, - ), + Card( + color: + ref.watch( + ClientStateController.provider.select( + (value) => value?.userId, + ), + ) == + event.sender + ? (event.eventId.startsWith("~") + ? colorScheme.onPrimary + : colorScheme.primaryContainer) + : colorScheme.surfaceContainer, + + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -185,72 +177,80 @@ class RenderEvent extends ConsumerWidget { ).colorScheme.primary, ), ), - if (event.content case ImageMessageContent( - :final url, - :final info, - )) - switch (url?.mxcToHttps( - ref.watch( - ClientStateController.provider.select( - (value) => value!.homeserverUrl!, - ), - ), - )) { - final url? => ExpandableImage( - url.toString(), - child: ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(8), + + if (!textOnly) + if (event.content case ImageMessageContent( + :final url, + :final info, + )) + switch (url?.mxcToHttps( + ref.watch( + ClientStateController.provider.select( + (value) => value!.homeserverUrl!, ), - child: Image( - image: CachedNetworkImage( - url.toString(), - ref.watch( - CrossCacheController.provider, + ), + )) { + final url? => ConstrainedBox( + constraints: BoxConstraints.loose( + Size.fromWidth(500), + ), + child: ExpandableImage( + url.toString(), + child: ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(8), ), - headers: ref.headers, - ), - width: info?.width, - loadingBuilder: - (_, child, loadingProgress) => - loadingProgress == null - ? child - : switch (info?.blurHash) { - final blurHash? => SizedBox( - width: - info?.width ?? - info?.height ?? - 200, - height: - info?.height ?? - info?.width ?? - 200, - child: BlurHash( - hash: blurHash, + child: Image( + image: CachedNetworkImage( + url.toString(), + ref.watch( + CrossCacheController.provider, + ), + headers: ref.headers, + ), + width: info?.width, + loadingBuilder: + (_, child, loadingProgress) => + loadingProgress == null + ? child + : switch (info?.blurHash) { + final blurHash? => + SizedBox( + width: + info?.width ?? + info?.height ?? + 200, + height: + info?.height ?? + info?.width ?? + 200, + child: BlurHash( + hash: blurHash, + ), + ), + _ => Loading(), + }, + errorBuilder: + (context, error, stackTrace) => + Center( + child: Text( + "Image Failed to Load", + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.error, + ), ), ), - _ => Loading(), - }, - errorBuilder: - (context, error, stackTrace) => - Center( - child: Text( - "Image Failed to Load", - style: TextStyle( - color: Theme.of( - context, - ).colorScheme.error, - ), - ), - ), + ), + ), ), ), - ), - _ => Text( - "Nexus currently cannot handle encrypted media", - style: errorStyle, - ), - }, + _ => Text( + "Nexus currently cannot handle encrypted media", + style: errorStyle, + ), + }, if (event.lastEditRowId != null && !textOnly) Text( "(edited)",