devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.42k stars 428 forks source link

SF Symbol name for device #280

Open matiaskorhonen opened 3 years ago

matiaskorhonen commented 3 years ago

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
denisenepraunig commented 3 years ago

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

Zandor300 commented 3 years ago

@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"
    }
}
gabors commented 3 years ago

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

furiosFast commented 1 year ago

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

UPDATE: is now possibile using .hasDynamicIsland

kudit commented 5 months ago

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).