Cleanup / fixes

This commit is contained in:
Thomas Ricouard 2023-03-03 12:41:38 +01:00
parent 82179e5f6f
commit 42c444fb03
4 changed files with 14 additions and 13 deletions

View file

@ -134,7 +134,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
func setInitialLanguageSelection(preference: String?) {
switch mode {
case let .edit(status), let .replyTo(status), let .quote(status):
case let .edit(status), let .quote(status):
selectedLanguage = status.language
default:
break

View file

@ -39,8 +39,7 @@ struct StatusRowContentView: View {
if !viewModel.finalStatus.mediaAttachments.isEmpty {
HStack {
StatusRowMediaPreviewView(attachments: viewModel.finalStatus.mediaAttachments,
sensitive: viewModel.finalStatus.sensitive,
isNotifications: isCompact)
sensitive: viewModel.finalStatus.sensitive)
if theme.statusDisplayStyle == .compact {
Spacer()
}

View file

@ -9,6 +9,7 @@ public struct StatusRowMediaPreviewView: View {
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
@Environment(\.extraLeadingInset) private var extraLeadingInset: CGFloat
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
@Environment(\.isCompact) private var isCompact: Bool
@EnvironmentObject var sceneDelegate: SceneDelegate
@EnvironmentObject private var preferences: UserPreferences
@ -17,7 +18,6 @@ public struct StatusRowMediaPreviewView: View {
public let attachments: [MediaAttachment]
public let sensitive: Bool
public let isNotifications: Bool
@State private var isQuickLookLoading: Bool = false
@State private var altTextDisplayed: String?
@ -48,7 +48,7 @@ public struct StatusRowMediaPreviewView: View {
}
private var imageMaxHeight: CGFloat {
if isNotifications {
if isCompact {
return 50
}
if theme.statusDisplayStyle == .compact {
@ -73,7 +73,7 @@ public struct StatusRowMediaPreviewView: View {
}
private func imageSize(from: CGSize, newWidth: CGFloat) -> CGSize {
if isNotifications || theme.statusDisplayStyle == .compact || isSecondaryColumn {
if isCompact || theme.statusDisplayStyle == .compact || isSecondaryColumn {
return .init(width: imageMaxHeight, height: imageMaxHeight)
}
let ratio = newWidth / from.width
@ -91,7 +91,7 @@ public struct StatusRowMediaPreviewView: View {
}
}
} else {
if isNotifications || theme.statusDisplayStyle == .compact {
if isCompact || theme.statusDisplayStyle == .compact {
HStack {
makeAttachmentView(for: 0)
makeAttachmentView(for: 1)
@ -182,7 +182,7 @@ public struct StatusRowMediaPreviewView: View {
if !isInCaptureMode, sensitive {
cornerSensitiveButton
}
if !isInCaptureMode, let alt = attachment.description, !alt.isEmpty, !isNotifications, preferences.showAltTextForMedia {
if !isInCaptureMode, let alt = attachment.description, !alt.isEmpty, !isCompact, preferences.showAltTextForMedia {
Group {
Button {
altTextDisplayed = alt
@ -208,7 +208,7 @@ public struct StatusRowMediaPreviewView: View {
GeometryReader { proxy in
switch type {
case .image:
let width = isNotifications ? imageMaxHeight : proxy.frame(in: .local).width
let width = isCompact ? imageMaxHeight : proxy.frame(in: .local).width
let processors: [ImageProcessing] = [.resize(size: .init(width: width, height: imageMaxHeight))]
ZStack(alignment: .bottomTrailing) {
LazyImage(url: attachment.previewUrl ?? attachment.url) { state in
@ -234,7 +234,7 @@ public struct StatusRowMediaPreviewView: View {
if !isInCaptureMode,
let alt = attachment.description,
!alt.isEmpty,
!isNotifications,
!isCompact,
preferences.showAltTextForMedia
{
Button {
@ -253,12 +253,12 @@ public struct StatusRowMediaPreviewView: View {
case .gifv, .video, .audio:
if let url = attachment.url {
VideoPlayerView(viewModel: .init(url: url))
.frame(width: isNotifications ? imageMaxHeight : proxy.frame(in: .local).width)
.frame(width: isCompact ? imageMaxHeight : proxy.frame(in: .local).width)
.frame(height: imageMaxHeight)
}
}
}
.frame(maxWidth: isNotifications ? imageMaxHeight : nil)
.frame(maxWidth: isCompact ? imageMaxHeight : nil)
.frame(height: imageMaxHeight)
}
// #965: do not create overlapping tappable areas, when multiple images are shown
@ -291,7 +291,7 @@ public struct StatusRowMediaPreviewView: View {
Rectangle()
.foregroundColor(.clear)
.background(.ultraThinMaterial)
if !isNotifications {
if !isCompact {
Button {
withAnimation {
isHidingMedia = false

View file

@ -5,6 +5,7 @@ import SwiftUI
struct StatusRowTranslateView: View {
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
@Environment(\.isCompact) private var isCompact: Bool
@EnvironmentObject private var preferences: UserPreferences
@ -35,6 +36,7 @@ struct StatusRowTranslateView: View {
var body: some View {
if !isInCaptureMode,
!isCompact,
let userLang = preferences.serverPreferences?.postLanguage,
shouldShowTranslateButton
{