fix: blurhash image render issue

This commit is contained in:
CMK 2021-04-16 20:29:08 +08:00
parent 680cf9a827
commit e3c6aaf64e
3 changed files with 18 additions and 16 deletions

View File

@ -7,7 +7,7 @@
<key>CoreDataStack.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>11</integer>
<integer>10</integer>
</dict>
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
<dict>

View File

@ -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 {

View File

@ -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) {