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(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)
}

View File

@ -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
}

View File

@ -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 {