Move “play video” image to SwiftUI, adjust to match design spec

This commit is contained in:
Jed Fox 2023-06-04 16:39:59 -04:00
parent 290a62aa5e
commit 10303eee37
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
2 changed files with 8 additions and 26 deletions

View File

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

View File

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