Fix alternate app icons

This commit is contained in:
Thomas Ricouard 2022-12-27 21:35:41 +01:00
parent 03e5a960d2
commit aef4d86853
12 changed files with 102 additions and 6 deletions

View file

@ -6,11 +6,21 @@ struct IconSelectorView: View {
self.rawValue self.rawValue
} }
case primary = "AppIconInApp" case primary = "AppIcon"
case alternate1 = "AppIconAlternate1" case alternate1 = "AppIconAlternate1"
case alternate2 = "AppIconAlternate2" case alternate2 = "AppIconAlternate2"
case alternate3 = "AppIconAlternate3" case alternate3 = "AppIconAlternate3"
case alternate4 = "AppIconAlternate4" case alternate4 = "AppIconAlternate4"
var iconName: String {
switch self {
case .primary: return "icon0"
case .alternate1: return "icon1"
case .alternate2: return "icon2"
case .alternate3: return "icon3"
case .alternate4: return "icon4"
}
}
} }
@State private var currentIcon = UIApplication.shared.alternateIconName ?? Icon.primary.rawValue @State private var currentIcon = UIApplication.shared.alternateIconName ?? Icon.primary.rawValue
@ -31,7 +41,7 @@ struct IconSelectorView: View {
} }
} label: { } label: {
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {
Image(uiImage: .init(named: icon.rawValue) ?? .init()) Image(uiImage: .init(named: icon.iconName) ?? .init())
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .aspectRatio(contentMode: .fit)
.frame(minHeight: 125, maxHeight: 1024) .frame(minHeight: 125, maxHeight: 1024)

View file

@ -96,12 +96,14 @@ struct SettingsTabs: View {
Label { Label {
Text("Icon selector") Text("Icon selector")
} icon: { } icon: {
Image(uiImage: .init(named: UIApplication.shared.alternateIconName ?? "AppIconInApp")!) if let icon = IconSelectorView.Icon(rawValue: UIApplication.shared.alternateIconName ?? "AppIcon") {
Image(uiImage: .init(named: icon.iconName)!)
.resizable() .resizable()
.frame(width: 25, height: 25) .frame(width: 25, height: 25)
.cornerRadius(4) .cornerRadius(4)
} }
} }
}
Link(destination: URL(string: "https://github.com/Dimillian/IceCubesApp")!) { Link(destination: URL(string: "https://github.com/Dimillian/IceCubesApp")!) {
Text("https://github.com/Dimillian/IceCubesApp") Text("https://github.com/Dimillian/IceCubesApp")
} }

View file

Before

Width:  |  Height:  |  Size: 986 KiB

After

Width:  |  Height:  |  Size: 986 KiB

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,016 KiB

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB