chore: handle Video&Gif sensitive situation

This commit is contained in:
sunxiaojian 2021-03-11 15:34:30 +08:00
parent 6b9ae8d05d
commit 1342471c5d
4 changed files with 31 additions and 16 deletions

View File

@ -192,8 +192,10 @@ extension StatusSection {
let scale: CGFloat = 1.3
return CGSize(width: maxWidth, height: maxWidth * scale)
}()
cell.statusView.mosaicPlayerView.mosaicView.blurVisualEffectView.effect = isStatusSensitive ? MosaicImageViewContainer.blurVisualEffect : nil
cell.statusView.mosaicPlayerView.mosaicView.vibrancyVisualEffectView.alpha = isStatusSensitive ? 1.0 : 0.0
cell.statusView.mosaicPlayerView.mosaicView.isUserInteractionEnabled = isStatusSensitive
cell.statusView.mosaicPlayerView.mosaicView.mosaicButton.publisher(for: .touchUpInside)
.sink { [weak cell] _ in
guard let cell = cell else { return }

View File

@ -57,7 +57,7 @@ extension StatusTableViewCellDelegate where Self: StatusProvider {
default:
return
}
mosaicView.isUserInteractionEnabled = false
var snapshot = diffableDataSource.snapshot()
snapshot.reloadItems([item])
UIView.animate(withDuration: 0.33) {

View File

@ -43,14 +43,6 @@ final class MosaicPlayerView: UIView {
extension MosaicPlayerView {
private func _init() {
addSubview(mosaicView)
NSLayoutConstraint.activate([
mosaicView.topAnchor.constraint(equalTo: topAnchor),
mosaicView.leadingAnchor.constraint(equalTo: leadingAnchor),
mosaicView.trailingAnchor.constraint(equalTo: trailingAnchor),
mosaicView.bottomAnchor.constraint(equalTo: bottomAnchor)
])
container.translatesAutoresizingMaskIntoConstraints = false
addSubview(container)
containerHeightLayoutConstraint = container.heightAnchor.constraint(equalToConstant: 162).priority(.required - 1)
@ -74,6 +66,14 @@ extension MosaicPlayerView {
playerViewController.view.layer.masksToBounds = true
playerViewController.view.layer.cornerRadius = MosaicPlayerView.cornerRadius
playerViewController.view.layer.cornerCurve = .continuous
addSubview(mosaicView)
NSLayoutConstraint.activate([
mosaicView.topAnchor.constraint(equalTo: topAnchor),
mosaicView.leadingAnchor.constraint(equalTo: leadingAnchor),
mosaicView.trailingAnchor.constraint(equalTo: trailingAnchor),
mosaicView.bottomAnchor.constraint(equalTo: bottomAnchor)
])
}
}

View File

@ -17,6 +17,7 @@ class MosaicView: UIView {
let mosaicButton: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = .clear
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
@ -41,14 +42,9 @@ class MosaicView: UIView {
extension MosaicView {
private func _init() {
backgroundColor = .clear
translatesAutoresizingMaskIntoConstraints = false
addSubview(mosaicButton)
NSLayoutConstraint.activate([
mosaicButton.topAnchor.constraint(equalTo: topAnchor),
mosaicButton.trailingAnchor.constraint(equalTo: trailingAnchor),
mosaicButton.bottomAnchor.constraint(equalTo: bottomAnchor),
mosaicButton.leadingAnchor.constraint(equalTo: leadingAnchor),
])
// add blur visual effect view in the setup method
blurVisualEffectView.layer.masksToBounds = true
blurVisualEffectView.layer.cornerRadius = MosaicView.cornerRadius
@ -70,5 +66,22 @@ extension MosaicView {
contentWarningLabel.trailingAnchor.constraint(equalTo: vibrancyVisualEffectView.contentView.layoutMarginsGuide.trailingAnchor),
contentWarningLabel.centerYAnchor.constraint(equalTo: vibrancyVisualEffectView.contentView.centerYAnchor),
])
blurVisualEffectView.translatesAutoresizingMaskIntoConstraints = false
addSubview(blurVisualEffectView)
NSLayoutConstraint.activate([
blurVisualEffectView.topAnchor.constraint(equalTo: topAnchor),
blurVisualEffectView.leadingAnchor.constraint(equalTo: leadingAnchor),
blurVisualEffectView.trailingAnchor.constraint(equalTo: trailingAnchor),
blurVisualEffectView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
addSubview(mosaicButton)
NSLayoutConstraint.activate([
mosaicButton.topAnchor.constraint(equalTo: topAnchor),
mosaicButton.trailingAnchor.constraint(equalTo: trailingAnchor),
mosaicButton.bottomAnchor.constraint(equalTo: bottomAnchor),
mosaicButton.leadingAnchor.constraint(equalTo: leadingAnchor),
])
}
}