Skip to content

Instantly share code, notes, and snippets.

View AungThiha's full-sized avatar

Aung Thiha AungThiha

View GitHub Profile
@AungThiha
AungThiha / ComposeUiTest.md
Last active December 9, 2023 08:13
Jetpack Compose: Assert Intent Data Consumption in Instrumented Tests

Gists for medium article titled Jetpack Compose: Assert Intent Data Consumption in Instrumented Tests

@AungThiha
AungThiha / RecipeDetail5.kt
Created September 16, 2023 10:14
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
val actionsProperties = motionProperties("actions")
Box(
modifier = Modifier
.background(actionsProperties.value.color("background"))
.layoutId("actionsTopBg")
)
Row(
@AungThiha
AungThiha / motion_scene5.json5
Last active September 16, 2023 10:07
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
{
ConstraintSets: {
start: {
...
actionsTopBg: {
width: 'spread',
height: 0,
start: ['parent', 'start', 16],
end: ['parent', 'end', 16],
top: ['date','bottom'],
@AungThiha
AungThiha / RecipeDetail4.kt
Created September 16, 2023 09:53
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
val actionsProperties = motionProperties("actions") // new code
Row(
modifier = Modifier
.background(actionsProperties.value.color("background")) // new code
.layoutId("actions")
...
@AungThiha
AungThiha / motion_scene4.json5
Created September 16, 2023 09:46
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
{
ConstraintSets: {
start: {
...
actions: {
...
top: ['date','bottom'],
custom: {
background: '#444444'
}
@AungThiha
AungThiha / RecipeDetai4.kt
Created September 15, 2023 17:51
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
Box(
modifier = Modifier
.anchoredDraggable(anchoredDraggableState, Orientation.Vertical)
.shadow(elevation = 4.dp, shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
.background(
Color.White,
shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
)
.layoutId("contentBg")
@AungThiha
AungThiha / RecipeDetail3.kt
Last active September 15, 2023 17:50
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
val draggedDownAnchorTop = with(LocalDensity.current) { 200.dp.toPx() }
val anchors = DraggableAnchors {
AnchoredDraggableCardState.DRAGGED_DOWN at draggedDownAnchorTop
AnchoredDraggableCardState.DRAGGED_UP at 0f
}
val density = LocalDensity.current
val anchoredDraggableState = remember {
AnchoredDraggableState(
initialValue = AnchoredDraggableCardState.DRAGGED_DOWN,
@AungThiha
AungThiha / RecipeDetailLoadingMotionScene.kt
Created September 15, 2023 17:32
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
val context = LocalContext.current
val motionSceneContent = remember {
context.resources
.openRawResource(R.raw.motion_scene)
.readBytes()
.decodeToString()
}
MotionLayout(
@AungThiha
AungThiha / AnchoredDraggableCardState.kt
Created September 15, 2023 17:21
Used in article "Jetpack Compose Anchored Draggable Item in MotionLayout"
enum class AnchoredDraggableCardState {
DRAGGED_DOWN, DRAGGED_UP
}
@AungThiha
AungThiha / motion_scene3.json5
Last active September 15, 2023 16:42
Used in article named "Jetpack Compose Anchored Draggable Item in MotionLayout"
...
end: {
headerImage: {
width: "spread",
height: 250,
top: ['parent', 'top', 0],
start: ['parent', 'start', 0],
end: ['parent', 'end', 0],
translationY: -250,
alpha: 0.3,