Remove capture mode for images (#996)
* Remove capture mode for images * Simplify how processor is created in StatusRowMediaPreviewView * Optimize StatusViewId further
This commit is contained in:
parent
678f6f0cdd
commit
37a69650ef
|
@ -4,7 +4,6 @@ import Shimmer
|
|||
import SwiftUI
|
||||
|
||||
public struct AvatarView: View {
|
||||
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
|
||||
@Environment(\.redactionReasons) private var reasons
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
|
@ -56,24 +55,17 @@ public struct AvatarView: View {
|
|||
.fill(.gray)
|
||||
.frame(width: size.size.width, height: size.size.height)
|
||||
} else {
|
||||
if isInCaptureMode, let url = url, let image = Nuke.ImagePipeline.shared.cache.cachedImage(for: makeImageRequest(for: url))?.image {
|
||||
Image(uiImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: size.size.width, height: size.size.height)
|
||||
} else {
|
||||
LazyImage(request: url.map(makeImageRequest)) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
} else {
|
||||
AvatarPlaceholderView(size: size)
|
||||
}
|
||||
LazyImage(request: url.map(makeImageRequest)) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
} else {
|
||||
AvatarPlaceholderView(size: size)
|
||||
}
|
||||
.animation(nil)
|
||||
.frame(width: size.size.width, height: size.size.height)
|
||||
}
|
||||
.animation(nil)
|
||||
.frame(width: size.size.width, height: size.size.height)
|
||||
}
|
||||
}
|
||||
.clipShape(clipShape)
|
||||
|
|
|
@ -57,12 +57,12 @@ public protocol AnyStatus {
|
|||
|
||||
public struct StatusViewId: Hashable {
|
||||
let id: String
|
||||
let editedAt: ServerDate?
|
||||
let editedAt: Date?
|
||||
}
|
||||
|
||||
public extension AnyStatus {
|
||||
var viewId: StatusViewId {
|
||||
StatusViewId(id: id, editedAt: editedAt)
|
||||
StatusViewId(id: id, editedAt: editedAt?.asDate)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public struct StatusRowMediaPreviewView: View {
|
|||
public let isNotifications: Bool
|
||||
|
||||
@State private var isQuickLookLoading: Bool = false
|
||||
@State private var width: CGFloat = 0
|
||||
@State private var altTextDisplayed: String?
|
||||
@State private var isAltAlertDisplayed: Bool = false
|
||||
@State private var isHidingMedia: Bool = false
|
||||
|
@ -155,39 +154,25 @@ public struct StatusRowMediaPreviewView: View {
|
|||
private func makeFeaturedImagePreview(attachment: MediaAttachment) -> some View {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
let size: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
||||
let newSize = imageSize(from: size,
|
||||
newWidth: availableWidth - appLayoutWidth)
|
||||
let processors: [ImageProcessing] = [.resize(size: .init(width: newSize.width, height: newSize.height))]
|
||||
let newSize = imageSize(from: size, newWidth: availableWidth - appLayoutWidth)
|
||||
switch attachment.supportedType {
|
||||
case .image:
|
||||
if isInCaptureMode,
|
||||
let image = Nuke.ImagePipeline.shared.cache.cachedImage(for: .init(url: attachment.url,
|
||||
processors: processors))?.image
|
||||
{
|
||||
Image(uiImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
.clipped()
|
||||
.cornerRadius(4)
|
||||
} else {
|
||||
LazyImage(url: attachment.url) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
.clipped()
|
||||
.cornerRadius(4)
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.fill(Color.gray)
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
}
|
||||
LazyImage(url: attachment.url) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
.clipped()
|
||||
.cornerRadius(4)
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.fill(Color.gray)
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
}
|
||||
.processors([.resize(size: .init(width: newSize.width, height: newSize.height))])
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
}
|
||||
.processors([.resize(size: newSize)])
|
||||
.frame(width: newSize.width, height: newSize.height)
|
||||
|
||||
case .gifv, .video, .audio:
|
||||
if let url = attachment.url {
|
||||
|
|
Loading…
Reference in New Issue