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

Dsl evolution #13

Merged
merged 2 commits into from Oct 25, 2021
Merged

Dsl evolution #13

merged 2 commits into from Oct 25, 2021

Conversation

gmerinojimenez
Copy link
Owner

@gmerinojimenez gmerinojimenez commented Oct 22, 2021

Adding entries to the dsl. Usage example:

    private fun demoTweakGraph() = tweaksGraph {
        tweakCategory("Screen 1") {
            tweakGroup("Group 1") {
                label(
                    key = "timestamp",
                    name = "Current timestamp",
                ) {
                    flow {
                        while (true) {
                            emit("${System.currentTimeMillis() / 1000}")
                            delay(1000)
                        }
                    }
                }
                editableString(
                    key = "value1",
                    name = "Value 1",
                )
                editableBoolean(
                    key = "value2",
                    name = "Value 2",
                )
                editableInt(
                    key = "value3",
                    name = "Value 3",
                    defaultValue = flow {
                        while (true) {
                            counter += 1
                            emit(counter)
                            delay(1000)
                        }
                    }
                )
                editableLong(
                    key = "value4",
                    name = "Value 4",
                    defaultValue = 0L,
                )

                button(
                    key = "button1",
                    name = "Demo button"
                ) {
                    Toast.makeText(this@TweakDemoApplication, "Demo button", Toast.LENGTH_LONG)
                        .show()
                }
            }
        }
    }

Comment on lines +49 to +53
fun tweak(entry: TweakEntry<*>) {
entries.add(entry)
}

fun button(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I like these naming 👍

@gmerinojimenez gmerinojimenez merged commit cc78c24 into main Oct 25, 2021
@gmerinojimenez gmerinojimenez deleted the dsl-evolution branch October 25, 2021 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants