mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
* Add AppIcon_Dev Adds a blue developer icon to help tell the dev app apart from the release app. * Add AppIconPicker and a couple icons Added a developer icon and an icon representing MSP Mesh * Dismiss icon picker when icon changes * Add icon to icon picker menu item * Replace local mesh icons with Chirpy and add Testflight icon * AppIconButton shows dark icon when in dark mode * Update plist to match main * Only show revelvant icons * Remove testflight images * Debug app icon in blue --------- Co-authored-by: Chase Lau <chase9@mac.com>
54 lines
1.2 KiB
Swift
54 lines
1.2 KiB
Swift
//
|
|
// AppIconButton.swift
|
|
// Meshtastic
|
|
//
|
|
// Created by Chase Christiansen on 7/21/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct AppIconButton: View {
|
|
@Binding var iconDescription: String
|
|
@Binding var iconName: String?
|
|
@Binding var isPresenting: Bool
|
|
@State var errorDetails: String?
|
|
@State var didError = false
|
|
|
|
@Environment(\.colorScheme) var colorScheme
|
|
|
|
var body: some View {
|
|
Button {
|
|
UIApplication.shared.setAlternateIconName(iconName) { error in
|
|
if let error = error {
|
|
errorDetails = error.localizedDescription
|
|
didError = true
|
|
} else {
|
|
self.isPresenting = false
|
|
}
|
|
}
|
|
} label: {
|
|
HStack(alignment: .center) {
|
|
let imageName = colorScheme == .dark ? "\(iconName ?? "AppIcon")_Dark_Thumb" : "\(iconName ?? "AppIcon")_Thumb"
|
|
|
|
if let image = UIImage(named: imageName) {
|
|
Image(uiImage: image)
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fill)
|
|
.background(.thickMaterial)
|
|
.frame(width: 50, height: 50)
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
|
|
VStack(alignment: .leading) {
|
|
Text(iconDescription)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
List {
|
|
AppIconButton(iconDescription: .constant("Default"), iconName: .constant("AppIcon"), isPresenting: .constant(true))
|
|
}
|
|
}
|