diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+Configuration.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+Configuration.swift index 0384f5deb..fe5f6d5fe 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+Configuration.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView+Configuration.swift @@ -94,34 +94,28 @@ extension StatusView { let hideAll: Bool let hideMediaOnly: Bool let explainationText: String - let canToggle: Bool switch contentDisplayMode { case .alwaysConceal: hideAll = true hideMediaOnly = false explainationText = "" - canToggle = false case .concealAll(let reason, let showAnyway): hideAll = !showAnyway hideMediaOnly = false explainationText = reason - canToggle = true case .concealMediaOnly(let showAnyway): hideAll = false hideMediaOnly = !showAnyway explainationText = "" - canToggle = true case .neverConceal: hideAll = false hideMediaOnly = false explainationText = "" - canToggle = false case .UNDETERMINED: hideAll = false hideMediaOnly = false explainationText = "" - canToggle = false } // Show/hide text @@ -135,9 +129,8 @@ extension StatusView { // eye-slash: when media display let image = contentDisplayMode.shouldConcealSomething ? UIImage(systemName: "eye.fill") : UIImage(systemName: "eye.slash.fill") authorView.contentSensitiveeToggleButton.setImage(image, for: .normal) - if canToggle { - setContentSensitiveeToggleButtonDisplay() - } + + setContentSensitiveeToggleButtonDisplay(isDisplay: contentDisplayMode.canToggleConcealed) // Set label on contentConcealView if !explainationText.isEmpty { diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift index 8a494668a..248439901 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift @@ -45,6 +45,8 @@ public protocol StatusViewDelegate: AnyObject { public final class StatusView: UIView { public struct ContentConcealViewModel { + // Treat this as a layered reveal, with the actual content at the bottom, a layer of contentWarned protection on top of it, and a layer of filtered on top of that. + // For a post that carries both, revealing content removes the filtered layer first, then the contentWarned layer. Concealing content replaces both layers at once. private let filtered: ContentDisplayMode private let contentWarned: ContentDisplayMode @@ -65,9 +67,9 @@ public final class StatusView: UIView { case .notFiltered: filtered = .neverConceal case .hide(let reason): - filtered = .concealAll(reason: filterPrefix + reason, showAnyway: status.showDespiteFilter) + filtered = .concealAll(reason: filterPrefix + reason + "\"", showAnyway: status.showDespiteFilter) case .warn(let reason): - filtered = .concealAll(reason: filterPrefix + reason, showAnyway: status.showDespiteFilter) + filtered = .concealAll(reason: filterPrefix + reason + "\"", showAnyway: status.showDespiteFilter) } } else { filtered = .neverConceal @@ -89,10 +91,20 @@ public final class StatusView: UIView { } public var effectiveDisplayMode: ContentDisplayMode { - if filtered.shouldConcealSomething { + switch (filtered.shouldConcealSomething, contentWarned.shouldConcealSomething) { + case (true, _): return filtered - } else { + case (false, true): return contentWarned + case (false, false): + switch (filtered.canToggleConcealed, contentWarned.canToggleConcealed) { + case (false, _): + return contentWarned + case (true, true): + return contentWarned + case (_, false): + return filtered + } } } @@ -171,6 +183,15 @@ public final class StatusView: UIView { } } + public var canToggleConcealed: Bool { + switch self { + case .neverConceal: return false + case .concealAll, .concealMediaOnly: return true + case .alwaysConceal: return false + case .UNDETERMINED: return false + } + } + public var shouldConcealText: Bool { switch self { case .neverConceal: return false