Skip to content

Commit

Permalink
Merge pull request #47 from Nexters/fix/share-link
Browse files Browse the repository at this point in the history
테스트 링크 공유 버그 수정
  • Loading branch information
DwEnn authored Nov 8, 2023
2 parents c51f0d6 + 7deafca commit aa557b5
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 17 deletions.
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.keyme.presentation.dailykeymetest

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -58,8 +59,8 @@ fun DailyKeymeTestRoute(
if (showTutorial) navigateToTutorial()

val myCharacter by dailyKeymeTestViewModel.myCharacterState.collectAsStateWithLifecycle()
val dailyKeymeTest by dailyKeymeTestViewModel.dailyKeymeTestState.collectAsStateWithLifecycle()
val dailyKeymeTestStatistic by dailyKeymeTestViewModel.dailyKeymeTestStatisticState.collectAsStateWithLifecycle()
val dailyKeymeTest by dailyKeymeTestViewModel.keymeTestState.collectAsStateWithLifecycle()
val dailyKeymeTestStatistic by dailyKeymeTestViewModel.keymeTestStatisticState.collectAsStateWithLifecycle()

val context = LocalContext.current

Expand All @@ -77,7 +78,12 @@ fun DailyKeymeTestRoute(
navigateToTakeKeymeTest(dailyKeymeTest.testId)
},
onShareClick = {
context.startShareActivity(KeymeLinkUtil.getTestLink(dailyKeymeTest.testId))
val shareTestLink = KeymeLinkUtil.getTestLink(dailyKeymeTest.testId)
if (shareTestLink.isNotEmpty()) {
context.startShareActivity(KeymeLinkUtil.getTestLink(dailyKeymeTest.testId))
} else {
Toast.makeText(context, "테스트 정보를 가져오는데 실패했습니다.", Toast.LENGTH_SHORT).show()
}
},
onQuestionStatisticClick = navigateToQuestionResult,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.keyme.presentation.dailykeymetest
import com.keyme.domain.entity.member.Member
import com.keyme.domain.entity.response.Test
import com.keyme.domain.entity.response.TestStatistic
import com.keyme.domain.usecase.GetDailyKeymeTestUseCase
import com.keyme.domain.usecase.GetKeymeTestStatisticUseCase
import com.keyme.domain.usecase.GetMyCharacterUseCase
import com.keyme.domain.usecase.GetOnboardingKeymeTestUseCase
Expand All @@ -12,13 +11,16 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn
import javax.inject.Inject

@HiltViewModel
class DailyKeymeTestViewModel @Inject constructor(
private val getMyCharacterUseCase: GetMyCharacterUseCase,
private val getDailyKeymeTestUseCase: GetDailyKeymeTestUseCase,
private val getKeymeTestStatisticUseCase: GetKeymeTestStatisticUseCase,
private val getOnboardingKeymeTestUseCase: GetOnboardingKeymeTestUseCase,
) : BaseViewModel() {
Expand All @@ -29,23 +31,29 @@ class DailyKeymeTestViewModel @Inject constructor(
scope = baseViewModelScope,
)

private val _dailyKeymeTestState = MutableStateFlow(Test.EMPTY)
val dailyKeymeTestState = _dailyKeymeTestState.asStateFlow()
private val _keymeTestState = MutableStateFlow(Test.EMPTY)
val keymeTestState = _keymeTestState.asStateFlow()

private val _dailyKeymeTestStatisticState = MutableStateFlow<TestStatistic?>(null)
val dailyKeymeTestStatisticState = _dailyKeymeTestStatisticState.asStateFlow()
private val _keymeTestStatisticState = MutableStateFlow<TestStatistic?>(null)
val keymeTestStatisticState = _keymeTestStatisticState.asStateFlow()

init {
load()
}

private fun load() {
// apiCall(apiRequest = { getDailyKeymeTestUseCase() }) {
// NOTE: 데일리 문제를 제공하는 대신 온보딩 문제를 계속 공유할 수 있게 하는 플로우로 수정 방향 생각중
// NOTE: 데일리 문제를 제공하는 대신 온보딩 문제를 계속 공유할 수 있게 하는 플로우로 수정
apiCall(apiRequest = { getOnboardingKeymeTestUseCase() }) {
apiCall(apiRequest = { getKeymeTestStatisticUseCase(it.testId) }) { statistic ->
_dailyKeymeTestStatisticState.value = statistic
}
_keymeTestState.value = it
}

_keymeTestState
.filter { it != Test.EMPTY }
.distinctUntilChanged()
.onEach {
apiCall(apiRequest = { getKeymeTestStatisticUseCase(it.testId) }) { statistic ->
_keymeTestStatisticState.value = statistic
}
}.launchIn(baseViewModelScope)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.keyme.presentation.myprofile.ui

import android.widget.Toast
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down Expand Up @@ -96,7 +97,11 @@ fun MyProfileScreen(
val context = LocalContext.current
EmptyStatistics(
onShareClick = {
context.startShareActivity(myProfileUiState.testLink)
if (myProfileUiState.testLink.isNotEmpty()) {
context.startShareActivity(myProfileUiState.testLink)
} else {
Toast.makeText(context, "테스트 정보를 가져오는데 실패했습니다.", Toast.LENGTH_SHORT).show()
}
},
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.keyme.presentation.utils

object Consts {
const val testLinkUrl = "https://keyme-frontend.vercel.app/test/"
const val testLinkUrl = "https://web.keyme.space/test/"

// 이용약관
const val termsOfUseUrl = "https://keyme.notion.site/Keyme-b1f3902d8fe04b97be6d8835119887cd?pvs=4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.keyme.presentation.utils

object KeymeLinkUtil {
fun getTestLink(testId: Int) = "${Consts.testLinkUrl}$testId"
fun getTestLink(testId: Int): String {
return if (testId != 0) {
"${Consts.testLinkUrl}$testId"
} else {
""
}
}
}

0 comments on commit aa557b5

Please sign in to comment.