Add ability to change app icons!

This commit is contained in:
Nindi Gill 2024-02-25 20:41:36 +11:00
parent cb48971342
commit b3cb86aecd
No known key found for this signature in database
44 changed files with 276 additions and 3 deletions

View file

@ -55,6 +55,8 @@
39252ABB285C7D3800956C74 /* SettingsInstallersCatalogsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39252ABA285C7D3800956C74 /* SettingsInstallersCatalogsView.swift */; };
39252ABD285C8FFC00956C74 /* ListRowInstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39252ABC285C8FFC00956C74 /* ListRowInstaller.swift */; };
39252AC3285CA5FE00956C74 /* InstallerExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39252AC2285CA5FE00956C74 /* InstallerExportView.swift */; };
392B30082B8B1D5C00B34BA4 /* SettingsGeneralAppIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392B30072B8B1D5C00B34BA4 /* SettingsGeneralAppIconView.swift */; };
392B300A2B8B1E3900B34BA4 /* AppIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392B30092B8B1E3900B34BA4 /* AppIcon.swift */; };
3935F47428643AB800760AB0 /* UNNotificationCategory+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3935F47328643AB800760AB0 /* UNNotificationCategory+Extension.swift */; };
3935F47628643AF000760AB0 /* UNNotificationAction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3935F47528643AF000760AB0 /* UNNotificationAction+Extension.swift */; };
3935F47828643B1F00760AB0 /* UserNotificationCenterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3935F47728643B1F00760AB0 /* UserNotificationCenterDelegate.swift */; };
@ -221,6 +223,8 @@
39252ABA285C7D3800956C74 /* SettingsInstallersCatalogsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInstallersCatalogsView.swift; sourceTree = "<group>"; };
39252ABC285C8FFC00956C74 /* ListRowInstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRowInstaller.swift; sourceTree = "<group>"; };
39252AC2285CA5FE00956C74 /* InstallerExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallerExportView.swift; sourceTree = "<group>"; };
392B30072B8B1D5C00B34BA4 /* SettingsGeneralAppIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsGeneralAppIconView.swift; sourceTree = "<group>"; };
392B30092B8B1E3900B34BA4 /* AppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIcon.swift; sourceTree = "<group>"; };
3935F47328643AB800760AB0 /* UNNotificationCategory+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNNotificationCategory+Extension.swift"; sourceTree = "<group>"; };
3935F47528643AF000760AB0 /* UNNotificationAction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNNotificationAction+Extension.swift"; sourceTree = "<group>"; };
3935F47728643B1F00760AB0 /* UserNotificationCenterDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationCenterDelegate.swift; sourceTree = "<group>"; };
@ -430,6 +434,7 @@
390451C32856E4A500E0B563 /* Model */ = {
isa = PBXGroup;
children = (
392B30092B8B1E3900B34BA4 /* AppIcon.swift */,
573A23612A28711C00EC9470 /* Architecture.swift */,
39CB5E3C293F5C2E00CFDBB8 /* Catalog.swift */,
390451E428574F0000E0B563 /* CatalogType.swift */,
@ -575,6 +580,7 @@
3935F47B2864434B00760AB0 /* SettingsGeneralNotificationsView.swift */,
39252AB0285C5C1E00956C74 /* SettingsGeneralRetryView.swift */,
39252AB2285C5D7700956C74 /* SettingsGeneralUpdatesView.swift */,
392B30072B8B1D5C00B34BA4 /* SettingsGeneralAppIconView.swift */,
39252A88285AD0AB00956C74 /* SettingsHeaderView.swift */,
39FF05F52859850F00A86670 /* SettingsFirmwaresView.swift */,
39252A78285A85AF00956C74 /* SettingsInstallersView.swift */,
@ -862,6 +868,7 @@
3935F4A6286AD3E100760AB0 /* ActivityHeaderView.swift in Sources */,
3935F480286551FB00760AB0 /* Double+Extension.swift in Sources */,
398BE6B52B62450500FE0C29 /* FloatingAlert.swift in Sources */,
392B30082B8B1D5C00B34BA4 /* SettingsGeneralAppIconView.swift in Sources */,
39252ABD285C8FFC00956C74 /* ListRowInstaller.swift in Sources */,
3935F49D286ABE4D00760AB0 /* FooterView.swift in Sources */,
390451CC2856F23100E0B563 /* ScaledSystemImage.swift in Sources */,
@ -881,6 +888,7 @@
39D68B892861369B00A7848C /* InstallerCreator.swift in Sources */,
39CF56312862A8C5006FB5D2 /* InstallMediaCreator.swift in Sources */,
39252AB1285C5C1E00956C74 /* SettingsGeneralRetryView.swift in Sources */,
392B300A2B8B1E3900B34BA4 /* AppIcon.swift in Sources */,
390451DC28573F1000E0B563 /* Dictionary+Extension.swift in Sources */,
390451D02856F63700E0B563 /* Installer.swift in Sources */,
3935F47628643AF000760AB0 /* UNNotificationAction+Extension.swift in Sources */,
@ -1088,8 +1096,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon - Sonoma";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
@ -1122,8 +1131,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon - Sonoma";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

View file

@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 212 KiB

Before After
Before After

View file

@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Monterey.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Sonoma.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Ventura.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -12,6 +12,8 @@ struct MistApp: App {
// swiftlint:disable:next weak_delegate
@NSApplicationDelegateAdaptor(AppDelegate.self)
var appDelegate: AppDelegate
@AppStorage("appIcon")
private var appIcon: AppIcon = .default
@StateObject var sparkleUpdater: SparkleUpdater = .init()
@StateObject var logManager: LogManager = .shared
@State private var refreshing: Bool = false
@ -23,6 +25,9 @@ struct MistApp: App {
.onReceive(NotificationCenter.default.publisher(for: NSApplication.willUpdateNotification)) { _ in
hideZoomButton()
}
.onAppear {
setAppIcon()
}
}
.fixedWindow()
.commands {
@ -38,7 +43,7 @@ struct MistApp: App {
.handlesExternalEvents(matching: ["log"])
}
func hideZoomButton() {
private func hideZoomButton() {
for window in NSApplication.shared.windows {
guard let button: NSButton = window.standardWindowButton(NSWindow.ButtonType.zoomButton) else {
continue
@ -47,4 +52,8 @@ struct MistApp: App {
button.isEnabled = false
}
}
private func setAppIcon() {
NSApplication.shared.applicationIconImage = NSImage(named: appIcon.name)
}
}

32
Mist/Model/AppIcon.swift Normal file
View file

@ -0,0 +1,32 @@
//
// AppIcon.swift
// Mist
//
// Created by Nindi Gill on 25/2/2024.
//
import Foundation
enum AppIcon: String, CaseIterable, Identifiable {
case monterey = "Monterey"
case ventura = "Ventura"
case sonoma = "Sonoma"
static let `default`: AppIcon = .sonoma
var id: String {
rawValue
}
var description: String {
rawValue
}
var name: String {
"App Icon - \(rawValue)"
}
var previewName: String {
"App Icon Preview - \(rawValue)"
}
}

View file

@ -0,0 +1,45 @@
//
// SettingsGeneralAppIconView.swift
// Mist
//
// Created by Nindi Gill on 25/2/2024.
//
import SwiftUI
struct SettingsGeneralAppIconView: View {
@Binding var appIcon: AppIcon
private let length: CGFloat = 64
var body: some View {
VStack {
HStack {
Picker("App Icon:", selection: $appIcon) {
ForEach(AppIcon.allCases) { icon in
VStack {
ScaledImage(name: icon.previewName, length: length)
Text(icon.description)
}
.padding(.trailing)
.tag(icon)
}
}
.pickerStyle(.radioGroup)
.horizontalRadioGroupLayout()
}
}
.onChange(of: appIcon) { icon in
setAppIcon(appIcon: icon)
}
}
private func setAppIcon(appIcon: AppIcon) {
NSApplication.shared.applicationIconImage = NSImage(named: appIcon.name)
}
}
struct SettingsGeneralAppIconView_Previews: PreviewProvider {
static var previews: some View {
SettingsGeneralAppIconView(appIcon: .constant(.default))
}
}

View file

@ -18,6 +18,8 @@ struct SettingsGeneralView: View {
private var enableAutomaticChecks: Bool = true
@AppStorage("SUScheduledCheckInterval")
private var scheduledCheckInterval: Int = 86_400
@AppStorage("appIcon")
private var appIcon: AppIcon = .default
@ObservedObject var sparkleUpdater: SparkleUpdater
private let enableNotificationsDefault: Bool = false
private let retriesDefault: Int = 10
@ -43,6 +45,8 @@ struct SettingsGeneralView: View {
PaddedDivider()
SettingsGeneralUpdatesView(sparkleUpdater: sparkleUpdater, enable: $enableAutomaticChecks, interval: $scheduledCheckInterval, width: width)
PaddedDivider()
SettingsGeneralAppIconView(appIcon: $appIcon)
PaddedDivider()
ResetToDefaultButton {
reset()
}
@ -56,6 +60,7 @@ struct SettingsGeneralView: View {
retryDelay = retryDelayDefault
enableAutomaticChecks = enableAutomaticChecksDefault
scheduledCheckInterval = scheduledCheckIntervalDefault
appIcon = .default
}
}