Skip to content

Instantly share code, notes, and snippets.

@sergenes
Created June 21, 2021 16:30
Show Gist options
  • Select an option

  • Save sergenes/e77a10f72caf6e9996d63fb7d57b201c to your computer and use it in GitHub Desktop.

Select an option

Save sergenes/e77a10f72caf6e9996d63fb7d57b201c to your computer and use it in GitHub Desktop.
var deleteMode by remember { mutableStateOf(false) }
if (editMode && !deleteMode) {
Button(
onClick = {
deleteMode = !deleteMode
}, modifier = Modifier
.width(deleteButtonWidth)
.fillMaxHeight(),
shape = RoundedCornerShape(noRadius),
colors = ButtonDefaults.outlinedButtonColors(
contentColor = Color.Red,
backgroundColor = scColors.primary
)
) {
Icon(
imageVector = Icons.Filled.DeleteForever,
contentDescription = "delete",
modifier = Modifier
.align(Alignment.CenterVertically)
)
}
}
@ppareit
Copy link

ppareit commented Jan 3, 2022

I might be doing something wrong, but on the first line I get an error:
Type TypeVariable(T) has no method getValue(Nothing?, KProperty<*>) and thus it cannot serve as a delegate
Changing the by to a = solve the error, but I'm still trying to understand the code.

@sergenes
Copy link
Author

sergenes commented Jan 5, 2022

To use the by operator you have to import runtime.setValue

import androidx.compose.runtime.setValue

@ppareit
Copy link

ppareit commented Jan 6, 2022

Ok, I see now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment