-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+6.25 KB
(110%)
...eproj/project.xcworkspace/xcuserdata/Francesco.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// IconPage.swift | ||
// AnimeGen | ||
// | ||
// Created by cranci on 28/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class IconNames: ObservableObject { | ||
var iconNames: [String?] = [nil] | ||
@Published var currentIndex = 0 | ||
|
||
init() { | ||
getAlternateIcons() | ||
if let currentIcon = UIApplication.shared.alternateIconName { | ||
self.currentIndex = iconNames.firstIndex(of: currentIcon) ?? 0 | ||
} | ||
} | ||
|
||
func getAlternateIcons() { | ||
if let icons = Bundle.main.object(forInfoDictionaryKey: "CFBundleIcons") as? [String: Any], | ||
let alternateIcons = icons["CFBundleAlternateIcons"] as? [String: Any] { | ||
|
||
for (_, value) in alternateIcons { | ||
guard let iconList = value as? Dictionary<String, Any> else { return } | ||
guard let iconFiles = iconList["CFBundleIconFiles"] as? [String] else { return } | ||
|
||
guard let icon = iconFiles.first else { return } | ||
|
||
iconNames.append(icon) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct IconPage: View { | ||
@EnvironmentObject var iconSettings: IconNames | ||
|
||
var body: some View { | ||
NavigationView { | ||
List { | ||
ForEach(0 ..< iconSettings.iconNames.count) { i in | ||
Button(action: { | ||
self.iconSettings.currentIndex = i | ||
self.changeAppIcon() | ||
}) { | ||
HStack { | ||
Image(uiImage: UIImage(named: self.iconSettings.iconNames[i] ?? "AppIcon") ?? UIImage()) | ||
.resizable() | ||
.renderingMode(.original) | ||
.frame(width: 80, height: 80) | ||
.clipShape(RoundedRectangle(cornerRadius: 12)) | ||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(Color.gray, lineWidth: 1)) | ||
|
||
Text(self.iconSettings.iconNames[i] ?? "Base") | ||
.font(.headline) | ||
.foregroundColor(.primary) | ||
.lineLimit(1) | ||
.padding(.leading, 8) | ||
|
||
Spacer() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func changeAppIcon() { | ||
let iconName = self.iconSettings.iconNames[self.iconSettings.currentIndex] | ||
UIApplication.shared.setAlternateIconName(iconName) { error in | ||
if let error = error { | ||
print("Error: \(error.localizedDescription)") | ||
print("App Icon Change Error Code: \((error as NSError).code)") | ||
} else { | ||
print("Finished changing icon to \(iconName ?? "AppIcon")") | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct IconPage_Previews: PreviewProvider { | ||
static var previews: some View { | ||
IconPage().environmentObject(IconNames()) | ||
} | ||
} |
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters