mirror of
https://github.com/somegeekintn/SimDirs.git
synced 2026-06-29 05:29:30 +00:00
57 lines
1.6 KiB
Swift
57 lines
1.6 KiB
Swift
//
|
|
// SimDeviceType.swift
|
|
// SimDirs
|
|
//
|
|
// Created by Casey Fleser on 5/24/22.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct SimDeviceType: Decodable {
|
|
// enum CodingKeys: String, CodingKey {
|
|
// case bundlePath
|
|
// case identifier
|
|
// case maxRuntimeVersion
|
|
// case maxRuntimeVersionString
|
|
// case minRuntimeVersion
|
|
// case minRuntimeVersionString
|
|
// case modelIdentifier
|
|
// case name
|
|
// case productFamily
|
|
// }
|
|
//
|
|
let name : String
|
|
let identifier : String
|
|
let productFamily : SimProductFamily
|
|
let modelIdentifier : String
|
|
let bundlePath : String
|
|
let minRuntimeVersion : Int
|
|
let maxRuntimeVersion : Int
|
|
let minRuntimeVersionString : String
|
|
let maxRuntimeVersionString : String
|
|
|
|
func supports(productFamily: SimProductFamily) -> Bool {
|
|
return productFamily == self.productFamily
|
|
}
|
|
|
|
func supports(runtime: SimRuntime) -> Bool {
|
|
return runtime.supportedDeviceTypes.contains { $0.identifier == identifier }
|
|
}
|
|
}
|
|
|
|
extension SimDeviceType: SourceItemData {
|
|
var title : String { return name }
|
|
var headerTitle : String { "Device Type: \(title)" }
|
|
var imageDesc : SourceImageDesc { .symbol(systemName: productFamily.symbolName) }
|
|
}
|
|
|
|
extension Array where Element == SimDeviceType {
|
|
func supporting(productFamily: SimProductFamily) -> Self {
|
|
filter { $0.supports(productFamily: productFamily) }
|
|
}
|
|
|
|
func supporting(runtime: SimRuntime) -> Self {
|
|
filter { $0.supports(runtime: runtime) }
|
|
}
|
|
}
|
|
|