More tweak to capture mode

This commit is contained in:
Thomas Ricouard 2023-02-19 16:03:27 +01:00
parent a965386a1e
commit e48260f309
3 changed files with 23 additions and 30 deletions

View file

@ -89,11 +89,12 @@ struct StatusRowContextMenu: View {
.environmentObject(QuickLook()) .environmentObject(QuickLook())
.environmentObject(viewModel.client) .environmentObject(viewModel.client)
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light) .preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
.foregroundColor(Theme.shared.labelColor)
.background(Theme.shared.primaryBackgroundColor) .background(Theme.shared.primaryBackgroundColor)
.cornerRadius(4) .frame(width: sceneDelegate.windowWidth - 12)
.frame(width: sceneDelegate.windowWidth)
let renderer = ImageRenderer(content: view) let renderer = ImageRenderer(content: view)
renderer.scale = displayScale renderer.scale = displayScale
renderer.isOpaque = false
if let image = renderer.uiImage { if let image = renderer.uiImage {
viewModel.routerPath.presentedSheet = .shareImage(image: image, status: viewModel.status) viewModel.routerPath.presentedSheet = .shareImage(image: image, status: viewModel.status)
} }

View file

@ -214,7 +214,7 @@ public struct StatusRowMediaPreviewView: View {
@ViewBuilder @ViewBuilder
private func makePreview(attachment: MediaAttachment) -> some View { private func makePreview(attachment: MediaAttachment) -> some View {
if let type = attachment.supportedType { if let type = attachment.supportedType, !isInCaptureMode {
Group { Group {
GeometryReader { proxy in GeometryReader { proxy in
switch type { switch type {
@ -222,16 +222,6 @@ public struct StatusRowMediaPreviewView: View {
let width = isNotifications ? imageMaxHeight : proxy.frame(in: .local).width let width = isNotifications ? imageMaxHeight : proxy.frame(in: .local).width
let processors: [ImageProcessing] = [.resize(size: .init(width: width, height: imageMaxHeight))] let processors: [ImageProcessing] = [.resize(size: .init(width: width, height: imageMaxHeight))]
ZStack(alignment: .bottomTrailing) { 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 LazyImage(url: attachment.previewUrl ?? attachment.url) { state in
if let image = state.image { if let image = state.image {
image image
@ -249,7 +239,6 @@ public struct StatusRowMediaPreviewView: View {
} }
} }
.processors(processors) .processors(processors)
}
if sensitive, !isInCaptureMode { if sensitive, !isInCaptureMode {
cornerSensitiveButton cornerSensitiveButton
} }

View file

@ -4,6 +4,8 @@ import Models
import SwiftUI import SwiftUI
struct StatusRowTranslateView: View { struct StatusRowTranslateView: View {
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
@EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var preferences: UserPreferences
let status: AnyStatus let status: AnyStatus
@ -24,7 +26,8 @@ struct StatusRowTranslateView: View {
} }
var body: some View { var body: some View {
if let userLang = preferences.serverPreferences?.postLanguage, if !isInCaptureMode,
let userLang = preferences.serverPreferences?.postLanguage,
shouldShowTranslateButton shouldShowTranslateButton
{ {
Button { Button {