u/-Periclase-Software-

I've been working on a UI package that contains components, etc. that can be customized to any app theme. Should I make all components accept String or LocalizedStringKey?

Here's an example, let's say you want to add a banner view:

Banner(title: "Something went wrong",
       description: "Please try again later.")

Should the type of title and description be String, LocalizedStringKey, or Text? The reason I ask is because originally I made them all LocalizedStringKey since I read Apple's own views default to that, but then if you do that, you can't do string interpolation directly.

So if you want to use string interpolation, you'll have to use String type, or create an init that accepts a StringProtocol. But then there is no guarantee the initializer will pick the init that uses LocalizedStringKey or StringProtocol.

Finally, I mentioned just accepting a Text type since they have useful arguments like format, etc.

Currently, I have it setup where views accept a LocalizedStringKey or Text (if you want the extra arguments stuff). So if you want string interpolation right now, you would have to use the inits that require Text.

reddit.com
u/-Periclase-Software- — 4 days ago