chore: Follow up image rendering
This commit is contained in:
parent
449357b501
commit
45e1122648
5 changed files with 48 additions and 49 deletions
|
|
@ -152,7 +152,8 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
return MatrixFile(
|
||||
bytes: await xfile.readAsBytes(),
|
||||
name: xfile.name,
|
||||
);
|
||||
mimeType: xfile.mimeType,
|
||||
).detectFileType;
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:pasteboard/pasteboard.dart';
|
|||
import 'package:slugify/slugify.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
import '../../widgets/avatar.dart';
|
||||
|
|
@ -464,7 +465,7 @@ class InputBar extends StatelessWidget {
|
|||
mimeType: content.mimeType,
|
||||
bytes: data,
|
||||
name: content.uri.split('/').last,
|
||||
);
|
||||
).detectFileType;
|
||||
room.sendFileEvent(file, shrinkImageMaxDimension: 1600);
|
||||
},
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue