chore: Follow up image rendering

This commit is contained in:
krille-chan 2024-03-24 10:56:44 +01:00
commit 45e1122648
No known key found for this signature in database
5 changed files with 48 additions and 49 deletions

View file

@ -111,26 +111,29 @@ class MessageContent extends StatelessWidget {
if (event.redacted) continue textmessage;
const maxSize = 256.0;
final w = event.content
.tryGetMap<String, Object?>('info')
?.tryGet<int>('w') ??
maxSize;
.tryGetMap<String, Object?>('info')
?.tryGet<int>('w');
final h = event.content
.tryGetMap<String, Object?>('info')
?.tryGet<int>('h') ??
maxSize;
double width, height;
if (w > h) {
width = maxSize;
height = max(32, maxSize * (h / w));
} else {
height = maxSize;
width = max(32, maxSize * (w / h));
.tryGetMap<String, Object?>('info')
?.tryGet<int>('h');
var width = maxSize;
var height = maxSize;
var fit = BoxFit.cover;
if (w != null && h != null) {
fit = BoxFit.contain;
if (w > h) {
width = maxSize;
height = max(32, maxSize * (h / w));
} else {
height = maxSize;
width = max(32, maxSize * (w / h));
}
}
return ImageBubble(
event,
width: width,
height: height,
fit: BoxFit.contain,
fit: fit,
borderRadius: borderRadius,
);
case CuteEventContent.eventType: