Skip to content

Commit

Permalink
Change color runtime example
Browse files Browse the repository at this point in the history
  • Loading branch information
warting committed Jan 5, 2022
1 parent b214072 commit 155030c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/src/main/java/se/warting/signaturepad/ComposeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp

private const val SIGNATURE_PAD_HEIGHT = 120

@Suppress("LongMethod")
class ComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -36,6 +37,7 @@ class ComposeActivity : ComponentActivity() {
Column {

var signaturePadAdapter: SignaturePadAdapter? = null
val penColor = remember { mutableStateOf(Color.Black) }

Box(
modifier = Modifier
Expand All @@ -46,11 +48,11 @@ class ComposeActivity : ComponentActivity() {
color = Color.Red,
)
) {

SignaturePadView(
onReady = {
signaturePadAdapter = it
},
penColor = penColor.value,
onSigned = {
if (BuildConfig.DEBUG) {
Log.d("ComposeActivity", "onSigned")
Expand Down Expand Up @@ -83,6 +85,18 @@ class ComposeActivity : ComponentActivity() {
}) {
Text("Clear")
}

Button(onClick = {
penColor.value = Color.Red
}) {
Text("Red")
}

Button(onClick = {
penColor.value = Color.Black
}) {
Text("Black")
}
}

Text(text = "SVG: " + mutableSvg.value)
Expand Down

0 comments on commit 155030c

Please sign in to comment.