Rename: MediaBadgesContainer → InlineMediaOverlayContainer
This commit is contained in:
parent
8804432b60
commit
5ff25e31d3
|
@ -1,12 +1,12 @@
|
|||
//
|
||||
// MediaBadgesContainer.swift
|
||||
// InlineMediaOverlayContainer.swift
|
||||
//
|
||||
// Created by Jed Fox on 2022-12-20.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MediaBadgesContainer: View {
|
||||
struct InlineMediaOverlayContainer: View {
|
||||
var altDescription: String?
|
||||
var isGIF = false
|
||||
var showDuration = false
|
||||
|
@ -60,7 +60,7 @@ struct MediaBadgesContainer: View {
|
|||
|
||||
struct MediaAltTextOverlay_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MediaBadgesContainer(altDescription: "Hello, world!")
|
||||
InlineMediaOverlayContainer(altDescription: "Hello, world!")
|
||||
.frame(height: 300)
|
||||
.background(Color.gray)
|
||||
.previewLayout(.sizeThatFits)
|
|
@ -66,8 +66,8 @@ public final class MediaView: UIView {
|
|||
return wrapper
|
||||
}()
|
||||
|
||||
let badgeViewController: UIHostingController<MediaBadgesContainer> = {
|
||||
let vc = UIHostingController(rootView: MediaBadgesContainer())
|
||||
let overlayViewController: UIHostingController<InlineMediaOverlayContainer> = {
|
||||
let vc = UIHostingController(rootView: InlineMediaOverlayContainer())
|
||||
vc.view.backgroundColor = .clear
|
||||
return vc
|
||||
}()
|
||||
|
@ -167,8 +167,8 @@ extension MediaView {
|
|||
}
|
||||
|
||||
private func bindGIF(configuration: Configuration, info: Configuration.VideoInfo) {
|
||||
badgeViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
|
||||
badgeViewController.rootView.showDuration = false
|
||||
overlayViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
|
||||
overlayViewController.rootView.showDuration = false
|
||||
|
||||
guard let player = setupGIFPlayer(info: info) else { return }
|
||||
setupPlayerLooper(player: player)
|
||||
|
@ -178,7 +178,7 @@ extension MediaView {
|
|||
// auto play for GIF
|
||||
player.play()
|
||||
|
||||
badgeViewController.rootView.isGIF = true
|
||||
overlayViewController.rootView.isGIF = true
|
||||
|
||||
bindAlt(configuration: configuration, altDescription: info.altDescription)
|
||||
}
|
||||
|
@ -197,8 +197,8 @@ extension MediaView {
|
|||
}
|
||||
|
||||
private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) {
|
||||
badgeViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
|
||||
badgeViewController.rootView.showDuration = true
|
||||
overlayViewController.rootView.mediaDuration = info.durationMS.map { Double($0) / 1000 }
|
||||
overlayViewController.rootView.showDuration = true
|
||||
|
||||
let imageInfo = Configuration.ImageInfo(
|
||||
aspectRadio: info.aspectRadio,
|
||||
|
@ -219,7 +219,7 @@ extension MediaView {
|
|||
accessibilityLabel = altDescription
|
||||
}
|
||||
|
||||
badgeViewController.rootView.altDescription = altDescription
|
||||
overlayViewController.rootView.altDescription = altDescription
|
||||
}
|
||||
|
||||
private func layoutBlurhash() {
|
||||
|
@ -251,9 +251,9 @@ extension MediaView {
|
|||
}
|
||||
|
||||
private func layoutAlt() {
|
||||
badgeViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
container.addSubview(badgeViewController.view)
|
||||
badgeViewController.view.pinToParent()
|
||||
overlayViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
container.addSubview(overlayViewController.view)
|
||||
overlayViewController.view.pinToParent()
|
||||
}
|
||||
|
||||
public func prepareForReuse() {
|
||||
|
@ -288,10 +288,10 @@ extension MediaView {
|
|||
container.removeFromSuperview()
|
||||
container.removeConstraints(container.constraints)
|
||||
|
||||
badgeViewController.rootView.altDescription = nil
|
||||
badgeViewController.rootView.isGIF = false
|
||||
badgeViewController.rootView.showDuration = false
|
||||
badgeViewController.rootView.mediaDuration = nil
|
||||
overlayViewController.rootView.altDescription = nil
|
||||
overlayViewController.rootView.isGIF = false
|
||||
overlayViewController.rootView.showDuration = false
|
||||
overlayViewController.rootView.mediaDuration = nil
|
||||
|
||||
// reset configuration
|
||||
configuration = nil
|
||||
|
|
Loading…
Reference in New Issue