Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
♻️ :: 피드 이미지 수정 버그 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Tmdhoon2 committed Dec 12, 2023
1 parent 54b1a92 commit dfaaf34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ internal fun ReportBug(
alignment = Alignment.Top,
)
PostImage(
uri = { imagePreview },
imagePreview = { imagePreview },
imageUrl = { imageUrl },
) {
focusManager.clearFocus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ internal fun CreatePost(

val launcher = rememberLauncherForActivityResult(ActivityResultContracts.PickVisualMedia()) {
it?.run {
feedViewModel.setButtonEnabled(
enabled = state.title.isNotBlank() && state.content.isNotBlank(),
)
imagePreview = it
attachmentViewModel.setFile(
FileUtil.toFile(
Expand Down Expand Up @@ -182,7 +185,7 @@ internal fun CreatePost(
maxLength = 300,
)
PostImage(
uri = { imagePreview },
imagePreview = { imagePreview },
imageUrl = { details.image },
) {
focusManager.clearFocus()
Expand Down Expand Up @@ -211,7 +214,7 @@ internal fun CreatePost(

@Composable
internal fun PostImage(
uri: () -> Uri?,
imagePreview: () -> Uri?,
imageUrl: () -> String?,
onClick: () -> Unit,
) {
Expand All @@ -235,7 +238,7 @@ internal fun PostImage(
)
AsyncImage(
modifier = Modifier.fillMaxSize(),
model = if (imageUrl().isNullOrBlank()) uri()
model = if (imageUrl().isNullOrBlank() || imagePreview() != null) imagePreview()
else imageUrl(),
contentDescription = stringResource(id = R.string.feed_image),
contentScale = ContentScale.Crop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ internal class FeedViewModel(
}
}

internal fun setButtonEnabled(enabled: Boolean) {
setState(state.value.copy(buttonEnabled = enabled))
}

internal fun fetchPostDetails() {
with(state.value) {
if (feedId != null) {
Expand Down

0 comments on commit dfaaf34

Please sign in to comment.