Last active
July 3, 2022 10:06
-
-
Save hisetu/710dd3275d3d04fb47eea517238e80d0 to your computer and use it in GitHub Desktop.
Jetpack Compose Modifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.interaction.MutableInteractionSource | |
import androidx.compose.foundation.selection.selectable | |
import androidx.compose.runtime.remember | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.composed | |
inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier = composed { | |
clickable(indication = null, | |
interactionSource = remember { MutableInteractionSource() }) { | |
onClick() | |
} | |
} | |
inline fun Modifier.selectableNoRipple(selected: Boolean, noinline onClick: () -> Unit): Modifier = | |
composed { | |
selectable( | |
selected = selected, | |
onClick = onClick, | |
interactionSource = remember { MutableInteractionSource() }, | |
indication = null | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Modifier.tabIndicatorOffsetNoAnim( | |
currentTabPosition: TabPosition | |
): Modifier = composed( | |
inspectorInfo = debugInspectorInfo { | |
name = "tabIndicatorOffset" | |
value = currentTabPosition | |
} | |
) { | |
fillMaxWidth() | |
.wrapContentSize(Alignment.BottomStart) | |
.offset(x = currentTabPosition.left) | |
.width(currentTabPosition.width) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment