forked from shadowfacts/Tusker
parent
7fe06d42ce
commit
5bd7c0ad2b
|
@ -52,6 +52,7 @@ class Preferences: Codable, ObservableObject {
|
|||
self.mentionReblogger = try container.decode(Bool.self, forKey: .mentionReblogger)
|
||||
|
||||
self.blurAllMedia = try container.decode(Bool.self, forKey: .blurAllMedia)
|
||||
self.blurMediaBehindContentWarning = try container.decodeIfPresent(Bool.self, forKey: .blurMediaBehindContentWarning) ?? true
|
||||
self.automaticallyPlayGifs = try container.decode(Bool.self, forKey: .automaticallyPlayGifs)
|
||||
|
||||
self.openLinksInApps = try container.decode(Bool.self, forKey: .openLinksInApps)
|
||||
|
@ -92,6 +93,7 @@ class Preferences: Codable, ObservableObject {
|
|||
try container.encode(mentionReblogger, forKey: .mentionReblogger)
|
||||
|
||||
try container.encode(blurAllMedia, forKey: .blurAllMedia)
|
||||
try container.encode(blurMediaBehindContentWarning, forKey: .blurMediaBehindContentWarning)
|
||||
try container.encode(automaticallyPlayGifs, forKey: .automaticallyPlayGifs)
|
||||
|
||||
try container.encode(openLinksInApps, forKey: .openLinksInApps)
|
||||
|
@ -131,7 +133,14 @@ class Preferences: Codable, ObservableObject {
|
|||
@Published var mentionReblogger = false
|
||||
|
||||
// MARK: Media
|
||||
@Published var blurAllMedia = false
|
||||
@Published var blurAllMedia = false {
|
||||
didSet {
|
||||
if blurAllMedia {
|
||||
blurMediaBehindContentWarning = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@Published var blurMediaBehindContentWarning = true
|
||||
@Published var automaticallyPlayGifs = true
|
||||
|
||||
// MARK: Behavior
|
||||
|
@ -174,6 +183,7 @@ class Preferences: Codable, ObservableObject {
|
|||
case mentionReblogger
|
||||
|
||||
case blurAllMedia
|
||||
case blurMediaBehindContentWarning
|
||||
case automaticallyPlayGifs
|
||||
|
||||
case openLinksInApps
|
||||
|
|
|
@ -24,6 +24,12 @@ struct MediaPrefsView: View {
|
|||
Toggle(isOn: $preferences.blurAllMedia) {
|
||||
Text("Blur All Media")
|
||||
}
|
||||
|
||||
Toggle(isOn: $preferences.blurMediaBehindContentWarning) {
|
||||
Text("Blur Media Behind Content Warning")
|
||||
}
|
||||
.disabled(preferences.blurAllMedia)
|
||||
|
||||
Toggle(isOn: $preferences.automaticallyPlayGifs) {
|
||||
Text("Automatically Play GIFs")
|
||||
}
|
||||
|
|
|
@ -236,27 +236,9 @@ class AttachmentsContainerView: UIView {
|
|||
// Make sure accessibilityElements is set every time the UI is updated, otherwise it holds
|
||||
// on to strong references to the old set of attachment views
|
||||
self.accessibilityElements = accessibilityElements
|
||||
|
||||
contentHidden = Preferences.shared.blurAllMedia || status.sensitive
|
||||
}
|
||||
|
||||
private func createAttachmentView(index: Int, hSize: RelativeSize, vSize: RelativeSize) -> AttachmentView {
|
||||
let width: CGFloat
|
||||
switch hSize {
|
||||
case .full:
|
||||
width = bounds.width
|
||||
case .half:
|
||||
width = (bounds.width - 4) / 2
|
||||
}
|
||||
let height: CGFloat
|
||||
switch vSize {
|
||||
case .full:
|
||||
height = bounds.height
|
||||
case .half:
|
||||
height = (bounds.height - 4) / 2
|
||||
}
|
||||
let size = CGSize(width: width, height: height)
|
||||
|
||||
let attachmentView = AttachmentView(attachment: attachments[index], index: index)
|
||||
attachmentView.delegate = delegate
|
||||
attachmentView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
|
@ -231,7 +231,17 @@ class BaseStatusTableViewCell: UITableViewCell {
|
|||
|
||||
func updateUIForPreferences(account: AccountMO, status: StatusMO) {
|
||||
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
|
||||
attachmentsView.contentHidden = Preferences.shared.blurAllMedia || status.sensitive
|
||||
if Preferences.shared.blurAllMedia {
|
||||
attachmentsView.contentHidden = true
|
||||
} else if status.sensitive {
|
||||
if !Preferences.shared.blurMediaBehindContentWarning && !status.spoilerText.isEmpty {
|
||||
attachmentsView.contentHidden = false
|
||||
} else {
|
||||
attachmentsView.contentHidden = true
|
||||
}
|
||||
} else {
|
||||
attachmentsView.contentHidden = false
|
||||
}
|
||||
|
||||
updateStatusIconsForPreferences(status)
|
||||
|
||||
|
|
|
@ -147,7 +147,17 @@ extension StatusCollectionViewCell {
|
|||
|
||||
func baseUpdateUIForPreferences(status: StatusMO) {
|
||||
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * Self.avatarImageViewSize
|
||||
contentContainer.attachmentsView.contentHidden = Preferences.shared.blurAllMedia || status.sensitive
|
||||
if Preferences.shared.blurAllMedia {
|
||||
contentContainer.attachmentsView.contentHidden = true
|
||||
} else if status.sensitive {
|
||||
if !Preferences.shared.blurMediaBehindContentWarning && !status.spoilerText.isEmpty {
|
||||
contentContainer.attachmentsView.contentHidden = false
|
||||
} else {
|
||||
contentContainer.attachmentsView.contentHidden = true
|
||||
}
|
||||
} else {
|
||||
contentContainer.attachmentsView.contentHidden = false
|
||||
}
|
||||
|
||||
let reblogButtonImage: UIImage
|
||||
if Preferences.shared.alwaysShowStatusVisibilityIcon || reblogEnabled(status: status) {
|
||||
|
|
Loading…
Reference in New Issue