From e48260f3093ec799c6a970d555ac8770d407de2d Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 19 Feb 2023 16:03:27 +0100 Subject: [PATCH] More tweak to capture mode --- .../Row/Subviews/StatusRowContextMenu.swift | 5 ++- .../Subviews/StatusRowMediaPreviewView.swift | 43 +++++++------------ .../Row/Subviews/StatusRowTranslateView.swift | 5 ++- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift index af79a485..c81983a2 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift @@ -89,11 +89,12 @@ struct StatusRowContextMenu: View { .environmentObject(QuickLook()) .environmentObject(viewModel.client) .preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light) + .foregroundColor(Theme.shared.labelColor) .background(Theme.shared.primaryBackgroundColor) - .cornerRadius(4) - .frame(width: sceneDelegate.windowWidth) + .frame(width: sceneDelegate.windowWidth - 12) let renderer = ImageRenderer(content: view) renderer.scale = displayScale + renderer.isOpaque = false if let image = renderer.uiImage { viewModel.routerPath.presentedSheet = .shareImage(image: image, status: viewModel.status) } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift index c6d4e79a..8bde6ffb 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift @@ -214,7 +214,7 @@ public struct StatusRowMediaPreviewView: View { @ViewBuilder private func makePreview(attachment: MediaAttachment) -> some View { - if let type = attachment.supportedType { + if let type = attachment.supportedType, !isInCaptureMode { Group { GeometryReader { proxy in switch type { @@ -222,34 +222,23 @@ public struct StatusRowMediaPreviewView: View { let width = isNotifications ? imageMaxHeight : proxy.frame(in: .local).width let processors: [ImageProcessing] = [.resize(size: .init(width: width, height: imageMaxHeight))] ZStack(alignment: .bottomTrailing) { - if isInCaptureMode, - let image = Nuke.ImagePipeline.shared.cache.cachedImage(for: .init(url: attachment.previewUrl ?? attachment.url, processors: processors))?.image { - Image(uiImage: image) - .resizable() - .aspectRatio(contentMode: .fill) - .frame(maxWidth: width) - .frame(maxHeight: imageMaxHeight) - .clipped() - .cornerRadius(4) - } else { - LazyImage(url: attachment.previewUrl ?? attachment.url) { state in - if let image = state.image { - image - .resizable() - .aspectRatio(contentMode: .fill) - .frame(maxWidth: width) - .frame(maxHeight: imageMaxHeight) - .clipped() - .cornerRadius(4) - } else if state.isLoading { - RoundedRectangle(cornerRadius: 4) - .fill(Color.gray) - .frame(maxHeight: imageMaxHeight) - .frame(maxWidth: width) - } + LazyImage(url: attachment.previewUrl ?? attachment.url) { state in + if let image = state.image { + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(maxWidth: width) + .frame(maxHeight: imageMaxHeight) + .clipped() + .cornerRadius(4) + } else if state.isLoading { + RoundedRectangle(cornerRadius: 4) + .fill(Color.gray) + .frame(maxHeight: imageMaxHeight) + .frame(maxWidth: width) } - .processors(processors) } + .processors(processors) if sensitive, !isInCaptureMode { cornerSensitiveButton } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowTranslateView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowTranslateView.swift index 4eef391c..3e3185ef 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowTranslateView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowTranslateView.swift @@ -4,6 +4,8 @@ import Models import SwiftUI struct StatusRowTranslateView: View { + @Environment(\.isInCaptureMode) private var isInCaptureMode: Bool + @EnvironmentObject private var preferences: UserPreferences let status: AnyStatus @@ -24,7 +26,8 @@ struct StatusRowTranslateView: View { } var body: some View { - if let userLang = preferences.serverPreferences?.postLanguage, + if !isInCaptureMode, + let userLang = preferences.serverPreferences?.postLanguage, shouldShowTranslateButton { Button {