This commit is contained in:
2026-01-12 18:13:22 -07:00
parent 94566eabf6
commit 394789d609
17 changed files with 192 additions and 11 deletions

View File

@@ -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