Skip to content

Commit

Permalink
fix(ios): show app icon previews in app
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Sep 12, 2024
1 parent 3057379 commit 9a2e21c
Show file tree
Hide file tree
Showing 45 changed files with 112 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct Christmas2023AnnouncementView: View {
.font(.headline)
.multilineTextAlignment(.center)

Image(uiImage: UIImage(named: AppIcon.christmas.rawValue) ?? UIImage())
Image(uiImage: AppIcon.christmas.image ?? UIImage())
.resizable()
.scaledToFit()
.frame(width: .extraLargeIcon)
Expand Down
10 changes: 10 additions & 0 deletions ios/Approach/Sources/AssetsLibrary/AppIcon.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import UIKit

public enum AppIcon: String, CaseIterable, Identifiable {
case primary = "AppIcon"
case dark = "AppIcon-Dark"
Expand All @@ -17,6 +19,14 @@ public enum AppIcon: String, CaseIterable, Identifiable {
case .bisexual, .pride, .trans: return .pride
}
}

public var previewName: String {
"\(id)-Preview"
}

public var image: UIImage? {
UIImage(named: previewName)
}
}

extension AppIcon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ extension AppIconList {
extension AppIconList.State {
var appIconImage: UIImage {
if let currentAppIcon {
return UIImage(named: currentAppIcon.rawValue) ?? UIImage()
return currentAppIcon.image ?? UIImage()
} else if isLoadingAppIcon {
return UIImage()
} else {
return UIImage(named: "AppIcon") ?? UIImage()
return AppIcon.primary.image ?? UIImage()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension AppIconView {
var image: UIImage {
switch self {
case let .appIcon(appIcon):
return UIImage(named: appIcon.rawValue) ?? UIImage()
return appIcon.image ?? UIImage()
case let .image(image):
return image
}
Expand Down
4 changes: 2 additions & 2 deletions ios/Approach/Sources/SettingsFeature/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public struct SettingsView: View {
extension Settings.State {
var appIconImage: UIImage {
if let currentAppIcon {
return UIImage(named: currentAppIcon.rawValue) ?? UIImage()
return currentAppIcon.image ?? UIImage()
} else {
return UIImage(named: "AppIcon") ?? UIImage()
return AppIcon.primary.image ?? UIImage()
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file modified ios/ApproachIOS/Assets.xcassets/AppIcon.appiconset/Dark.png
Binary file modified ios/ApproachIOS/Assets.xcassets/AppIcon.appiconset/Tinted.png

0 comments on commit 9a2e21c

Please sign in to comment.