2019-12-07 22:43:11 +01:00
|
|
|
//
|
|
|
|
// RSImage-AppIcons.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Nate Weaver on 2019-12-07.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2024-03-21 04:49:15 +01:00
|
|
|
import Core
|
2024-04-16 07:21:17 +02:00
|
|
|
import Images
|
2019-12-07 22:43:11 +01:00
|
|
|
|
|
|
|
extension RSImage {
|
2024-04-02 08:11:30 +02:00
|
|
|
static let appIconImage: RSImage? = {
|
2019-12-07 22:43:11 +01:00
|
|
|
#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
|
2019-12-08 07:23:55 +01:00
|
|
|
#endif
|
2024-04-02 08:11:30 +02:00
|
|
|
}()
|
2019-12-07 22:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extension IconImage {
|
2024-04-02 08:11:30 +02:00
|
|
|
@MainActor static let appIcon: IconImage? = {
|
2019-12-07 22:43:11 +01:00
|
|
|
if let image = RSImage.appIconImage {
|
|
|
|
return IconImage(image)
|
|
|
|
}
|
|
|
|
return nil
|
2020-03-30 17:56:52 +02:00
|
|
|
}()
|
2019-12-07 22:43:11 +01:00
|
|
|
}
|