DeviceKit icon indicating copy to clipboard operation
DeviceKit copied to clipboard

SF Symbol name for device

Open matiaskorhonen opened this issue 4 years ago • 5 comments

It would be great if DeviceKit could return the name of the correct SF symbol for a device.

For example:

Device.current.symbol_name

// or

Device.current.system_image

So, an iPhone 8 or earlier would return iphone.homebutton and home buttonless phones would return iphone and so forth…

iphone iphone.homebutton ipad ipad.homebutton
iphone iphone.homebutton ipad ipad.homebutton

matiaskorhonen avatar Apr 28 '21 07:04 matiaskorhonen

Hahah, that would be a nice feature 😅. @Zandor300 what do you think?

denisenepraunig avatar Apr 28 '21 07:04 denisenepraunig

@denisenepraunig Yeah, really nice. Could be implemented fairly easily I think using just Swift:

var sfSymbolName: String {
    if isPhone {
        return hasRoundedDisplayCorners ? "iphone" : "iphone.homebutton"
    } else {
        return hasRoundedDisplayCorners ? "ipad" : "ipad.homebutton"
    }
}

Zandor300 avatar Apr 28 '21 16:04 Zandor300

Great idea, let's not forget Macs and Apple TVs

gabors avatar Apr 29 '21 01:04 gabors

hi, how to do the same but with iphone 14 pro and the dynamic island?

UPDATE: is now possibile using .hasDynamicIsland

furiosFast avatar Apr 19 '23 08:04 furiosFast

This feature has been added in this project: GitHub.com/kudit/Device It includes support for all 3 "generations" of iPhone (home button, notch, & Dynamic Island), 2 models of iPad, HomePod, Apple TV, Apple Vision, iPod touch, and Macs! (I could use some help adding more Mac models but there is an easy way to add additional devices without having to learn an obscure mapping).

kudit avatar Mar 21 '24 02:03 kudit