Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conditional modifiers not working as expected #1439

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import androidx.compose.ui.Modifier
* @param builder the modifier(s) to apply when [predicate] is true
*/
public inline fun Modifier.ifTrue(predicate: Boolean, builder: Modifier.() -> Modifier): Modifier =
then(if (predicate) this.builder() else Modifier)
then(if (predicate) this.builder() else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [predicate]
Expand All @@ -51,7 +51,7 @@ public inline fun Modifier.ifTrue(predicate: Boolean, builder: Modifier.() -> Mo
* @param builder the modifier(s) to apply when [predicate] is false
*/
public inline fun Modifier.ifFalse(predicate: Boolean, builder: Modifier.() -> Modifier): Modifier =
then(if (!predicate) this.builder() else Modifier)
then(if (!predicate) this.builder() else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [value] nullability
Expand All @@ -66,7 +66,7 @@ public inline fun Modifier.ifFalse(predicate: Boolean, builder: Modifier.() -> M
* @param builder the modifier(s) to apply when [value] is not null
*/
public inline fun <T : Any> Modifier.ifNotNull(value: T?, builder: Modifier.(T) -> Modifier): Modifier =
then(if (value != null) this.builder(value) else Modifier)
then(if (value != null) this.builder(value) else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [value] nullability
Expand All @@ -81,4 +81,4 @@ public inline fun <T : Any> Modifier.ifNotNull(value: T?, builder: Modifier.(T)
* @param builder the modifier(s) to apply when [value] is null
*/
public inline fun <T : Any> Modifier.ifNull(value: T?, builder: Modifier.() -> Modifier): Modifier =
then(if (value == null) this.builder() else Modifier)
then(if (value == null) this.builder() else this)
Loading