Skip to content

holgerkrupp/SwiftDeviceInfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Device Info

A Package I wrote to show SF Symbols for the device used.

Add this to your SwiftUI App:

import DeviceInfo


extension DeviceUIStyle {
    var sfSymbolName: String {
        switch self {
        case .iphoneHomeButton: return "iphone.gen1"
        case .iphoneNotch: return "iphone.gen2"
        case .iphoneDynamicIsland: return "iphone.gen3"
        case .ipadHomeButton: return "ipad.gen1"
        case .ipadNoHomeButton: return "ipad.gen2"
        case .appleWatch: return "applewatch"
        case .visionPro: return "visionpro"
        case .macLaptop: return "macbook"
        case .macMini: return "macmini"
        case .macPro: return "macpro.gen3"
        case .macDesktop: return "desktopcomputer"
        }
    }
}

Inject it in your View with

            ContentView()
                .withDeviceStyle()

And use it with

    @Environment(\.deviceUIStyle) var style

        ...

    Image(systemName: style.sfSymbolName)

You can use it of course to customize other items, not only sfSymbolNames. Modify the extension accordingly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages