control
Register a control for this component
This allows the user to change the data that the component is using, and see updates to it in realtime
Currently supported data types for controls are:
Boolean
Double
Float
Int
String
If a control with an unsupported data type is registered then it will not appear in Manuscript's bottom sheet, and the value of the control will always be the default value
Parameters
name
the name of the control; this will be displayed alongside the input field in Manuscript's bottom sheet
default Value
the initial value of the control
Samples
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.ezard.manuscript.manuscript.LocalManuscriptData
import io.ezard.manuscript.manuscript.Manuscript
import io.ezard.manuscript.manuscript.ManuscriptScope
import io.ezard.manuscript.variant.Variant
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
fun main() {
//sampleStart
Manuscript {
val text by control(name = "Text", defaultValue = "Click me!")
Variant(name = "Button") {
Button(onClick = {}) {
Text(text = text)
}
}
}
//sampleEnd
}