1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-20 14:32:48 +01:00
metatext-app-ios-iphone-ipad/View Models/AttachmentViewModel.swift
Justin Mazzocchi 9b59e2fbea
wip
2020-08-30 16:33:32 -07:00

30 lines
637 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
import Mastodon
struct AttachmentViewModel {
let attachment: Attachment
init(attachment: Attachment) {
self.attachment = attachment
}
}
extension AttachmentViewModel {
var aspectRatio: Double? {
if
let info = attachment.meta?.original,
let width = info.width,
let height = info.height,
width != 0,
height != 0 {
let aspectRatio = Double(width) / Double(height)
return aspectRatio.isNaN ? nil : aspectRatio
}
return nil
}
}