|
| 1 | +package com.into.websoso.ui.createFeed.component |
| 2 | + |
| 3 | +import androidx.compose.foundation.Image |
| 4 | +import androidx.compose.foundation.layout.Arrangement |
| 5 | +import androidx.compose.foundation.layout.Box |
| 6 | +import androidx.compose.foundation.layout.PaddingValues |
| 7 | +import androidx.compose.foundation.layout.aspectRatio |
| 8 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 9 | +import androidx.compose.foundation.layout.padding |
| 10 | +import androidx.compose.foundation.layout.size |
| 11 | +import androidx.compose.foundation.lazy.LazyRow |
| 12 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 13 | +import androidx.compose.runtime.Composable |
| 14 | +import androidx.compose.ui.Alignment |
| 15 | +import androidx.compose.ui.Modifier |
| 16 | +import androidx.compose.ui.draw.clip |
| 17 | +import androidx.compose.ui.layout.ContentScale |
| 18 | +import androidx.compose.ui.res.painterResource |
| 19 | +import androidx.compose.ui.tooling.preview.Preview |
| 20 | +import androidx.compose.ui.unit.dp |
| 21 | +import com.into.websoso.core.common.ui.component.AdaptationImage |
| 22 | +import com.into.websoso.core.common.util.clickableWithoutRipple |
| 23 | +import com.into.websoso.core.designsystem.theme.WebsosoTheme |
| 24 | +import com.into.websoso.core.resource.R.drawable.ic_feed_remove_image |
| 25 | + |
| 26 | +@Composable |
| 27 | +fun CreateFeedImageContainer( |
| 28 | + imageUrls: List<String> = listOf( |
| 29 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 30 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 31 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 32 | + ), |
| 33 | + onRemoveClick: (Int) -> Unit, |
| 34 | +) { |
| 35 | + LazyRow( |
| 36 | + modifier = Modifier |
| 37 | + .fillMaxWidth(), |
| 38 | + horizontalArrangement = Arrangement.spacedBy(10.dp), |
| 39 | + contentPadding = PaddingValues(horizontal = 20.dp), |
| 40 | + ) { |
| 41 | + items(imageUrls.size) { index -> |
| 42 | + CreateFeedImageBox( |
| 43 | + imageUrl = imageUrls[index], |
| 44 | + onRemoveClick = { |
| 45 | + onRemoveClick(index) |
| 46 | + }, |
| 47 | + ) |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +@Composable |
| 53 | +private fun CreateFeedImageBox( |
| 54 | + imageUrl: String, |
| 55 | + onRemoveClick: () -> Unit, |
| 56 | +) { |
| 57 | + Box( |
| 58 | + modifier = Modifier |
| 59 | + .size(100.dp) |
| 60 | + .aspectRatio(1f) |
| 61 | + .clip(RoundedCornerShape(8.dp)), |
| 62 | + ) { |
| 63 | + Image( |
| 64 | + painter = painterResource(ic_feed_remove_image), |
| 65 | + contentDescription = null, |
| 66 | + modifier = Modifier |
| 67 | + .size(38.dp) |
| 68 | + .padding(10.dp) |
| 69 | + .align(Alignment.TopEnd) |
| 70 | + .clickableWithoutRipple { onRemoveClick() }, |
| 71 | + ) |
| 72 | + AdaptationImage( |
| 73 | + imageUrl = imageUrl, |
| 74 | + contentScale = ContentScale.Crop, |
| 75 | + ) |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +@Preview |
| 80 | +@Composable |
| 81 | +private fun CreateFeedImageContainerPreview() { |
| 82 | + WebsosoTheme { |
| 83 | + CreateFeedImageContainer( |
| 84 | + imageUrls = listOf( |
| 85 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 86 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 87 | + "https://github.com/user-attachments/assets/e89a02bb-549f-414d-809f-0ab1e8f72c5f", |
| 88 | + ), |
| 89 | + onRemoveClick = {}, |
| 90 | + ) |
| 91 | + } |
| 92 | +} |
0 commit comments