yonaskolb / Stylist

Define UI styles for iOS apps in a hot-reloadable yaml or json file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancements proposal

garsdle opened this issue · comments

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.

Hey @garsdle, glad you're liking it. Thanks for the feedback!

  1. Yeah, we already have a styles: Array property, so automatically splitting styles: String by , will be easy. I've thought about adding that already 👍
  2. 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 a StyleableView which is an @IBDesignable UIView subclass so you can set style in the property inspector instead of runtime attributes.
  3. 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!

StyleableView added in #4

Comma separated styles added in #6

Closing this for now. Feel free to open any more specific issues