From 10303eee379830f24b0fc59e820093ec0b237112 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 4 Jun 2023 16:39:59 -0400 Subject: [PATCH] =?UTF-8?q?Move=20=E2=80=9Cplay=20video=E2=80=9D=20image?= =?UTF-8?q?=20to=20SwiftUI,=20adjust=20to=20match=20design=20spec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/InlineMediaOverlayContainer.swift | 8 ++++++ .../MastodonUI/View/Content/MediaView.swift | 26 ------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/InlineMediaOverlayContainer.swift b/MastodonSDK/Sources/MastodonUI/View/Content/InlineMediaOverlayContainer.swift index 2d333776c..17e1d48e2 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/InlineMediaOverlayContainer.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/InlineMediaOverlayContainer.swift @@ -58,6 +58,14 @@ struct InlineMediaOverlayContainer: View { } .padding(.horizontal, 16) .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 showingAlt = false } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift index 5a7ec58a1..6155b0da5 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift @@ -51,21 +51,6 @@ public final class MediaView: UIView { }() 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 = { let vc = UIHostingController(rootView: InlineMediaOverlayContainer()) vc.view.backgroundColor = .clear @@ -186,15 +171,6 @@ extension MediaView { private func layoutVideo() { 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) { @@ -278,8 +254,6 @@ extension MediaView { playerViewController.player = nil playerLooper = nil - playbackImageView.removeFromSuperview() - // blurhash blurhashImageView.removeFromSuperview() blurhashImageView.removeConstraints(blurhashImageView.constraints)