Skip to content

Commit

Permalink
Merge pull request #146 from depromeet/fix/#144-viewfinder-skill-qa-v1
Browse files Browse the repository at this point in the history
[FIX] 시야찾기 기능 QA V1
  • Loading branch information
Jokwanhee authored Aug 27, 2024
2 parents 5b4a365 + 039a997 commit cda4297
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 91 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/dpm/spot/MyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class MyApp : Application() {
} else {
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(true)
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
// MixpanelManager.initialize(this)
MixpanelManager.initialize(this)
}
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY)
// TODO : 데이터 트래킹 Dev 작동 확인 -> release 모드 실행
MixpanelManager.initialize(this)
// MixpanelManager.initialize(this)
}
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object Constants {
const val compileSdk = 34
const val minSdk = 28
const val targetSdk = 34
var versionCode = 2
var versionName = "1.0.0"
var versionCode = 3
var versionName = "1.0.1"
}
2 changes: 1 addition & 1 deletion presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
// TODO : 데이터 트래킹 Dev 작동 확인 -> prod.mixpanel_token 교체
buildConfigField("String", "MIXPANEL_TOKEN", getApiKey("dev.mixpanel_token"))
buildConfigField("String", "MIXPANEL_TOKEN", getApiKey("prod.mixpanel_token"))
}

composeOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fun StadiumDetailScreen(
)
}
)
Spacer(modifier = Modifier.height(40.dp))
Spacer(modifier = Modifier.height(20.dp))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fun StadiumReviewContent(
)
)
),
error = painterResource(id = com.depromeet.designsystem.R.drawable.ic_default_profile),
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
Expand Down Expand Up @@ -294,15 +295,16 @@ fun StadiumReviewContent(
contentScale = ContentScale.FillHeight
)
}
}
if (firstReview && isFirstShare) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(end = 16.dp),
contentAlignment = Alignment.CenterEnd
) {
ShareTooltip(bias = 0.875f, content = "카카오톡으로 같이가는 친구에게 공유하기")
if (firstReview && isFirstShare) {
Box(
modifier = Modifier
.offset(y = 45.dp)
.fillMaxWidth()
.padding(end = 16.dp),
contentAlignment = Alignment.CenterEnd
) {
ShareTooltip(bias = 0.875f, content = "카카오톡으로 같이가는 친구에게 공유하기")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.BrushPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -140,6 +141,7 @@ fun DetailContentHeader(
)
)
),
error = painterResource(id = com.depromeet.designsystem.R.drawable.ic_default_profile),
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

enum class Sort {
Expand Down Expand Up @@ -67,120 +68,132 @@ class StadiumDetailViewModel @Inject constructor(

fun updateLike(id: Long) {
viewModelScope.launch {
viewfinderRepository.updateLike(id.toInt())
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.reviews.map { review ->
if (review.id == id) {
if (review.isLike) {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount - 1
)
viewfinderRepository.updateLike(id.toInt()).onSuccess {
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.reviews.map { review ->
if (review.id == id) {
if (review.isLike) {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount - 1
)
} else {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount + 1
)
}
} else {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount + 1
)
review
}
} else {
review
}
currentState.copy(reviews = updatedReviews)
}
currentState.copy(reviews = updatedReviews)
}

else -> currentState
else -> currentState
}
}.onFailure {
Timber.e("error : ${it.message}")
}
}
}

fun updateTopReviewLike(id: Long) {
viewModelScope.launch {
viewfinderRepository.updateLike(id.toInt())
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.topReviewImages.map { review ->
if (review.id == id) {
if (review.isLike) {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount - 1
)
viewfinderRepository.updateLike(id.toInt()).onSuccess {
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.topReviewImages.map { review ->
if (review.id == id) {
if (review.isLike) {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount - 1
)
} else {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount + 1
)
}
} else {
review.copy(
isLike = !review.isLike,
likesCount = review.likesCount + 1
)
review
}
} else {
review
}
currentState.copy(topReviewImages = updatedReviews)
}
currentState.copy(topReviewImages = updatedReviews)
}

else -> currentState
else -> currentState
}
}.onFailure {
Timber.e("error : ${it.message}")
}
}
}

fun updateScrap(id: Long) {
viewModelScope.launch {
viewfinderRepository.updateScrap(id.toInt())
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.reviews.map { review ->
if (review.id == id) {
if (review.isScrap) {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount - 1
)
viewfinderRepository.updateScrap(id.toInt()).onSuccess {
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.reviews.map { review ->
if (review.id == id) {
if (review.isScrap) {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount - 1
)
} else {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount + 1
)
}
} else {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount + 1
)
review
}
} else {
review
}
currentState.copy(reviews = updatedReviews)
}
currentState.copy(reviews = updatedReviews)
}

else -> currentState
else -> currentState
}
}.onFailure {
Timber.e("error : ${it.message}")
}
}
}

fun updateTopReviewScrap(id: Long) {
viewModelScope.launch {
viewfinderRepository.updateScrap(id.toInt())
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.topReviewImages.map { review ->
if (review.id == id) {
if (review.isScrap) {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount - 1
)
viewfinderRepository.updateScrap(id.toInt()).onSuccess {
_detailUiState.value = when (val currentState = _detailUiState.value) {
is StadiumDetailUiState.ReviewsData -> {
val updatedReviews = currentState.topReviewImages.map { review ->
if (review.id == id) {
if (review.isScrap) {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount - 1
)
} else {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount + 1
)
}
} else {
review.copy(
isScrap = !review.isScrap,
scrapsCount = review.scrapsCount + 1
)
review
}
} else {
review
}
currentState.copy(topReviewImages = updatedReviews)
}
currentState.copy(topReviewImages = updatedReviews)
}

else -> currentState
else -> currentState
}
}.onFailure {
Timber.e("error : ${it.message}")
}
}
}
Expand Down

0 comments on commit cda4297

Please sign in to comment.