Tweaks
A customizable debug screen to view and edit flags that can be used for development in Jetpack Compose applications
To include the library add to your app's build.gradle
:
implementation 'io.github.gmerinojimenez:tweaks:0.0.6'
Or, in case you want to don't add the library in release builds:
debugImplementation 'io.github.gmerinojimenez:tweaks:0.0.6'
releaseImplementation 'io.github.gmerinojimenez:tweaks-no-op:0.0.6'
Then initialize the library in your app's onCreate
:
override fun onCreate() {
super.onCreate()
Tweaks.init(this@TweakDemoApplication, demoTweakGraph())
}
where demoTweakGraph
is the structure you want to be rendered:
private fun demoTweakGraph() = TweaksGraph(
category = listOf(
TweakCategory(
"Screen 1", listOf(
TweakGroup(
"Group 1", listOf(
ReadOnlyStringTweakEntry(
key = "timestamp",
name = "Current timestamp",
value = flow {
while (true) {
emit("${System.currentTimeMillis() / 1000}")
delay(1000)
}
}),
EditableStringTweakEntry(
key = "value1",
name = "Value 1",
),
EditableBooleanTweakEntry(
key = "value2",
name = "Value 2",
),
EditableIntTweakEntry(
key = "value3",
name = "Value 3",
defaultUniqueValue = 0,
),
ButtonTweakEntry(
key = "button1",
name = "Demo button"
) {
Toast.makeText(this, "Demo button", Toast.LENGTH_LONG).show()
}
)
)
)
)
)
)
And then, in your NavHost setup, use the extension function NavGraphBuilder.addTweakGraph
to fill the navigation graph with the tweak components:
@Composable
private fun DemoNavHost(
navController: NavHostController,
initialScreen: String,
modifier: Modifier = Modifier,
) {
NavHost(
navController = navController,
startDestination = initialScreen,
modifier = modifier,
) {
addTweakGraph(
navController = navController,
)
}
}
Please review the app module for configuration examples. Check the available nodes in the graph here