airbnb / paris

Define and apply styles to Android views programmatically

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advantage of Paris when used with Epoxy and MvRx

qbait opened this issue · comments

I use MvRx and Epoxy. I'm looking at Paris lib, but I'm not sure if I'm not overengineering by using it.

For my Epoxy view, I could define enum with styles

    enum class Style {
        RED, GREEN, BLUE
    }

And define the function that will programmatically style my views.

    @ModelProp
    fun style(style: Style) {
        when(style) {
            Style.RED -> {}
            Style.GREEN -> {}
            Style.BLUE -> {}
        }
    }

What's the advantage of using Paris over having a simple style function?

@qbait While you can achieve the same thing using Epoxy, I think the following Paris features will make the code safer and more concise:

Results will vary depending on how complex your styles and custom views are. At Airbnb we also use the style linking feature (https://github.com/airbnb/paris/wiki/Custom-Views#linking-styles-to-custom-views) for testing.