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

[JEWEL] Move the thenIf modifier from ui to foundation module #2895

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 4 additions & 1 deletion platform/jewel/foundation/api/foundation.api
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ public final class org/jetbrains/jewel/foundation/modifier/BorderKt {
public static synthetic fun border-QWjY48E$default (Landroidx/compose/ui/Modifier;Lorg/jetbrains/jewel/foundation/Stroke$Alignment;FJLandroidx/compose/ui/graphics/Shape;FILjava/lang/Object;)Landroidx/compose/ui/Modifier;
}

public final class org/jetbrains/jewel/foundation/modifier/ModifierExtensionsKt {
public static final fun thenIf (Landroidx/compose/ui/Modifier;ZLkotlin/jvm/functions/Function1;)Landroidx/compose/ui/Modifier;
}

public final class org/jetbrains/jewel/foundation/modifier/OnHoverModifierKt {
public static final fun onHover (Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;)Landroidx/compose/ui/Modifier;
}
Expand Down Expand Up @@ -1019,4 +1023,3 @@ public final class org/jetbrains/jewel/foundation/util/JewelLogger$Companion {
public final fun getInstance (Ljava/lang/Class;)Lorg/jetbrains/jewel/foundation/util/JewelLogger;
public final fun getInstance (Ljava/lang/String;)Lorg/jetbrains/jewel/foundation/util/JewelLogger;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.jetbrains.jewel.foundation.modifier

import androidx.compose.ui.Modifier

/**
* Conditionally applies the [action] to the receiver [Modifier], if [precondition] is true. Returns the receiver as-is
* otherwise.
*/
public inline fun Modifier.thenIf(precondition: Boolean, action: Modifier.() -> Modifier): Modifier =
if (precondition) action() else this
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ import androidx.compose.ui.Modifier
* Conditionally applies the [action] to the receiver [Modifier], if [precondition] is true. Returns the receiver as-is
* otherwise.
*/
@Deprecated(
message = "This modifier has been moved to org.jetbrains.jewel.foundation.util. Please update your imports.",
ReplaceWith("thenIf(precondition, action)", "org.jetbrains.jewel.foundation.util"),
)
public inline fun Modifier.thenIf(precondition: Boolean, action: Modifier.() -> Modifier): Modifier =
if (precondition) action() else this