Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBAnimatable Themes #500

Open
SD10 opened this issue Jun 12, 2017 · 7 comments
Open

IBAnimatable Themes #500

SD10 opened this issue Jun 12, 2017 · 7 comments

Comments

@SD10
Copy link
Member

SD10 commented Jun 12, 2017

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:

  • Storing a UIImage -- actually, we could just use the IMG name
  • Colors, would probably need to be represented as a HEX value
@JakeLin
Copy link
Member

JakeLin commented Jun 13, 2017

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
Copy link
Member

phimage commented Jun 18, 2017

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
Copy link
Member Author

SD10 commented Jun 18, 2017

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

@phimage
Copy link
Member

phimage commented Jun 18, 2017

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
Copy link
Member Author

SD10 commented Jun 18, 2017

@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
Copy link
Member Author

SD10 commented Jul 1, 2017

@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
Copy link
Member

phimage commented Jul 2, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants