Balls.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import HealthKit
|
||||
import MusicKit
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
enum SheetType {
|
||||
@@ -28,6 +29,8 @@ struct SettingsView: View {
|
||||
|
||||
AppearanceSection()
|
||||
|
||||
AppIconSection()
|
||||
|
||||
DataManagementSection(
|
||||
activeSheet: $activeSheet
|
||||
)
|
||||
@@ -168,6 +171,61 @@ struct AppearanceSection: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct AppIconSection: View {
|
||||
@State private var currentIcon: String? = UIApplication.shared.alternateIconName
|
||||
|
||||
var body: some View {
|
||||
Section("App Icon") {
|
||||
Button(action: {
|
||||
setIcon(nil)
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "triangle.fill")
|
||||
Text("Peaks")
|
||||
.foregroundColor(.primary)
|
||||
Spacer()
|
||||
if currentIcon == nil {
|
||||
Image(systemName: "checkmark")
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
setIcon("Balls")
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "circle.fill")
|
||||
Text("Balls")
|
||||
.foregroundColor(.primary)
|
||||
Spacer()
|
||||
if currentIcon == "Balls" {
|
||||
Image(systemName: "checkmark")
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
currentIcon = UIApplication.shared.alternateIconName
|
||||
}
|
||||
}
|
||||
|
||||
private func setIcon(_ name: String?) {
|
||||
guard UIApplication.shared.alternateIconName != name else { return }
|
||||
|
||||
UIApplication.shared.setAlternateIconName(name) { error in
|
||||
if let error = error {
|
||||
print("Error setting icon: \(error.localizedDescription)")
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
currentIcon = name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DataManagementSection: View {
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
@EnvironmentObject var themeManager: ThemeManager
|
||||
|
||||
Reference in New Issue
Block a user