From e5e3e96a9e4265d60050a33f51e88fc3058c57ff Mon Sep 17 00:00:00 2001 From: pmj1459 <76741702+minju1459@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:57:58 +0900 Subject: [PATCH] =?UTF-8?q?[feat/#104]=20=EC=A2=8C=EC=84=9D=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D,=20=EB=82=B4=20=EC=8B=9C=EC=95=BC=20=ED=9B=84?= =?UTF-8?q?=EA=B8=B0=20=EC=9E=85=EB=A0=A5=20=EC=83=81=ED=83=9C=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EC=8A=A4=EB=82=B5=EB=B0=94=20=EB=B0=8F=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EB=B2=84=ED=8A=BC=20UI=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/seatreview/ReviewActivity.kt | 56 +++++++++++++++---- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt b/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt index 22f0b4e2..ace65b3b 100644 --- a/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt @@ -19,6 +19,7 @@ import com.depromeet.presentation.R import com.depromeet.presentation.databinding.ActivityReviewBinding import com.dpm.core.base.BaseActivity import com.dpm.core.state.UiState +import com.dpm.designsystem.SpotImageSnackBar import com.dpm.presentation.extension.setOnSingleClickListener import com.dpm.presentation.extension.toast import com.dpm.presentation.home.HomeActivity @@ -326,11 +327,12 @@ class ReviewActivity : BaseActivity({ val isSelectedNumberFilled = viewModel.selectedNumber.value.isNotEmpty() with(binding.tvUploadBtn) { - isEnabled = isSelectedDateFilled && isSelectedImageFilled && + val isReadyToUpload = isSelectedDateFilled && isSelectedImageFilled && (isSelectedGoodBtnFilled || isSelectedBadBtnFilled) && isSelectedBlockFilled && (isSelectedColumnFilled || isSelectedNumberFilled) - if (isEnabled) { + + if (isReadyToUpload) { setBackgroundResource(R.drawable.rect_action_enabled_fill_8) } else { setBackgroundResource(R.drawable.rect_action_disabled_fill_8) @@ -359,15 +361,35 @@ class ReviewActivity : BaseActivity({ private fun initEventUploadBtn() { binding.tvUploadBtn.setOnSingleClickListener { - val uniqueImageUris = selectedImageUris.distinct() - uniqueImageUris.forEach { imageUriString -> - val imageUri = Uri.parse(imageUriString) - val fileExtension = getFileExtension(this, imageUri) - val imageData = readImageData(this, imageUri) - if (imageData != null) { - viewModel.requestPreSignedUrl(fileExtension) - } else { - toast("파일을 읽을 수 없습니다.") + val isSelectedGoodBtnFilled = viewModel.selectedGoodReview.value.isNotEmpty() + val isSelectedBadBtnFilled = viewModel.selectedBadReview.value.isNotEmpty() + val isSelectedBlockFilled = viewModel.selectedBlock.value.isNotEmpty() + val isSelectedColumnFilled = viewModel.selectedColumn.value.isNotEmpty() + val isSelectedNumberFilled = viewModel.selectedNumber.value.isNotEmpty() + when { + !(isSelectedGoodBtnFilled || isSelectedBadBtnFilled) && (isSelectedBlockFilled || (isSelectedColumnFilled || isSelectedNumberFilled)) -> { + binding.tvUploadBtn.setBackgroundResource(R.drawable.rect_action_disabled_fill_8) + makeSpotImageAppbar("내 시야 후기를 등록해주세요", 67) + } + !(isSelectedBlockFilled && (isSelectedColumnFilled || isSelectedNumberFilled)) && (isSelectedGoodBtnFilled || isSelectedBadBtnFilled) -> { + binding.tvUploadBtn.setBackgroundResource(R.drawable.rect_action_disabled_fill_8) + makeSpotImageAppbar("좌석을 선택해주세요", 88) + } + ((!isSelectedGoodBtnFilled && !isSelectedBadBtnFilled) || !(isSelectedBlockFilled && (isSelectedColumnFilled || isSelectedNumberFilled))) -> { + binding.tvUploadBtn.setBackgroundResource(R.drawable.rect_action_disabled_fill_8) + } + else -> { + val uniqueImageUris = selectedImageUris.distinct() + uniqueImageUris.forEach { imageUriString -> + val imageUri = Uri.parse(imageUriString) + val fileExtension = getFileExtension(this, imageUri) + val imageData = readImageData(this, imageUri) + if (imageData != null) { + viewModel.requestPreSignedUrl(fileExtension) + } else { + toast("파일을 읽을 수 없습니다.") + } + } } } } @@ -418,8 +440,20 @@ class ReviewActivity : BaseActivity({ is UiState.Failure -> { toast("리뷰 등록 실패: $state") } + else -> {} } } } + + private fun makeSpotImageAppbar(message: String, marginHorizontal: Int) { + SpotImageSnackBar.make( + view = binding.root, + message = message, + messageColor = com.depromeet.designsystem.R.color.color_foreground_white, + icon = com.depromeet.designsystem.R.drawable.ic_alert_circle, + iconColor = com.depromeet.designsystem.R.color.color_error_secondary, + marginHorizontal = marginHorizontal, + ).show() + } }