Files
luma/Luma/InstrumentIconView.swift
Ole André Vadla Ravnås a0973fbdfa host: Consolidate platform image handling
Introduce PlatformImage typealias and Image(platformImageData:)
so loaders across the host share one path instead of repeating
NSImage/UIImage branches. Fixes iOS build break in widgets.
2026-05-23 17:18:02 +02:00

36 lines
945 B
Swift

import SwiftUI
import LumaCore
struct InstrumentIconView: View {
let icon: InstrumentIcon
var pointSize: CGFloat = 12
var body: some View {
switch icon {
case .symbolic(let id):
Image(systemName: InstrumentIconCatalog.concept(forID: id).sfSymbol)
.font(.system(size: pointSize))
case .pixels(let data):
pixelsImage(data: data)
}
}
@ViewBuilder
private func pixelsImage(data: Data) -> some View {
if let image = Image(platformImageData: data) {
image
.resizable()
.interpolation(.high)
.aspectRatio(contentMode: .fit)
.frame(width: pointSize, height: pointSize)
} else {
fallback
}
}
private var fallback: some View {
Image(systemName: "questionmark.square.dashed")
.font(.system(size: pointSize))
}
}