Skip to content

Commit

Permalink
Add package SFSafeSymbols to manage SF Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
F1248 committed Jan 15, 2025
1 parent 8b6c9c6 commit fa9d0b7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
16 changes: 16 additions & 0 deletions Genius.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
A46854972D1729B500DB3E87 /* Defaults in Frameworks */ = {isa = PBXBuildFile; productRef = A46854962D1729B500DB3E87 /* Defaults */; };
A4D6DC6E2D37EE4700E9A61D /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = A4D6DC6D2D37EE4700E9A61D /* SFSafeSymbols */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -81,6 +82,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A4D6DC6E2D37EE4700E9A61D /* SFSafeSymbols in Frameworks */,
A46854972D1729B500DB3E87 /* Defaults in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -204,6 +206,7 @@
packageReferences = (
A4672DD92C61205000C933CB /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
A46854952D1729B500DB3E87 /* XCRemoteSwiftPackageReference "Defaults" */,
A4D6DC6C2D37EE4700E9A61D /* XCRemoteSwiftPackageReference "SFSafeSymbols" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = A42B353E2BA2185B009E81AD /* Products */;
Expand Down Expand Up @@ -589,6 +592,14 @@
kind = branch;
};
};
A4D6DC6C2D37EE4700E9A61D /* XCRemoteSwiftPackageReference "SFSafeSymbols" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SFSafeSymbols/SFSafeSymbols";
requirement = {
branch = stable;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -602,6 +613,11 @@
package = A46854952D1729B500DB3E87 /* XCRemoteSwiftPackageReference "Defaults" */;
productName = Defaults;
};
A4D6DC6D2D37EE4700E9A61D /* SFSafeSymbols */ = {
isa = XCSwiftPackageProductDependency;
package = A4D6DC6C2D37EE4700E9A61D /* XCRemoteSwiftPackageReference "SFSafeSymbols" */;
productName = SFSafeSymbols;
};
A4D9A1BC2D257090008D91E7 /* SwiftLintBuildToolPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = A4672DD92C61205000C933CB /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */;
Expand Down
37 changes: 20 additions & 17 deletions Genius/Models/SystemInformation/Hardware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import IOKit
import SFSafeSymbols

extension SystemInformation {

Expand Down Expand Up @@ -46,29 +47,31 @@ extension SystemInformation {
// swiftlint:disable:next unused_declaration
static let isLaptop = SystemInformationData<Bool?>(name.value?.hasPrefix("MacBook"))
static let isVirtualMachine = SystemInformationData<Bool?>(Sysctl.read("kern.hv_vmm_present"))
static let sfSymbol = SystemInformationData<String>(sfSymbolFallback({
static let sfSymbol = SystemInformationData<SFSymbol>({
switch true {
case isVirtualMachine.value: "macwindow"
case isVirtualMachine.value: .macwindow
case name.value.hasPrefix("MacBook"):
switch identifier.value {
case "Mac14,7": "macbook.gen1"
case _ where identifier.value.hasPrefix("MacBookPro18"): "macbook.gen2"
case _ where identifier.value.hasPrefix("MacBook"): "macbook.gen1"
default: "macbook.gen2"
}
case name.value.hasPrefix("iMac"): "desktopcomputer"
case name.value.hasPrefix("Mac mini"): "macmini"
case name.value.hasPrefix("Mac Studio"): "macstudio"
if #available(macOS 14, *) {
switch identifier.value {
case "Mac14,7": .macbookGen1
case _ where identifier.value.hasPrefix("MacBookPro18"): .macbookGen2
case _ where identifier.value.hasPrefix("MacBook"): .macbookGen1
default: .macbookGen2
}
} else { .laptopcomputer }
case name.value.hasPrefix("iMac"): .desktopcomputer
case name.value.hasPrefix("Mac mini"): .macmini
case name.value.hasPrefix("Mac Studio"): if #available(macOS 13, *) { .macstudio } else { .macmini }
case name.value.hasPrefix("Mac Pro"):
switch identifier.value {
case "MacPro3,1", "MacPro4,1", "MacPro5,1": "macpro.gen1"
case "MacPro6,1": "macpro.gen2"
default: ["A2304", "A2787"].contains(regulatoryNumber.value) ? "macpro.gen3.server" : "macpro.gen3"
case "MacPro3,1", "MacPro4,1", "MacPro5,1": .macproGen1
case "MacPro6,1": .macproGen2
default: ["A2304", "A2787"].contains(regulatoryNumber.value) ? .macproGen3Server : .macproGen3
}
case name.value.hasPrefix("Xserve"): "xserve"
default: "desktopcomputer.and.macbook"
case name.value.hasPrefix("Xserve"): .xserve
default: if #available(macOS 15, *) { .desktopcomputerAndMacbook } else { .desktopcomputer }
}
}()))
}())
}

static let securityChip = SystemInformationData<SecurityChip?>({
Expand Down
17 changes: 0 additions & 17 deletions Genius/ViewModels/SFSymbolManager.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
// See LICENSE.txt for license information.
//

import SFSafeSymbols
import SwiftUI
import SwiftUICore

struct SystemInformationHardwareView: View {

var body: some View {
Label("Hardware", systemImage: SystemInformation.Hardware.Model.sfSymbol.value)
Label("Hardware", systemSymbol: SystemInformation.Hardware.Model.sfSymbol.value)
.font(.title)
.padding()
SystemInformationTabView(content: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
// See LICENSE.txt for license information.
//

import SFSafeSymbols
import SwiftUI
import SwiftUICore

struct SystemInformationSoftwareView: View {

var body: some View {
Label("Software", systemImage: "macwindow.on.rectangle")
Label("Software", systemSymbol: .macwindowOnRectangle)
.font(.title)
.padding()
SystemInformationTabView(content: [
Expand Down

0 comments on commit fa9d0b7

Please sign in to comment.