Rename: MediaBadgesContainer → InlineMediaOverlayContainer

This commit is contained in:
Jed Fox 2023-06-04 16:15:05 -04:00
parent 8804432b60
commit 5ff25e31d3
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
2 changed files with 18 additions and 18 deletions

View File

@ -1,12 +1,12 @@
// //
// MediaBadgesContainer.swift // InlineMediaOverlayContainer.swift
// //
// Created by Jed Fox on 2022-12-20. // Created by Jed Fox on 2022-12-20.
// //
import SwiftUI import SwiftUI
struct MediaBadgesContainer: View { struct InlineMediaOverlayContainer: View {
var altDescription: String? var altDescription: String?
var isGIF = false var isGIF = false
var showDuration = false var showDuration = false
@ -60,7 +60,7 @@ struct MediaBadgesContainer: View {
struct MediaAltTextOverlay_Previews: PreviewProvider { struct MediaAltTextOverlay_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
MediaBadgesContainer(altDescription: "Hello, world!") InlineMediaOverlayContainer(altDescription: "Hello, world!")
.frame(height: 300) .frame(height: 300)
.background(Color.gray) .background(Color.gray)
.previewLayout(.sizeThatFits) .previewLayout(.sizeThatFits)

View File

@ -66,8 +66,8 @@ public final class MediaView: UIView {
return wrapper return wrapper
}() }()
let badgeViewController: UIHostingController<MediaBadgesContainer> = { let overlayViewController: UIHostingController<InlineMediaOverlayContainer> = {
let vc = UIHostingController(rootView: MediaBadgesContainer()) let vc = UIHostingController(rootView: InlineMediaOverlayContainer())
vc.view.backgroundColor = .clear vc.view.backgroundColor = .clear
return vc return vc
}() }()
@ -167,8 +167,8 @@ extension MediaView {
} }
private func bindGIF(configuration: Configuration, info: Configuration.VideoInfo) { private func bindGIF(configuration: Configuration, info: Configuration.VideoInfo) {
badgeViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 } overlayViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
badgeViewController.rootView.showDuration = false overlayViewController.rootView.showDuration = false
guard let player = setupGIFPlayer(info: info) else { return } guard let player = setupGIFPlayer(info: info) else { return }
setupPlayerLooper(player: player) setupPlayerLooper(player: player)
@ -178,7 +178,7 @@ extension MediaView {
// auto play for GIF // auto play for GIF
player.play() player.play()
badgeViewController.rootView.isGIF = true overlayViewController.rootView.isGIF = true
bindAlt(configuration: configuration, altDescription: info.altDescription) bindAlt(configuration: configuration, altDescription: info.altDescription)
} }
@ -197,8 +197,8 @@ extension MediaView {
} }
private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) { private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) {
badgeViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 } overlayViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
badgeViewController.rootView.showDuration = true overlayViewController.rootView.showDuration = true
let imageInfo = Configuration.ImageInfo( let imageInfo = Configuration.ImageInfo(
aspectRadio: info.aspectRadio, aspectRadio: info.aspectRadio,
@ -219,7 +219,7 @@ extension MediaView {
accessibilityLabel = altDescription accessibilityLabel = altDescription
} }
badgeViewController.rootView.altDescription = altDescription overlayViewController.rootView.altDescription = altDescription
} }
private func layoutBlurhash() { private func layoutBlurhash() {
@ -251,9 +251,9 @@ extension MediaView {
} }
private func layoutAlt() { private func layoutAlt() {
badgeViewController.view.translatesAutoresizingMaskIntoConstraints = false overlayViewController.view.translatesAutoresizingMaskIntoConstraints = false
container.addSubview(badgeViewController.view) container.addSubview(overlayViewController.view)
badgeViewController.view.pinToParent() overlayViewController.view.pinToParent()
} }
public func prepareForReuse() { public func prepareForReuse() {
@ -288,10 +288,10 @@ extension MediaView {
container.removeFromSuperview() container.removeFromSuperview()
container.removeConstraints(container.constraints) container.removeConstraints(container.constraints)
badgeViewController.rootView.altDescription = nil overlayViewController.rootView.altDescription = nil
badgeViewController.rootView.isGIF = false overlayViewController.rootView.isGIF = false
badgeViewController.rootView.showDuration = false overlayViewController.rootView.showDuration = false
badgeViewController.rootView.mediaDuration = nil overlayViewController.rootView.mediaDuration = nil
// reset configuration // reset configuration
configuration = nil configuration = nil