From 4325ca3127fe02f381fba42d16e1a2d5a99c3781 Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 23 Jun 2021 22:59:39 +0800 Subject: [PATCH] fix: content warning user interaction not cancel after disappear issue --- .../xcschemes/xcschememanagement.plist | 8 +-- .../Diffiable/Section/StatusSection.swift | 62 +++++++++---------- .../Container/MosaicImageViewContainer.swift | 2 + .../Scene/Share/View/Content/StatusView.swift | 14 +++-- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index 5bf05338..fd0e14aa 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ AppShared.xcscheme_^#shared#^_ orderHint - 14 + 26 CoreDataStack.xcscheme_^#shared#^_ @@ -17,7 +17,7 @@ Mastodon - ASDK.xcscheme_^#shared#^_ orderHint - 4 + 1 Mastodon - RTL.xcscheme_^#shared#^_ @@ -32,12 +32,12 @@ Mastodon.xcscheme_^#shared#^_ orderHint - 2 + 0 NotificationService.xcscheme_^#shared#^_ orderHint - 22 + 2 SuppressBuildableAutocreation diff --git a/Mastodon/Diffiable/Section/StatusSection.swift b/Mastodon/Diffiable/Section/StatusSection.swift index 28901bc2..672022b1 100644 --- a/Mastodon/Diffiable/Section/StatusSection.swift +++ b/Mastodon/Diffiable/Section/StatusSection.swift @@ -600,37 +600,37 @@ extension StatusSection { let isSingleMosaicLayout = mosaics.count == 1 // set link preview - cell.statusView.linkPreview.isHidden = true - - var _firstURL: URL? = { - for entity in cell.statusView.activeTextLabel.activeEntities { - guard case let .url(_, _, url, _) = entity.type else { continue } - return URL(string: url) - } - return nil - }() - - if let url = _firstURL { - Future { promise in - LPMetadataProvider().startFetchingMetadata(for: url) { meta, error in - if let error = error { - promise(.failure(error)) - } else { - promise(.success(meta)) - } - } - } - .receive(on: RunLoop.main) - .sink { _ in - // do nothing - } receiveValue: { [weak cell] meta in - guard let meta = meta else { return } - guard let cell = cell else { return } - cell.statusView.linkPreview.metadata = meta - cell.statusView.linkPreview.isHidden = false - } - .store(in: &cell.disposeBag) - } +// cell.statusView.linkPreview.isHidden = true +// +// var _firstURL: URL? = { +// for entity in cell.statusView.activeTextLabel.activeEntities { +// guard case let .url(_, _, url, _) = entity.type else { continue } +// return URL(string: url) +// } +// return nil +// }() +// +// if let url = _firstURL { +// Future { promise in +// LPMetadataProvider().startFetchingMetadata(for: url) { meta, error in +// if let error = error { +// promise(.failure(error)) +// } else { +// promise(.success(meta)) +// } +// } +// } +// .receive(on: RunLoop.main) +// .sink { _ in +// // do nothing +// } receiveValue: { [weak cell] meta in +// guard let meta = meta else { return } +// guard let cell = cell else { return } +// cell.statusView.linkPreview.metadata = meta +// cell.statusView.linkPreview.isHidden = false +// } +// .store(in: &cell.disposeBag) +// } // set image let imageSize = CGSize( diff --git a/Mastodon/Scene/Share/View/Container/MosaicImageViewContainer.swift b/Mastodon/Scene/Share/View/Container/MosaicImageViewContainer.swift index 73f2fe3d..f6ea1edf 100644 --- a/Mastodon/Scene/Share/View/Container/MosaicImageViewContainer.swift +++ b/Mastodon/Scene/Share/View/Container/MosaicImageViewContainer.swift @@ -103,10 +103,12 @@ extension MosaicImageViewContainer { imageViews.forEach { imageView in imageView.constraints.forEach { imageView.removeConstraint($0) } imageView.removeFromSuperview() + imageView.image = nil } blurhashOverlayImageViews.forEach { imageView in imageView.constraints.forEach { imageView.removeConstraint($0) } imageView.removeFromSuperview() + imageView.image = nil } contentWarningOverlayView.removeFromSuperview() diff --git a/Mastodon/Scene/Share/View/Content/StatusView.swift b/Mastodon/Scene/Share/View/Content/StatusView.swift index b0dfd684..ef037e84 100644 --- a/Mastodon/Scene/Share/View/Content/StatusView.swift +++ b/Mastodon/Scene/Share/View/Content/StatusView.swift @@ -12,7 +12,9 @@ import AVKit import ActiveLabel import AlamofireImage import FLAnimatedImage -import LinkPresentation + +// TODO: +// import LinkPresentation protocol StatusViewDelegate: AnyObject { func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel) @@ -205,7 +207,8 @@ final class StatusView: UIView { var isRevealing = true - let linkPreview = LPLinkView() + // TODO: + // let linkPreview = LPLinkView() override init(frame: CGRect) { super.init(frame: frame) @@ -360,9 +363,10 @@ extension StatusView { statusContainerStackView.addArrangedSubview(activeTextLabel) activeTextLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical) + // TODO: // link preview - statusContainerStackView.addArrangedSubview(linkPreview) - linkPreview.setContentHuggingPriority(.defaultHigh, for: .vertical) + // statusContainerStackView.addArrangedSubview(linkPreview) + // linkPreview.setContentHuggingPriority(.defaultHigh, for: .vertical) // image statusContainerStackView.addArrangedSubview(statusMosaicImageViewContainer) @@ -444,6 +448,7 @@ extension StatusView { func updateContentWarningDisplay(isHidden: Bool, animated: Bool) { func updateOverlayView() { contentWarningOverlayView.contentOverlayView.alpha = isHidden ? 0 : 1 + contentWarningOverlayView.isUserInteractionEnabled = !isHidden } if animated { @@ -456,7 +461,6 @@ extension StatusView { } contentWarningOverlayView.blurContentWarningTitleLabel.isHidden = isHidden - contentWarningOverlayView.blurContentWarningLabel.isHidden = isHidden } func updateRevealContentWarningButton(isRevealing: Bool) {