From e3c6aaf64e073ed489b4a50c0633c98407d95326 Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 16 Apr 2021 20:29:08 +0800 Subject: [PATCH] fix: blurhash image render issue --- .../xcschemes/xcschememanagement.plist | 2 +- Mastodon/Diffiable/Section/StatusSection.swift | 15 ++++++++++----- .../Scene/Share/View/Content/StatusView.swift | 17 +++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index c25eac1f..6ec23cf5 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ CoreDataStack.xcscheme_^#shared#^_ orderHint - 11 + 10 Mastodon - RTL.xcscheme_^#shared#^_ diff --git a/Mastodon/Diffiable/Section/StatusSection.swift b/Mastodon/Diffiable/Section/StatusSection.swift index f2b3059c..fc7b02c2 100644 --- a/Mastodon/Diffiable/Section/StatusSection.swift +++ b/Mastodon/Diffiable/Section/StatusSection.swift @@ -245,11 +245,16 @@ extension StatusSection { return } - let animator = UIViewPropertyAnimator(duration: 0.33, curve: .easeInOut) - animator.addAnimations { - blurhashOverlayImageView.alpha = isMediaRevealing ? 0 : 1 + blurhashOverlayImageView.alpha = isMediaRevealing ? 0 : 1 + if isMediaRevealing { + let animator = UIViewPropertyAnimator(duration: 0.33, curve: .easeInOut) + animator.addAnimations { + blurhashOverlayImageView.alpha = isMediaRevealing ? 0 : 1 + } + animator.startAnimation() + } else { + cell.statusView.drawContentWarningImageView() } - animator.startAnimation() } .store(in: &cell.disposeBag) } @@ -406,7 +411,7 @@ extension StatusSection { animated: Bool ) { statusView.contentWarningOverlayView.blurContentWarningTitleLabel.text = { - let spoilerText = status.spoilerText ?? "" + let spoilerText = (status.reblog ?? status).spoilerText ?? "" if spoilerText.isEmpty { return L10n.Common.Controls.Status.contentWarning } else { diff --git a/Mastodon/Scene/Share/View/Content/StatusView.swift b/Mastodon/Scene/Share/View/Content/StatusView.swift index 2b0294fe..a58ad124 100644 --- a/Mastodon/Scene/Share/View/Content/StatusView.swift +++ b/Mastodon/Scene/Share/View/Content/StatusView.swift @@ -416,13 +416,6 @@ extension StatusView { format.opaque = false let image = UIGraphicsImageRenderer(size: statusContainerStackView.frame.size, format: format).image { context in statusContainerStackView.drawHierarchy(in: statusContainerStackView.bounds, afterScreenUpdates: true) - - // always draw the blurhash image - statusMosaicImageViewContainer.blurhashOverlayImageViews.forEach { imageView in - guard let image = imageView.image else { return } - guard let frame = imageView.superview?.convert(imageView.frame, to: statusContainerStackView) else { return } - image.draw(in: frame) - } } .blur(radius: StatusView.contentWarningBlurRadius) contentWarningOverlayView.blurContentImageView.contentScaleFactor = traitCollection.displayScale @@ -431,6 +424,11 @@ extension StatusView { func updateContentWarningDisplay(isHidden: Bool, animated: Bool) { needsDrawContentOverlay = !isHidden + + if !isHidden { + drawContentWarningImageView() + } + if animated { UIView.animate(withDuration: 0.33, delay: 0, options: .curveEaseInOut) { [weak self] in guard let self = self else { return } @@ -442,9 +440,8 @@ extension StatusView { contentWarningOverlayView.alpha = isHidden ? 0 : 1 } - if !isHidden { - drawContentWarningImageView() - } + contentWarningOverlayView.blurContentWarningTitleLabel.isHidden = isHidden + contentWarningOverlayView.blurContentWarningLabel.isHidden = isHidden } func updateRevealContentWarningButton(isRevealing: Bool) {