Skip to content

Commit

Permalink
Merge pull request #114 from depromeet/feat/#108-seat-intuition-review
Browse files Browse the repository at this point in the history
�[FEAT] 좌석시야 / 직관등록 구현
  • Loading branch information
minju1459 authored Aug 24, 2024
2 parents c56963c + c52d829 commit e7fc0fd
Show file tree
Hide file tree
Showing 43 changed files with 1,794 additions and 42 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
android:exported="false"
android:screenOrientation="portrait"/>

<activity android:name="com.dpm.presentation.seatreview.SelectViewImageActivity"
android:exported="false"
android:screenOrientation="portrait"/>

<activity android:name="com.dpm.presentation.seatreview.ReviewDoneActivity"
android:exported="false"
android:screenOrientation="portrait"/>
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build/kotlin/buildSrcjar-classes.txt

This file was deleted.

Binary file modified buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ data class RequestSeatReviewDto(
val content: String?,
@SerialName("dateTime")
val dateTime: String,
@SerialName("reviewType")
val reviewType: String?,
)

fun RequestSeatReview.toSeatReview() = RequestSeatReviewDto(
Expand All @@ -30,4 +32,5 @@ fun RequestSeatReview.toSeatReview() = RequestSeatReviewDto(
bad = bad,
content = content,
dateTime = dateTime,
reviewType = reviewType,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ data class RequestSeatReview(
val bad: List<String>,
val content: String?,
val dateTime: String,
val reviewType: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.dpm.domain.model.seatreview

enum class ReviewMethod {
VIEW,
FEED,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dpm.presentation.home

import ReviewData
import android.content.Intent
import android.os.Bundle
import android.view.View
Expand All @@ -10,16 +11,20 @@ import com.depromeet.presentation.databinding.ActivityHomeBinding
import com.dpm.core.base.BaseActivity
import com.dpm.core.state.UiState
import com.dpm.designsystem.SpotImageSnackBar
import com.dpm.designsystem.SpotSnackBar
import com.dpm.domain.entity.response.home.ResponseHomeFeed
import com.dpm.domain.entity.response.viewfinder.ResponseStadiums
import com.dpm.domain.model.seatreview.ReviewMethod
import com.dpm.presentation.extension.dpToPx
import com.dpm.presentation.home.adapter.StadiumAdapter
import com.dpm.presentation.home.dialog.LevelDescriptionDialog
import com.dpm.presentation.home.dialog.LevelupDialog
import com.dpm.presentation.home.viewmodel.HomeGuiViewModel
import com.dpm.presentation.seatrecord.SeatRecordActivity
import com.dpm.presentation.seatrecord.adapter.LinearSpacingItemDecoration
import com.dpm.presentation.seatreview.ReviewActivity
import com.dpm.presentation.seatreview.dialog.ReviewTypeDialog
import com.dpm.presentation.seatreview.dialog.feed.FeedUploadDialog
import com.dpm.presentation.seatreview.dialog.view.ViewUploadDialog
import com.dpm.presentation.setting.SettingActivity
import com.dpm.presentation.util.Utils
import com.dpm.presentation.viewfinder.StadiumActivity
Expand All @@ -34,6 +39,12 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
const val STADIUM_EXTRA_ID = "stadium_id"
private const val START_SPACING_DP = 16
private const val BETWEEN_SPADING_DP = 8
private const val VIEW_UPLOAD_DIALOG = "ViewUploadDialog"
private const val FEED_UPLOAD_DIALOG = "FeedUploadDialog"
private const val REVIEW_DATA = "REVIEW_DATA"
private const val DIALOG_TYPE = "DIALOG_TYPE"
private const val CANCEL_SNACKBAR = "CANCEL_SNACKBAR"
private const val UPLOAD_SNACKBAR = "UPLOAD_SNACKBAR"
}

private val homeViewModel: HomeGuiViewModel by viewModels()
Expand All @@ -54,11 +65,40 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
}

private fun initView() {
initReviewDialog()
initViewStatusBar()
homeViewModel.getStadiums()
setStadiumAdapter()
}

private fun initReviewDialog() {
val reviewData = intent.getParcelableExtra<ReviewData>(REVIEW_DATA)

when (intent?.getSerializableExtra(DIALOG_TYPE) as? ReviewMethod) {
ReviewMethod.VIEW -> ViewUploadDialog().show(supportFragmentManager, VIEW_UPLOAD_DIALOG)
ReviewMethod.FEED -> FeedUploadDialog().apply {
arguments = Bundle().apply { putParcelable(REVIEW_DATA, reviewData) }
}.show(supportFragmentManager, FEED_UPLOAD_DIALOG)
else -> {}
}

intent.getBooleanExtra(CANCEL_SNACKBAR, false).takeIf { it }?.run {
makeSpotImageAppbar("다음에는 좌석 시야 공유도 기대할게요!")
}

intent.getBooleanExtra(UPLOAD_SNACKBAR, false).takeIf { it }?.run {
SpotSnackBar.make(
view = binding.root,
message = "시야찾기에 내 게시글이 올라갔어요!",
endMessage = "확인하러 가기",
) {
// TODO : onclick -> 방금 작성한 시야 후기 상세페이지 게시물 화면으로 이동
}.show()
}
}



private fun initEvent() = with(binding) {
clHomeArchiving.setOnClickListener { startSeatRecordActivity() }
ivHomeInfo.setOnClickListener { showLevelDescriptionDialog() }
Expand Down Expand Up @@ -215,7 +255,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
}

private fun navigateToReviewActivity() {
Intent(this, ReviewActivity::class.java).apply { startActivity(this) }
ReviewTypeDialog().show(supportFragmentManager, "MyDialog")
}

private fun setHomeFeedShimmer(isLoading: Boolean) = with(binding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.dpm.core.base.BindingFragment
import com.depromeet.presentation.R
import com.depromeet.presentation.databinding.FragmentEditReviewBinding
import com.dpm.presentation.seatrecord.viewmodel.SeatRecordViewModel
import com.dpm.presentation.seatreview.dialog.DatePickerDialog
import com.dpm.presentation.seatreview.dialog.main.DatePickerDialog
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dpm.presentation.seatreview

import ReviewData
import android.content.Context
import android.content.Intent
import android.net.Uri
Expand All @@ -20,13 +21,15 @@ 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.domain.model.seatreview.ReviewMethod
import com.dpm.presentation.extension.setOnSingleClickListener
import com.dpm.presentation.extension.toast
import com.dpm.presentation.home.HomeActivity
import com.dpm.presentation.seatreview.dialog.DatePickerDialog
import com.dpm.presentation.seatreview.dialog.ImageUploadDialog
import com.dpm.presentation.seatreview.dialog.ReviewMySeatDialog
import com.dpm.presentation.seatreview.dialog.SelectSeatDialog
import com.dpm.presentation.seatreview.dialog.main.DatePickerDialog
import com.dpm.presentation.seatreview.dialog.main.ImageUploadDialog
import com.dpm.presentation.seatreview.dialog.main.ReviewMySeatDialog
import com.dpm.presentation.seatreview.dialog.main.SelectSeatDialog
import com.dpm.presentation.seatreview.viewmodel.ReviewViewModel
import com.dpm.presentation.util.Utils
import dagger.hilt.android.AndroidEntryPoint
import java.io.FileNotFoundException
Expand All @@ -48,9 +51,13 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
private const val SELECT_SEAT_DIALOG = "SelectSeatDialog"
private const val DATE_PICKER_DIALOG_TAG = "DatePickerDialogTag"
private const val IMAGE_UPLOAD_DIALOG = "ImageUploadDialog"
private const val REVIEW_DATA = "REVIEW_DATA"
private const val METHOD_KEY = "METHOD_KEY"
private const val DIALOG_TYPE = "DIALOG_TYPE"
}

private val viewModel by viewModels<ReviewViewModel>()
private val method by lazy { intent.getStringExtra(METHOD_KEY)?.let { ReviewMethod.valueOf(it) } }
private val selectedImage: List<ImageView> by lazy {
listOf(
binding.ivFirstImage,
Expand Down Expand Up @@ -82,6 +89,7 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
}

private fun initView() {
initMethodNaming()
viewModel.getStadiumName()
initDatePickerDialog()
initUploadDialog()
Expand Down Expand Up @@ -110,6 +118,22 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
}
}

private fun initMethodNaming() {
when (method) {
ReviewMethod.VIEW -> {
binding.tvTitle.text = "좌석의 시야를 공유해보세요"
binding.tvAddImage.text = "야구장 시야 사진을\n올려주세요"
binding.tvReviewMySeat.text = "내 시야 후기"
}
ReviewMethod.FEED -> {
binding.tvTitle.text = "경기의 순간을 간직해보세요"
binding.tvAddImage.text = "직관후기 사진을\n올려주세요"
binding.tvReviewMySeat.text = "내 직관 후기"
}
null -> {}
}
}

private fun observeReviewViewModel() {
viewModel.selectedImages.asLiveData().observe(this) { image ->
updateNextButtonState()
Expand Down Expand Up @@ -181,6 +205,18 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
tvNumber.visibility = VISIBLE
}

2 -> {
tvSeatColor.visibility = VISIBLE
tvSeatColor.text = seatZone
tvSeatBlock.text = viewModel.getBlockListName(block)
tvBlock.visibility = VISIBLE
tvColumnNumber.visibility = GONE
tvColumn.visibility = GONE
tvSeatNumber.visibility = VISIBLE
tvSeatNumber.text = number
tvNumber.visibility = VISIBLE
}

else -> {
tvSeatColor.visibility = VISIBLE
tvSeatColor.text = seatZone
Expand Down Expand Up @@ -253,7 +289,9 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
if (supportFragmentManager.findFragmentByTag(REVIEW_MY_SEAT_DIALOG) == null &&
supportFragmentManager.findFragmentByTag(SELECT_SEAT_DIALOG) == null
) {
ReviewMySeatDialog().show(supportFragmentManager, REVIEW_MY_SEAT_DIALOG)
ReviewMySeatDialog().apply {
arguments = Bundle().apply { putString(METHOD_KEY, method?.name) }
}.show(supportFragmentManager, REVIEW_MY_SEAT_DIALOG)
}
}

Expand Down Expand Up @@ -423,7 +461,15 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
private fun observeUploadImageToS3() {
viewModel.count.asLiveData().observe(this) {
if (it == selectedImageUris.size && it != 0) {
viewModel.postSeatReview()
when (method) {
ReviewMethod.VIEW -> {
viewModel.postSeatReview(ReviewMethod.VIEW)
}
ReviewMethod.FEED -> {
viewModel.postSeatReview(ReviewMethod.FEED)
}
null -> {}
}
}
}
}
Expand All @@ -432,11 +478,29 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
viewModel.postReviewState.asLiveData().observe(this) { state ->
when (state) {
is UiState.Success -> {
Intent(this, ReviewDoneActivity::class.java).apply {
startActivity(this)
val dialogType = when (method) {
ReviewMethod.VIEW -> ReviewMethod.VIEW
ReviewMethod.FEED -> ReviewMethod.FEED
else -> null
}
val reviewData = ReviewData(
selectedColumn = viewModel.selectedColumn.value,
selectedNumber = viewModel.selectedNumber.value,
preSignedUrlImages = viewModel.preSignedUrlImages.value,
selectedGoodReview = viewModel.selectedGoodReview.value,
selectedBadReview = viewModel.selectedBadReview.value,
detailReviewText = viewModel.detailReviewText.value,
selectedDate = viewModel.selectedDate.value,
blockId = viewModel.selectedBlockId.value,
)
dialogType?.let {
Intent(this, HomeActivity::class.java).apply {
putExtra(DIALOG_TYPE, dialogType)
putExtra(REVIEW_DATA, reviewData)
startActivity(this)
}
}
}

is UiState.Failure -> {
toast("리뷰 등록 실패: $state")
}
Expand Down
Loading

0 comments on commit e7fc0fd

Please sign in to comment.