import Foundation
import ThreemaMacros
enum AppIcon: CaseIterable {
// Default Icon
case `
default`
// Base Icons
// We also have the current here, so users can `hard` select it
case icon2025
case icon2019
case icon20132
case icon20131
// Special Icons
case anniversary10
// This is also the order in AppIconSettingsView
static let defaultIcon: [AppIcon] = [.
default]
static let baseIcons: [AppIcon] = [.icon2025, .icon2019, .icon20132, .icon20131]
static let specialIcons: [AppIcon] = [.anniversary10]
// These strings are defined in the xcconfig
var iconName: String? {
switch self {
case .
default:
nil
case .icon2025:
"Icon2025"
case .icon2019:
"Icon2019"
case .icon20131:
"Icon2013_1"
case .icon20132:
"Icon2013_2"
case .anniversary10:
"Icon10Years"
}
}
var displayTitle: String {
switch self {
case .
default, .icon2025:
#localize(
"app_icon_title_current")
case .icon2019:
#localize(
"app_icon_title_third")
case .icon20131:
#localize(
"app_icon_title_first")
case .icon20132:
#localize(
"app_icon_title_second")
case .anniversary10:
#localize(
"app_icon_title_celebration")
}
}
var displayInfo: String {
switch self {
case .
default, .icon2025:
#localize(
"app_icon_description_fourth")
case .icon2019:
#localize(
"app_icon_description_third")
case .icon20131:
#localize(
"app_icon_description_first")
case .icon20132:
#localize(
"app_icon_description_second")
case .anniversary10:
#localize(
"app_icon_description_celebration")
}
}
var preview: UIImage {
// Starting with the iOS 18 SDK (Xcode 16) app icon assets cannot be accessed from the app. Thus we have to add
// them twice, once as an image asset. Our convention is to suffix these images with `-image`.
// Source: https://forums.developer.apple.com/forums/thread/757162?answerId=799284022#799284022
// We want to take advantage of the build time guarantees of image resources. At the same time we don't see a
// reason to set active Swift compilation conditions for each app target. Our workaround is to also add the
// `-image` assets to Green, but they are never actually used/shown.
#
if THREEMA_CUSTOMER
let image: UIImage? =
switch self {
case .
default:
UIImage(resource: .appIcon)
case .icon2025:
UIImage(resource: .icon2025)
case .icon2019:
UIImage(resource: .icon2019)
case .icon20131:
UIImage(resource: .icon20131)
case .icon20132:
UIImage(resource: .icon20132)
case .anniversary10:
UIImage(resource: .icon10Years)
}
#
else
let image: UIImage? =
switch self {
case .
default:
UIImage(resource: .appIcon)
case .icon2025, .icon2019, .icon20131, .icon20132, .anniversary10:
UIImage(systemName:
"questionmark.square.dashed")
}
#endif
guard let image
else {
return UIImage(systemName:
"questionmark.square.dashed")!
}
return image
}
}