mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Move RSImage-AppIcons to Images module.
This commit is contained in:
37
Modules/Images/Sources/Images/RSImage-AppIcons.swift
Normal file
37
Modules/Images/Sources/Images/RSImage-AppIcons.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RSImage-AppIcons.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Nate Weaver on 2019-12-07.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Core
|
||||
import Images
|
||||
|
||||
extension RSImage {
|
||||
static let 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 {
|
||||
@MainActor static let appIcon: IconImage? = {
|
||||
if let image = RSImage.appIconImage {
|
||||
return IconImage(image)
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user