Refactor: isGIF → mediaType

This commit is contained in:
Jed Fox 2023-06-04 16:17:34 -04:00
parent 5ff25e31d3
commit 290a62aa5e
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
2 changed files with 12 additions and 6 deletions

View File

@ -8,10 +8,16 @@ import SwiftUI
struct InlineMediaOverlayContainer: View {
var altDescription: String?
var isGIF = false
var mediaType: MediaType = .image
var showDuration = false
var mediaDuration: TimeInterval?
enum MediaType {
case image
case gif
case video
}
@State private var showingAlt = false
@State private var space = AnyHashable(UUID())
@ -35,7 +41,7 @@ struct InlineMediaOverlayContainer: View {
.fixedSize(horizontal: false, vertical: true)
}
}
if isGIF {
if mediaType == .gif {
MediaBadge("GIF")
}
if showDuration {

View File

@ -112,14 +112,17 @@ extension MediaView {
switch configuration.info {
case .image(let info):
layoutImage()
overlayViewController.rootView.mediaType = .image
bindImage(configuration: configuration, info: info)
accessibilityHint = L10n.Common.Controls.Status.Media.expandImageHint
case .gif(let info):
layoutGIF()
overlayViewController.rootView.mediaType = .gif
bindGIF(configuration: configuration, info: info)
accessibilityHint = L10n.Common.Controls.Status.Media.expandGifHint
case .video(let info):
layoutVideo()
overlayViewController.rootView.mediaType = .video
bindVideo(configuration: configuration, info: info)
accessibilityHint = L10n.Common.Controls.Status.Media.expandVideoHint
}
@ -178,8 +181,6 @@ extension MediaView {
// auto play for GIF
player.play()
overlayViewController.rootView.isGIF = true
bindAlt(configuration: configuration, altDescription: info.altDescription)
}
@ -289,7 +290,6 @@ extension MediaView {
container.removeConstraints(container.constraints)
overlayViewController.rootView.altDescription = nil
overlayViewController.rootView.isGIF = false
overlayViewController.rootView.showDuration = false
overlayViewController.rootView.mediaDuration = nil