Refactor: isGIF → mediaType
This commit is contained in:
parent
5ff25e31d3
commit
290a62aa5e
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue