Enhancements proposal
garsdle opened this issue · comments
Emmanuel Garsd commented
First of all I love Stylist! You've really made something great here, especially with that live reload.
I've got some feedback so far:
- Styles designable comma separated styles
- Update Xibs via IBInspectable and prepareForInterfaceBuilder (I already got this working by adding the code that loads the stylist into the
stylist_willMove
swizzled method. It works as long as you use a designable view). - Optimize finding the right theme using a dictionary instead of looping through all styles?
for theme in themes.values {
for style in theme.styles {
guard style.applies(to: styleable) else { continue }
apply(style: style, to: styleable)
}
}
I'm curious what your thoughts are on these.
Yonas Kolb commented
Hey @garsdle, glad you're liking it. Thanks for the feedback!
- Yeah, we already have a
styles: Array
property, so automatically splittingstyles: String
by,
will be easy. I've thought about adding that already 👍 - I'm not sure how this would work? Interface builder calls
prepareForInterfaceBuilder
for@IBDesignable
views, but we wouldn't have a theme loaded at that point. What I can do is make aStyleableView
which is an@IBDesignable
UIView
subclass so you can setstyle
in the property inspector instead of runtime attributes. - The styles used to be stored in a dictionary, but with the addition of classes and view hierarchies this wasn't a simple mapping of style names anymore, as you may have a selector like
UIStackView.section main UIButton.primary
I welcome any more suggestions!
Yonas Kolb commented
StyleableView
added in #4
Yonas Kolb commented
Comma separated styles added in #6
Yonas Kolb commented
Closing this for now. Feel free to open any more specific issues