Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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,26 @@ 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) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator(
color = SpoonyAndroidTheme.colors.gray300
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 Box로 꼭 감싸야 하나요?? 인디케이터에도 modifier 넣을 수 있는걸로 알고 있는데 fillMaxSize를 인디케이터에 넣고 box 빼면 원하는대로 안나오려나요?!??

Copy link
Member

Choose a reason for hiding this comment

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

모양은 원하는대로 나올건데 인디케이터 크기를 유지하면서 정중앙에 하려면 저게 맞을거같다는??

}
Copy link
Member

Choose a reason for hiding this comment

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

이거 컴포넌트화 할래말래ㅋㅋ 그냥 private로 때려도 될거같아요

Copy link
Member Author

Choose a reason for hiding this comment

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

아 그거도 좋을 듯!

Copy link
Member Author

Choose a reason for hiding this comment

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

완완

},
success = {
SubcomposeAsyncImageContent()
}
)
}
}
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