fix: content warning user interaction not cancel after disappear issue

This commit is contained in:
CMK 2021-06-23 22:59:39 +08:00
parent 692ca257fd
commit 4325ca3127
4 changed files with 46 additions and 40 deletions

View File

@ -7,7 +7,7 @@
<key>AppShared.xcscheme_^#shared#^_</key> <key>AppShared.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>14</integer> <integer>26</integer>
</dict> </dict>
<key>CoreDataStack.xcscheme_^#shared#^_</key> <key>CoreDataStack.xcscheme_^#shared#^_</key>
<dict> <dict>
@ -17,7 +17,7 @@
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key> <key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>1</integer>
</dict> </dict>
<key>Mastodon - RTL.xcscheme_^#shared#^_</key> <key>Mastodon - RTL.xcscheme_^#shared#^_</key>
<dict> <dict>
@ -32,12 +32,12 @@
<key>Mastodon.xcscheme_^#shared#^_</key> <key>Mastodon.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>0</integer>
</dict> </dict>
<key>NotificationService.xcscheme_^#shared#^_</key> <key>NotificationService.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>22</integer> <integer>2</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>

View File

@ -600,37 +600,37 @@ extension StatusSection {
let isSingleMosaicLayout = mosaics.count == 1 let isSingleMosaicLayout = mosaics.count == 1
// set link preview // set link preview
cell.statusView.linkPreview.isHidden = true // cell.statusView.linkPreview.isHidden = true
//
var _firstURL: URL? = { // var _firstURL: URL? = {
for entity in cell.statusView.activeTextLabel.activeEntities { // for entity in cell.statusView.activeTextLabel.activeEntities {
guard case let .url(_, _, url, _) = entity.type else { continue } // guard case let .url(_, _, url, _) = entity.type else { continue }
return URL(string: url) // return URL(string: url)
} // }
return nil // return nil
}() // }()
//
if let url = _firstURL { // if let url = _firstURL {
Future<LPLinkMetadata?, Error> { promise in // Future<LPLinkMetadata?, Error> { promise in
LPMetadataProvider().startFetchingMetadata(for: url) { meta, error in // LPMetadataProvider().startFetchingMetadata(for: url) { meta, error in
if let error = error { // if let error = error {
promise(.failure(error)) // promise(.failure(error))
} else { // } else {
promise(.success(meta)) // promise(.success(meta))
} // }
} // }
} // }
.receive(on: RunLoop.main) // .receive(on: RunLoop.main)
.sink { _ in // .sink { _ in
// do nothing // // do nothing
} receiveValue: { [weak cell] meta in // } receiveValue: { [weak cell] meta in
guard let meta = meta else { return } // guard let meta = meta else { return }
guard let cell = cell else { return } // guard let cell = cell else { return }
cell.statusView.linkPreview.metadata = meta // cell.statusView.linkPreview.metadata = meta
cell.statusView.linkPreview.isHidden = false // cell.statusView.linkPreview.isHidden = false
} // }
.store(in: &cell.disposeBag) // .store(in: &cell.disposeBag)
} // }
// set image // set image
let imageSize = CGSize( let imageSize = CGSize(

View File

@ -103,10 +103,12 @@ extension MosaicImageViewContainer {
imageViews.forEach { imageView in imageViews.forEach { imageView in
imageView.constraints.forEach { imageView.removeConstraint($0) } imageView.constraints.forEach { imageView.removeConstraint($0) }
imageView.removeFromSuperview() imageView.removeFromSuperview()
imageView.image = nil
} }
blurhashOverlayImageViews.forEach { imageView in blurhashOverlayImageViews.forEach { imageView in
imageView.constraints.forEach { imageView.removeConstraint($0) } imageView.constraints.forEach { imageView.removeConstraint($0) }
imageView.removeFromSuperview() imageView.removeFromSuperview()
imageView.image = nil
} }
contentWarningOverlayView.removeFromSuperview() contentWarningOverlayView.removeFromSuperview()

View File

@ -12,7 +12,9 @@ import AVKit
import ActiveLabel import ActiveLabel
import AlamofireImage import AlamofireImage
import FLAnimatedImage import FLAnimatedImage
import LinkPresentation
// TODO:
// import LinkPresentation
protocol StatusViewDelegate: AnyObject { protocol StatusViewDelegate: AnyObject {
func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel) func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel)
@ -205,7 +207,8 @@ final class StatusView: UIView {
var isRevealing = true var isRevealing = true
let linkPreview = LPLinkView() // TODO:
// let linkPreview = LPLinkView()
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
@ -360,9 +363,10 @@ extension StatusView {
statusContainerStackView.addArrangedSubview(activeTextLabel) statusContainerStackView.addArrangedSubview(activeTextLabel)
activeTextLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical) activeTextLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
// TODO:
// link preview // link preview
statusContainerStackView.addArrangedSubview(linkPreview) // statusContainerStackView.addArrangedSubview(linkPreview)
linkPreview.setContentHuggingPriority(.defaultHigh, for: .vertical) // linkPreview.setContentHuggingPriority(.defaultHigh, for: .vertical)
// image // image
statusContainerStackView.addArrangedSubview(statusMosaicImageViewContainer) statusContainerStackView.addArrangedSubview(statusMosaicImageViewContainer)
@ -444,6 +448,7 @@ extension StatusView {
func updateContentWarningDisplay(isHidden: Bool, animated: Bool) { func updateContentWarningDisplay(isHidden: Bool, animated: Bool) {
func updateOverlayView() { func updateOverlayView() {
contentWarningOverlayView.contentOverlayView.alpha = isHidden ? 0 : 1 contentWarningOverlayView.contentOverlayView.alpha = isHidden ? 0 : 1
contentWarningOverlayView.isUserInteractionEnabled = !isHidden
} }
if animated { if animated {
@ -456,7 +461,6 @@ extension StatusView {
} }
contentWarningOverlayView.blurContentWarningTitleLabel.isHidden = isHidden contentWarningOverlayView.blurContentWarningTitleLabel.isHidden = isHidden
contentWarningOverlayView.blurContentWarningLabel.isHidden = isHidden
} }
func updateRevealContentWarningButton(isRevealing: Bool) { func updateRevealContentWarningButton(isRevealing: Bool) {