IBAnimatable / IBAnimatable

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
MIT License
8.68k stars 780 forks source link

IBAnimatable Themes #500

Open SD10 opened 7 years ago

SD10 commented 7 years ago

IBAnimatable Themes

It would be nice to be able to set default values for IBDesignable classes without having to subclass.

How?

I'm thinking we can add a property:

@IBInspectable
var theme: String {}

This would be the name of a .plist file to use for the configuration. Then we could parse this file and apply all the values.

Some limitations:

JakeLin commented 7 years ago

I thought about this but haven't found a way to set the default values within the protocol without doing it in subclasses. It will be great if we can do it. then we don't need to set a lot of = CGFloat.nans

phimage commented 7 years ago

I try something like that using a CSS parser (like 100mango/SwiftCssParser, ...) but plist or json it's easier to load file Bundle(forClass: self.dynamicType)

SD10 commented 7 years ago

Thank you for sharing SwiftCssParser! I wanted to look at something like this!

phimage commented 7 years ago

I play also with https://github.com/146BC/StyleKit, https://github.com/akane/Gaikan but I want the result in storyboard editor, not at execution time

I try also to edit storyboard XML (by modifying https://github.com/krzyzanowskim/Natalie) to edit some attributes to make a "theme change"

SD10 commented 7 years ago

@phimage Yeah, I've looked at StyleKit.

I think having a "theme change" at execution time still provides value. However, like you, I want the result in the storyboard editor. It's not a simple task but I've been playing with it now and then

SD10 commented 7 years ago

@phimage If we use a didSet property observer in the theme property, won't this parse the stylesheet and apply the values to the storyboard editor?

phimage commented 7 years ago

If you parse your own style sheet(in code or file using the good Bundle to read file) and apply directly to some view attributes, yes it will work on the current view And if there is issue, you can try with prepareForInterfaceBuilder