mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Enable local echoes for media uploads on development builds. (#3514)
* Enable local echoes for media uploads on development builds. * Use media sizes when loading timeline items so they can take advantage of the cached local echo data.
This commit is contained in:
+33
-24
@@ -17,19 +17,12 @@ struct ImageRoomTimelineView: View {
|
||||
var body: some View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
LoadableImage(mediaSource: source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.height,
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonImage)
|
||||
// This clip shape is distinct from the one in the styler as that one
|
||||
// operates on the entire message so wouldn't round the bottom corners.
|
||||
.clipShape(RoundedRectangle(cornerRadius: hasMediaCaption ? 6 : 0))
|
||||
loadableImage
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonImage)
|
||||
// This clip shape is distinct from the one in the styler as that one
|
||||
// operates on the entire message so wouldn't round the bottom corners.
|
||||
.clipShape(RoundedRectangle(cornerRadius: hasMediaCaption ? 6 : 0))
|
||||
|
||||
if let attributedCaption = timelineItem.content.formattedCaption {
|
||||
FormattedBodyText(attributedString: attributedCaption,
|
||||
@@ -44,15 +37,32 @@ struct ImageRoomTimelineView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var source: MediaSourceProxy {
|
||||
guard timelineItem.content.contentType != .gif, let thumbnailSource = timelineItem.content.thumbnailSource else {
|
||||
return timelineItem.content.source
|
||||
@ViewBuilder
|
||||
private var loadableImage: some View {
|
||||
if timelineItem.content.contentType == .gif {
|
||||
LoadableImage(mediaSource: timelineItem.content.source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
size: timelineItem.content.size,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.thumbnailSize?.height,
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
} else {
|
||||
LoadableImage(mediaSource: timelineItem.content.thumbnailSource ?? timelineItem.content.source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
size: timelineItem.content.thumbnailSize ?? timelineItem.content.size,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.thumbnailSize?.height ?? timelineItem.content.size?.height,
|
||||
aspectRatio: timelineItem.content.thumbnailAspectRatio ?? timelineItem.content.aspectRatio)
|
||||
}
|
||||
|
||||
return thumbnailSource
|
||||
}
|
||||
|
||||
var placeholder: some View {
|
||||
|
||||
private var placeholder: some View {
|
||||
Rectangle()
|
||||
.foregroundColor(timelineItem.isOutgoing ? .compound._bgBubbleOutgoing : .compound._bgBubbleIncoming)
|
||||
.opacity(0.3)
|
||||
@@ -100,8 +110,8 @@ struct ImageRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
sender: .init(id: "Bob"),
|
||||
content: .init(filename: "Blurhashed.jpg",
|
||||
source: MediaSourceProxy(url: .picturesDirectory, mimeType: "image/gif"),
|
||||
thumbnailSource: nil,
|
||||
aspectRatio: 0.7,
|
||||
thumbnailSource: nil,
|
||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
|
||||
contentType: .gif)))
|
||||
|
||||
@@ -115,10 +125,9 @@ struct ImageRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
content: .init(filename: "Blurhashed.jpg",
|
||||
caption: "This is a great image 😎",
|
||||
source: MediaSourceProxy(url: .picturesDirectory, mimeType: "image/png"),
|
||||
thumbnailSource: nil,
|
||||
width: 50,
|
||||
height: 50,
|
||||
size: .init(width: 50, height: 50),
|
||||
aspectRatio: 1,
|
||||
thumbnailSource: nil,
|
||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
|
||||
contentType: .gif)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user