mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Fix #1369 [BUG] No option to re-hide filtered posts once they have been revealed
This commit is contained in:
parent
6bc34282e4
commit
a662406117
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user