mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 08:17:16 +00:00
45 lines
966 B
Swift
45 lines
966 B
Swift
//
|
|
// RSImage-Extensions.swift
|
|
// NetNewsWire
|
|
//
|
|
// Created by Maurice Parker on 4/11/19.
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import RSCore
|
|
import Images
|
|
#if os(macOS)
|
|
import AppKit
|
|
#else
|
|
import UIKit
|
|
#endif
|
|
|
|
extension RSImage {
|
|
|
|
static var appIconImage: RSImage? {
|
|
#if os(macOS)
|
|
return RSImage(named: NSImage.applicationIconName)
|
|
#elseif os(iOS)
|
|
// https://stackoverflow.com/a/51241158/14256
|
|
if let icons = Bundle.main.infoDictionary?["CFBundleIcons"] as? [String: Any],
|
|
let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any],
|
|
let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String],
|
|
let lastIcon = iconFiles.last {
|
|
return RSImage(named: lastIcon)
|
|
}
|
|
return nil
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extension IconImage {
|
|
static let appIcon: IconImage? = {
|
|
if let image = RSImage.appIconImage {
|
|
return IconImage(image)
|
|
}
|
|
return nil
|
|
}()
|
|
|
|
static let nnwFeedIcon = IconImage(Assets.Images.nnwFeedIcon)
|
|
}
|