Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ private fun ImageGrid(
.aspectRatio(1f),
shape = RoundedCornerShape(imageRadius),
contentScale = ContentScale.Crop,
contentDescription = null
contentDescription = null,
showLoadingIndicator = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.spoony.spoony.core.designsystem.component.image

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.RectangleShape
Expand All @@ -10,16 +14,19 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.vectorResource
import coil3.compose.AsyncImage
import coil3.compose.SubcomposeAsyncImage
import coil3.compose.SubcomposeAsyncImageContent
import com.spoony.spoony.R
import com.spoony.spoony.core.designsystem.theme.SpoonyAndroidTheme

@Composable
fun SpoonyImage(
model: Any?,
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
contentScale: ContentScale = ContentScale.Crop,
contentDescription: String? = null
contentDescription: String? = null,
showLoadingIndicator: Boolean = false
) {
if (LocalInspectionMode.current) {
Image(
Expand All @@ -29,11 +36,31 @@ fun SpoonyImage(
modifier = modifier.clip(shape)
)
} else {
AsyncImage(
SubcomposeAsyncImage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오..이건 몰랐네...
기본 AsyncImage는 placeholder에 painter만 가능해서 요거로 한건가요???

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SubcomposeAsyncImage 넣야지 painter 뿐만 아니라 커스텀한 로딩 UI 를 넣을 수 있어서 저렇게 작업했습니다! 사용하진 않았지만loading 상태, success 상태, error 상태를 분기해서 뷰를 구성할 수도 있다고 합니다.

model = model,
contentDescription = contentDescription,
contentScale = contentScale,
modifier = modifier.clip(shape)
modifier = modifier.clip(shape),
loading = {
if (showLoadingIndicator) {
LoadingIndicator()
}
},
success = {
SubcomposeAsyncImageContent()
}
)
}
}

@Composable
private fun LoadingIndicator() {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator(
color = SpoonyAndroidTheme.colors.gray300
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ fun ExploreSearchUserItem(
modifier = Modifier.size(48.dp),
shape = CircleShape,
contentScale = ContentScale.Crop,
contentDescription = null
contentDescription = null,
showLoadingIndicator = true
)
Spacer(modifier = Modifier.width(14.dp))
Column {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ fun MapPlaceDetailCard(
model = url,
modifier = Modifier
.height(103.dp)
.weight(1f)
.weight(1f),
showLoadingIndicator = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fun PlaceDetailImageLazyRow(
model = imageUrl,
shape = RoundedCornerShape(10.dp),
contentScale = ContentScale.Crop,
contentDescription = null
contentDescription = null,
showLoadingIndicator = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ fun PhotoPicker(
model = photo.uri,
modifier = Modifier.fillMaxSize(),
shape = RoundedCornerShape(8.dp),
contentScale = ContentScale.Crop
contentScale = ContentScale.Crop,
showLoadingIndicator = true
)
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_delete_filled_24),
Expand Down