-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardView.kt
More file actions
53 lines (50 loc) · 1.51 KB
/
CardView.kt
File metadata and controls
53 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var status by rememberSaveable {
mutableStateOf(false)
}
ImageCard(status) { clickStatus ->
status = clickStatus
}
}
}
@Composable
fun ImageCard(
status: Boolean,
onClickCallback: (Boolean) -> Unit
) {
Card(
modifier = Modifier
.fillMaxWidth(0.5f)
.padding(16.dp),
shape = RoundedCornerShape(5.dp),
elevation = 3.dp
) {
Box(
modifier = Modifier.height(200.dp)
) {
Image(
painter = painterResource(id = R.drawable.tmp),
contentDescription = "tmp",
contentScale = ContentScale.Crop
)
}
Box(
modifier = Modifier.height (200.dp),
contentAlignment = Alignment.TopEnd
) {
IconButton(onClick = {
onClickCallback(!status)
}) {
Icon(
imageVector = if(status) Icons.Default.Favorite else Icons.Default.FavoriteBorder,
contentDescription = "Favorite",
tint = Color.White
)
}
}
}
}
}