Skip to content

Commit

Permalink
♻️ :: collectIsPressedAsState를 활용하여 눌렸을 때 backgroundColor 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Cjsghkd committed Sep 14, 2023
1 parent 5e852dd commit 6238c80
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dotori.dotori_components.components.student_info
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -17,10 +18,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -35,8 +33,6 @@ import com.dotori.dotori_components.theme.MeatballIcon
import com.dotori.dotori_components.theme.White
import com.example.dus.R
import com.skydoves.landscapist.glide.GlideImage
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
fun DotoriStudentInfoListItem(
Expand All @@ -48,8 +44,8 @@ fun DotoriStudentInfoListItem(
role: String,
onOptionClicked: () -> Unit
) {
var isClicked by remember { mutableStateOf(false) }
val coroutineScope = rememberCoroutineScope()
val interactionSource = remember { MutableInteractionSource() }
val isClicked by interactionSource.collectIsPressedAsState()

Row(
modifier = modifier
Expand Down Expand Up @@ -105,16 +101,9 @@ fun DotoriStudentInfoListItem(
Spacer(modifier = Modifier.weight(1f))
MeatballIcon(
modifier = Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
interactionSource = interactionSource,
indication = null,
onClick = {
isClicked = true
onOptionClicked()
coroutineScope.launch {
delay(700L)
isClicked = false
}
}
onClick = onOptionClicked
),
tint = DotoriTheme.colors.neutral30
)
Expand Down

0 comments on commit 6238c80

Please sign in to comment.