Kotlin Operate Literals with Jetpack Compose | by Hani Fakhouri | Jul, 2022

[ad_1]

Photograph by Marc Sendra Martorell on Unsplash
enjoyable Modifier.applyIf(
situation: Boolean,
modifierFunction: Modifier.() -> Modifier
): Modifier {
return this.run {
if (situation) {
this.modifierFunction()
} else {
this
}
}
}
Textual content(
modifier = Modifier
.alpha(0.8F)
.clickable { onSubmit() }
.padding(16.dp),
textual content = "Submit"
)
var modifier = Modifier.alpha(0.8F)
if (isReady) {
modifier = modifier.clickable { onSubmit() }
}

Textual content(
modifier = modifier.padding(16.dp),
textual content = "Submit"
)

Textual content(
modifier = Modifier
.alpha(0.8F)
.run {
if (isReady) {
this.clickable { onSubmit() }
} else {
this
}
}
.padding(16.dp),
textual content = "Submit"
)
enjoyable Modifier.applyIf(
situation: Boolean,
modifierFunction: Modifier.() -> Modifier
): Modifier {
return this.run {
if (situation) {
this.modifierFunction()
} else {
this
}
}
}
Textual content(
modifier = Modifier
.alpha(0.8F)
.applyIf(isReady) {
this.clickable { onSubmit() }
}
.padding(16.dp),
textual content = "Submit"
)
modifierFunction: Modifier.() -> Modifier

[ad_2]

Source_link

Leave a Comment