🐛 Fix bugs and don't know what has been fixed
This commit is contained in:
@ -29,9 +29,12 @@ class AttachmentPreview extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var ratio =
|
||||
(item.isOnCloud ? (item.data.fileMeta?['ratio'] ?? 1) : 1).toDouble();
|
||||
if (ratio == 0) ratio = 1.0;
|
||||
|
||||
return AspectRatio(
|
||||
aspectRatio:
|
||||
(item.isOnCloud ? (item.data.fileMeta?['ratio'] ?? 1) : 1).toDouble(),
|
||||
aspectRatio: ratio,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Stack(
|
||||
|
@ -37,13 +37,10 @@ class CloudFileList extends HookConsumerWidget {
|
||||
|
||||
double calculateAspectRatio() {
|
||||
double total = 0;
|
||||
for (var ratio in files.map(
|
||||
(e) =>
|
||||
e.fileMeta?['ratio'] ??
|
||||
((e.mimeType?.startsWith('image') ?? false) ? 1 : 16 / 9),
|
||||
)) {
|
||||
for (var ratio in files.map((e) => e.fileMeta?['ratio'] ?? 1)) {
|
||||
total += ratio;
|
||||
}
|
||||
if (total == 0) return 1;
|
||||
return total / files.length;
|
||||
}
|
||||
|
||||
|
@ -27,20 +27,19 @@ class CloudFileWidget extends ConsumerWidget {
|
||||
final serverUrl = ref.watch(serverUrlProvider);
|
||||
final uri = '$serverUrl/api/files/${item.id}';
|
||||
|
||||
var ratio = (item.fileMeta?['ratio'] ?? 1).toDouble();
|
||||
if (ratio == 0) ratio = 1.0;
|
||||
final content = switch (item.mimeType?.split('/').firstOrNull) {
|
||||
"image" => AspectRatio(
|
||||
aspectRatio: (item.fileMeta?['ratio'] ?? 1).toDouble(),
|
||||
aspectRatio: ratio,
|
||||
child: UniversalImage(
|
||||
uri: uri,
|
||||
blurHash: noBlurhash ? null : item.fileMeta?['blur'],
|
||||
),
|
||||
),
|
||||
"video" => AspectRatio(
|
||||
aspectRatio: (item.fileMeta?['ratio'] ?? 16 / 9).toDouble(),
|
||||
child: UniversalVideo(
|
||||
uri: uri,
|
||||
aspectRatio: (item.fileMeta?['ratio'] ?? 16 / 9).toDouble(),
|
||||
),
|
||||
aspectRatio: ratio,
|
||||
child: UniversalVideo(uri: uri, aspectRatio: ratio),
|
||||
),
|
||||
_ => Text('Unable render for ${item.mimeType}'),
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ class _UniversalVideoState extends ConsumerState<UniversalVideo> {
|
||||
|
||||
return Video(
|
||||
controller: _videoController!,
|
||||
aspectRatio: widget.aspectRatio,
|
||||
aspectRatio: widget.aspectRatio != 1 ? widget.aspectRatio : null,
|
||||
controls:
|
||||
!kIsWeb && (Platform.isAndroid || Platform.isIOS)
|
||||
? MaterialVideoControls
|
||||
|
Reference in New Issue
Block a user