Skip to content

Commit

Permalink
Add ability to change app icons!
Browse files Browse the repository at this point in the history
  • Loading branch information
ninxsoft committed Feb 25, 2024
1 parent cb48971 commit b3cb86a
Show file tree
Hide file tree
Showing 44 changed files with 276 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Mist.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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>"; };
Expand Down Expand Up @@ -430,6 +434,7 @@
390451C32856E4A500E0B563 /* Model */ = {
isa = PBXGroup;
children = (
392B30092B8B1E3900B34BA4 /* AppIcon.swift */,
573A23612A28711C00EC9470 /* Architecture.swift */,
39CB5E3C293F5C2E00CFDBB8 /* Catalog.swift */,
390451E428574F0000E0B563 /* CatalogType.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
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.
68 changes: 68 additions & 0 deletions Mist/Assets.xcassets/App Icon - Sonoma.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
File renamed without changes
File renamed without changes
File renamed without changes
68 changes: 68 additions & 0 deletions Mist/Assets.xcassets/App Icon - Ventura.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Monterey.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Sonoma.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "App Icon Preview - Ventura.png",
"idiom" : "mac"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
11 changes: 10 additions & 1 deletion Mist/MistApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +25,9 @@ struct MistApp: App {
.onReceive(NotificationCenter.default.publisher(for: NSApplication.willUpdateNotification)) { _ in
hideZoomButton()
}
.onAppear {
setAppIcon()
}
}
.fixedWindow()
.commands {
Expand All @@ -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
Expand All @@ -47,4 +52,8 @@ struct MistApp: App {
button.isEnabled = false
}
}

private func setAppIcon() {
NSApplication.shared.applicationIconImage = NSImage(named: appIcon.name)
}
}
32 changes: 32 additions & 0 deletions Mist/Model/AppIcon.swift
Original file line number Diff line number Diff line change
@@ -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)"
}
}
45 changes: 45 additions & 0 deletions Mist/Views/Settings/SettingsGeneralAppIconView.swift
Original file line number Diff line number Diff line change
@@ -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))
}
}
5 changes: 5 additions & 0 deletions Mist/Views/Settings/SettingsGeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +45,8 @@ struct SettingsGeneralView: View {
PaddedDivider()
SettingsGeneralUpdatesView(sparkleUpdater: sparkleUpdater, enable: $enableAutomaticChecks, interval: $scheduledCheckInterval, width: width)
PaddedDivider()
SettingsGeneralAppIconView(appIcon: $appIcon)
PaddedDivider()
ResetToDefaultButton {
reset()
}
Expand All @@ -56,6 +60,7 @@ struct SettingsGeneralView: View {
retryDelay = retryDelayDefault
enableAutomaticChecks = enableAutomaticChecksDefault
scheduledCheckInterval = scheduledCheckIntervalDefault
appIcon = .default
}
}

Expand Down

0 comments on commit b3cb86a

Please sign in to comment.