Move “play video” image to SwiftUI, adjust to match design spec
This commit is contained in:
parent
290a62aa5e
commit
10303eee37
|
@ -58,6 +58,14 @@ struct InlineMediaOverlayContainer: View {
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
|
.overlay {
|
||||||
|
if mediaType == .video {
|
||||||
|
Image(systemName: "play.circle.fill")
|
||||||
|
.font(.system(size: 54))
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.shadow(color: .black.opacity(0.5), radius: 32, x: 0, y: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
.onChange(of: altDescription) { _ in
|
.onChange(of: altDescription) { _ in
|
||||||
showingAlt = false
|
showingAlt = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,21 +51,6 @@ public final class MediaView: UIView {
|
||||||
}()
|
}()
|
||||||
private var playerLooper: AVPlayerLooper?
|
private var playerLooper: AVPlayerLooper?
|
||||||
|
|
||||||
private(set) lazy var playbackImageView: UIView = {
|
|
||||||
let wrapper = UIView()
|
|
||||||
|
|
||||||
let imageView = UIImageView()
|
|
||||||
imageView.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
imageView.image = UIImage(systemName: "play.circle.fill")
|
|
||||||
imageView.tintColor = Asset.Colors.Label.primary.color
|
|
||||||
wrapper.addSubview(imageView)
|
|
||||||
imageView.pinToParent(padding: .init(top: 8, left: 8, bottom: 8, right: 8))
|
|
||||||
wrapper.backgroundColor = Asset.Theme.Mastodon.systemBackground.color.withAlphaComponent(0.8)
|
|
||||||
wrapper.applyCornerRadius(radius: 8)
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
}()
|
|
||||||
|
|
||||||
let overlayViewController: UIHostingController<InlineMediaOverlayContainer> = {
|
let overlayViewController: UIHostingController<InlineMediaOverlayContainer> = {
|
||||||
let vc = UIHostingController(rootView: InlineMediaOverlayContainer())
|
let vc = UIHostingController(rootView: InlineMediaOverlayContainer())
|
||||||
vc.view.backgroundColor = .clear
|
vc.view.backgroundColor = .clear
|
||||||
|
@ -186,15 +171,6 @@ extension MediaView {
|
||||||
|
|
||||||
private func layoutVideo() {
|
private func layoutVideo() {
|
||||||
layoutImage()
|
layoutImage()
|
||||||
|
|
||||||
playbackImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
container.addSubview(playbackImageView)
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
playbackImageView.centerXAnchor.constraint(equalTo: container.centerXAnchor),
|
|
||||||
playbackImageView.centerYAnchor.constraint(equalTo: container.centerYAnchor),
|
|
||||||
playbackImageView.widthAnchor.constraint(equalToConstant: 88).priority(.required - 1),
|
|
||||||
playbackImageView.heightAnchor.constraint(equalToConstant: 88).priority(.required - 1),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) {
|
private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) {
|
||||||
|
@ -278,8 +254,6 @@ extension MediaView {
|
||||||
playerViewController.player = nil
|
playerViewController.player = nil
|
||||||
playerLooper = nil
|
playerLooper = nil
|
||||||
|
|
||||||
playbackImageView.removeFromSuperview()
|
|
||||||
|
|
||||||
// blurhash
|
// blurhash
|
||||||
blurhashImageView.removeFromSuperview()
|
blurhashImageView.removeFromSuperview()
|
||||||
blurhashImageView.removeConstraints(blurhashImageView.constraints)
|
blurhashImageView.removeConstraints(blurhashImageView.constraints)
|
||||||
|
|
Loading…
Reference in New Issue