Originate / OriginateTheme

OriginateTheme is a lightweight user interface theming framework.
MIT License
5 stars 0 forks source link

Improve the Key Naming #25

Open pkluz opened 7 years ago

pkluz commented 7 years ago

Right now, when the following json theme definition file is parsed:

"components" : {
        "navigationBar" : {
            "colors" : {
                "background" : "84E0FA",
                "tint" : "000000",
                ...
            },
            "fonts" : {
                "text" : {
                    "name" : "HelveticaNeue-Light",
                    "size" : 14.0
                },
                "description" : {
                    "name" : "HelveticaNeue-Light",
                    "size" : 12.0
                },
                ...
            }
        },
...
}

In order to access the navigationBar's background color, one would have to write:

theme.component.navigationBarBackgroundColor

When the navigationBar components has a lot of keys, autocomplete starts to struggle in Xcode and suggests a whole lot of things.

Thus we need to change the code-generation a little bit.

It'd be preferable if the output code structure allowed for access as follows:

theme.component.navigationBar.colors.background

or alternatively:

theme.component.navigationBar.backgroundColor - whichever is more comfortable and more in line with the rest of the codebase. I'll leave this up to the author.

chhaylatte commented 7 years ago

This is implemented in the swift version of the code generation script.

I went with the theme.components.navigationBar.backgroundColor version since it's cleaner to implement.

https://github.com/Originate/OriginateTheme/pull/28