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
@Composable | |
fun SaveableLaunchedEffect( | |
key1: Any?, | |
block: suspend CoroutineScope.() -> Unit, | |
) { | |
var launched by rememberSaveable(key1) { | |
mutableStateOf(false) | |
} | |
if (!launched) { | |
LaunchedEffect(key1) { |
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
#!/bin/bash | |
# don't forget to do `chmod +x screencap.sh` in the script location | |
adb devices | tail -n +2 | while read line | |
do | |
deviceId=$(echo $line | awk '{print $1}') | |
if [ -z "${deviceId}" ]; then | |
continue | |
fi |
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.clickableClipped( | |
shape: Shape, | |
enabled: Boolean = true, | |
onClickLabel: String? = null, | |
role: Role? = null, | |
onClick: () -> Unit, | |
) = composed { | |
val interactionSource = remember { | |
MutableInteractionSource() | |
} |
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
@Composable | |
fun FpsCounter( | |
modifier: Modifier = Modifier, | |
) { | |
var fps by remember { | |
mutableStateOf("") | |
} | |
LaunchedEffect(Unit) { | |
val frames = mutableListOf<Long>() | |
while (true) { |
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
@Composable | |
inline fun LtrRow( | |
modifier: Modifier = Modifier, | |
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, | |
verticalAlignment: Alignment.Vertical = Alignment.Top, | |
crossinline content: @Composable RowScope.() -> Unit | |
) { | |
val direction = LocalLayoutDirection.current | |
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) { | |
Row( |
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.swipeableTopBottom(onTop: () -> Unit, onBottom: () -> Unit): Modifier = composed { | |
var width by rememberSaveable { mutableStateOf(0f) } | |
val swipeableState = rememberSwipeableState( | |
SwipeDirection.Initial, | |
animationSpec = snap() | |
) | |
val anchorWidth = remember(width) { | |
if (width == 0f) { | |
1f | |
} else { |
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.swipeableLeftRight(onLeft: () -> Unit, onRight: () -> Unit): Modifier = composed { | |
var width by rememberSaveable { mutableStateOf(0f) } | |
val swipeableState = rememberSwipeableState( | |
SwipeDirection.Initial, | |
animationSpec = snap() | |
) | |
val anchorWidth = remember(width) { | |
if (width == 0f) { | |
1f | |
} else { |
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
@Composable | |
fun <I, O> rememberLambda(lambda: (I) -> O) = remember { lambda } | |
@Composable | |
fun <I, O> rememberLambda( | |
key1: Any?, | |
lambda: (I) -> O | |
) = remember(key1) { lambda } | |
@Composable |
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
@Composable | |
fun MiddleEllipsisText( | |
text: String, | |
modifier: Modifier = Modifier, | |
color: Color = Color.Unspecified, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
fontStyle: FontStyle? = null, | |
fontWeight: FontWeight? = null, | |
fontFamily: FontFamily? = null, | |
letterSpacing: TextUnit = TextUnit.Unspecified, |
NewerOlder