mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Add altDescription attribute to MediaView.Configuration values
This commit is contained in:
parent
26aff2d627
commit
c9a7405519
@ -0,0 +1,15 @@
|
||||
//
|
||||
// CGSize.swift
|
||||
//
|
||||
//
|
||||
// Created by Jed Fox on 2022-12-20.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension CGSize: Hashable {
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(width)
|
||||
hasher.combine(height)
|
||||
}
|
||||
}
|
@ -101,19 +101,16 @@ extension MediaView.Configuration {
|
||||
public struct ImageInfo: Hashable {
|
||||
public let aspectRadio: CGSize
|
||||
public let assetURL: String?
|
||||
public let altDescription: String?
|
||||
|
||||
public init(
|
||||
aspectRadio: CGSize,
|
||||
assetURL: String?
|
||||
assetURL: String?,
|
||||
altDescription: String?
|
||||
) {
|
||||
self.aspectRadio = aspectRadio
|
||||
self.assetURL = assetURL
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(aspectRadio.width)
|
||||
hasher.combine(aspectRadio.height)
|
||||
assetURL.flatMap { hasher.combine($0) }
|
||||
self.altDescription = altDescription
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,26 +118,21 @@ extension MediaView.Configuration {
|
||||
public let aspectRadio: CGSize
|
||||
public let assetURL: String?
|
||||
public let previewURL: String?
|
||||
public let altDescription: String?
|
||||
public let durationMS: Int?
|
||||
|
||||
public init(
|
||||
aspectRadio: CGSize,
|
||||
assetURL: String?,
|
||||
previewURL: String?,
|
||||
altDescription: String?,
|
||||
durationMS: Int?
|
||||
) {
|
||||
self.aspectRadio = aspectRadio
|
||||
self.assetURL = assetURL
|
||||
self.previewURL = previewURL
|
||||
self.durationMS = durationMS
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(aspectRadio.width)
|
||||
hasher.combine(aspectRadio.height)
|
||||
assetURL.flatMap { hasher.combine($0) }
|
||||
previewURL.flatMap { hasher.combine($0) }
|
||||
durationMS.flatMap { hasher.combine($0) }
|
||||
self.altDescription = altDescription
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,6 +179,7 @@ extension MediaView {
|
||||
aspectRadio: attachment.size,
|
||||
assetURL: attachment.assetURL,
|
||||
previewURL: attachment.previewURL,
|
||||
altDescription: attachment.altDescription,
|
||||
durationMS: attachment.durationMS
|
||||
)
|
||||
}
|
||||
@ -199,7 +192,8 @@ extension MediaView {
|
||||
case .image:
|
||||
let info = MediaView.Configuration.ImageInfo(
|
||||
aspectRadio: attachment.size,
|
||||
assetURL: attachment.assetURL
|
||||
assetURL: attachment.assetURL,
|
||||
altDescription: attachment.altDescription
|
||||
)
|
||||
return .init(
|
||||
info: .image(info: info),
|
||||
|
@ -189,7 +189,8 @@ extension MediaView {
|
||||
private func bindVideo(configuration: Configuration, info: Configuration.VideoInfo) {
|
||||
let imageInfo = Configuration.ImageInfo(
|
||||
aspectRadio: info.aspectRadio,
|
||||
assetURL: info.previewURL
|
||||
assetURL: info.previewURL,
|
||||
altDescription: info.altDescription
|
||||
)
|
||||
bindImage(configuration: configuration, info: imageInfo)
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ extension NewsView {
|
||||
let configuration = MediaView.Configuration(
|
||||
info: .image(info: .init(
|
||||
aspectRadio: CGSize(width: link.width, height: link.height),
|
||||
assetURL: link.image
|
||||
assetURL: link.image,
|
||||
altDescription: nil
|
||||
)),
|
||||
blurhash: link.blurhash
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user