Skip to content

Provide proper SF symbol support #143

@ghost

Description

Right now in cacao all symbols are hardcoded and I personally believe there's no real reason for this, and if a symbol doesn't exist; you could just do it like how SwiftUI does it where it's just a blank image and it warns you that it doesn't exist if the OS doesn't support it

image

Because of this, this is currently how I am having to do SF symbols (if anyone does use this, please note that this isn't safe and will crash if the OS doesn't support it, in my app this doesn't really matter to me though)

pub fn symbol_from(system_name: &str) -> Image {
    Image(unsafe {
        let icon = NSString::new(system_name);
        let desc = NSString::new("");
        msg_send![class!(NSImage), imageWithSystemSymbolName:&*icon
                    accessibilityDescription:&*desc]
    })
}

Which works nicely, I can use symbols from Sequoia now in my Cacao app:

image

I am requesting that something similar to my function could maybe be included in Cacao to prevent any confusion; I'm not really sure what the best and cleanest way of integrating this would be but I think it could be discussed a little here; I personally like how SwiftUI does it again but ofcourse this isn't very rust-y

Image(systemName: "house.fill")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions