Skip to content

Commit

Permalink
Merge pull request #202 from SWM-KAWAI-MANS/release/v1.0.1
Browse files Browse the repository at this point in the history
Release/v1.0.1
  • Loading branch information
nohjunh authored Sep 26, 2023
2 parents d8ad406 + 5d1d2b8 commit 5d98221
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ fun SetUpMainNavGraph(
navigateToSettings = {
navController.navigate(MainNavRoutes.Settings.route)
},
navigateBack = {
navController.popBackStack()
},
navigateToMyPage = {
navController.navigate(MainNavRoutes.MyPage.route) {
popUpTo(MainNavRoutes.MyPage.route) {
Expand All @@ -119,11 +116,9 @@ fun SetUpMainNavGraph(
battleRunningRoute(
navigateToBattleOnWebSocketError = {
navController.navigate(MainNavRoutes.Battle.route) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
popUpTo(MainNavRoutes.Battle.route) {
inclusive = true
}
launchSingleTop = true // 자기 자신이 또 스택 푸시가 되지 않도록 방지
restoreState = true
}
},
navigateToBattleResult = {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Configurations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Configurations {
const val TARGET_SDK_VERSION = 33
private const val MAJOR_VERSION = 1
private const val MINOR_VERSION = 0
private const val PATCH_VERSION = 0
private const val PATCH_VERSION = 1
const val VERSION_NAME = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
const val VERSION_CODE = 19
const val VERSION_CODE = 20
// kotlinCompilerExtensionVersion
const val COMPOSE = "1.4.5"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import online.partyrun.partyrunapplication.feature.my_page.profile.ProfileScreen
fun NavGraphBuilder.myPageRoute(
onSignOut: () -> Unit,
navigateToSettings: () -> Unit,
navigateBack: () -> Unit,
navigateToMyPage: () -> Unit,
navigateToProfile: () -> Unit,
onShowSnackbar: (String) -> Unit
Expand All @@ -18,7 +17,6 @@ fun NavGraphBuilder.myPageRoute(
MyPageScreen(
onSignOut = onSignOut,
navigateToSettings = navigateToSettings,
navigateBack = navigateBack,
navigateToProfile = navigateToProfile,
onShowSnackbar = onShowSnackbar
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ fun MyPageScreen(
myPageViewModel: MyPageViewModel = hiltViewModel(),
onSignOut: () -> Unit = {},
navigateToSettings: () -> Unit = {},
navigateBack: () -> Unit = {},
navigateToProfile: () -> Unit = {},
onShowSnackbar: (String) -> Unit
) {
Expand All @@ -58,7 +57,6 @@ fun MyPageScreen(
myPageUiState = myPageUiState,
onSignOut = onSignOut,
navigateToSettings = navigateToSettings,
navigateBack = navigateBack,
navigateToProfile = navigateToProfile,
onShowSnackbar = onShowSnackbar,
myPageSnackbarMessage = myPageSnackbarMessage
Expand All @@ -73,7 +71,6 @@ fun Content(
myPageUiState: MyPageUiState,
onSignOut: () -> Unit,
navigateToSettings: () -> Unit,
navigateBack: () -> Unit,
navigateToProfile: () -> Unit,
onShowSnackbar: (String) -> Unit,
myPageSnackbarMessage: String
Expand All @@ -90,7 +87,6 @@ fun Content(
topBar = {
MyPageTopAppBar(
modifier = modifier,
navigateBack = navigateBack,
navigateToSettings = navigateToSettings
)
}
Expand Down Expand Up @@ -119,19 +115,10 @@ fun Content(
@Composable
private fun MyPageTopAppBar(
modifier: Modifier,
navigateBack: () -> Unit,
navigateToSettings: () -> Unit
) {
PartyRunTopAppBar(
modifier = modifier,
navigateToContent = {
IconButton(onClick = { navigateBack() }) {
Icon(
painterResource(id = PartyRunIcons.ArrowBackIos),
contentDescription = stringResource(id = R.string.arrow_back_desc)
)
}
},
titleContent = {
Text(
text = stringResource(id = R.string.my_page_title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import online.partyrun.partyrunapplication.core.designsystem.component.LottieImage
import online.partyrun.partyrunapplication.core.designsystem.component.PartyRunGradientButton
import online.partyrun.partyrunapplication.core.designsystem.component.PartyRunTextInput
import online.partyrun.partyrunapplication.core.designsystem.component.TextInputType
Expand Down Expand Up @@ -182,6 +183,12 @@ private fun ProfileBody(
keyboardController: SoftwareKeyboardController,
focusManager: FocusManager
) {
val updateProgressState by profileViewModel.updateProgressState.collectAsStateWithLifecycle()

if (updateProgressState) {
ProgressIndicator()
}

LaunchedEffect(Unit) {
profileViewModel.initProfileContent(
name = userData.nickName,
Expand Down Expand Up @@ -240,6 +247,18 @@ private fun ProfileBody(
}
}

@Composable
private fun ProgressIndicator() {
Box(
modifier = Modifier
.fillMaxSize()
.zIndex(1f),
contentAlignment = Alignment.Center
) {
LottieImage(modifier = Modifier.size(60.dp), rawAnimation = R.raw.mypage_progress)
}
}

@Composable
@OptIn(ExperimentalComposeUiApi::class)
private fun NickNameSection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ProfileViewModel @Inject constructor(
private val _profileUiState = MutableStateFlow(ProfileUiState())
val profileUiState = _profileUiState.asStateFlow()

private val _updateProgressState = MutableStateFlow(false)
val updateProgressState = _updateProgressState.asStateFlow()

private val _snackbarMessage = MutableStateFlow("")
val snackbarMessage: StateFlow<String> = _snackbarMessage

Expand Down Expand Up @@ -91,6 +94,7 @@ class ProfileViewModel @Inject constructor(
}

fun handlePickedImage(context: Context, uri: Uri) {
_updateProgressState.value = true
val requestBody = context.contentResolver.openInputStream(uri)?.use { inputStream ->
inputStream.readBytes().toRequestBody("image/*".toMediaTypeOrNull())
}
Expand All @@ -109,21 +113,26 @@ class ProfileViewModel @Inject constructor(
}

fun updateUserData() = viewModelScope.launch {
if (passAllConditions()) {
updateUserDataUseCase(
nickName = _profileUiState.value.newNickName
).collect { result ->
result.onEmpty {
saveUserData()
_profileUiState.update { state ->
state.copy(
isProfileUpdateSuccess = true
)
}
}.onFailure { errorMessage, code ->
Timber.e("$code $errorMessage")
_snackbarMessage.value = "변경에 실패하였습니다.\n다시 시도해주세요."
if (!passAllConditions()) return@launch

_updateProgressState.value = true

updateUserDataUseCase(
nickName = _profileUiState.value.newNickName
).collect { result ->
result.onEmpty {
saveUserData()
_profileUiState.update { state ->
state.copy(
isProfileUpdateSuccess = true
)
}
_updateProgressState.value = false
_snackbarMessage.value = "프로필 정보를 변경하였습니다."
}.onFailure { errorMessage, code ->
Timber.e("$code $errorMessage")
_updateProgressState.value = false
_snackbarMessage.value = "변경에 실패하였습니다.\n다시 시도해주세요."
}
}
}
Expand All @@ -136,9 +145,11 @@ class ProfileViewModel @Inject constructor(
).collect { result ->
result.onEmpty {
saveUserData()
_updateProgressState.value = false
_snackbarMessage.value = "프로필 사진이 변경되었습니다."
}.onFailure { errorMessage, code ->
Timber.e("$code $errorMessage")
_updateProgressState.value = false
_snackbarMessage.value = "변경에 실패하였습니다.\n다시 시도해주세요."
}
}
Expand Down
1 change: 1 addition & 0 deletions feature/my_page/src/main/res/raw/mypage_progress.json

Large diffs are not rendered by default.

Binary file modified feature/party/src/main/res/drawable/party_track_10km.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import android.content.Context
import android.content.Intent
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -16,16 +18,19 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.delay
import online.partyrun.partyrunapplication.core.common.Constants.ACTION_START_RUNNING
import online.partyrun.partyrunapplication.core.common.Constants.ACTION_STOP_RUNNING
import online.partyrun.partyrunapplication.core.common.Constants.BATTLE_ID_KEY
import online.partyrun.partyrunapplication.core.designsystem.component.LottieImage
import online.partyrun.partyrunapplication.core.ui.CountdownDialog
import online.partyrun.partyrunapplication.feature.running.R
import online.partyrun.partyrunapplication.feature.running.finish.FinishScreen
Expand Down Expand Up @@ -91,9 +96,9 @@ fun Content(
)

LaunchedEffect(battleId) {
battleId.let { id ->
battleId?.let { id ->
battleContentViewModel.startBattleStream(
battleId = id ?: "",
battleId = id,
navigateToBattleOnWebSocketError = navigateToBattleOnWebSocketError
)
}
Expand Down Expand Up @@ -131,11 +136,39 @@ fun Content(
openRunningExitDialog = openRunningExitDialog
)

BattleScreenState.Finish -> FinishScreen()
is BattleScreenState.Finish -> FinishScreen()
is BattleScreenState.LoadFailed ->
LoadFailedScreen {
navigateToBattleOnWebSocketError()
}
}
}
}

@Composable
fun LoadFailedScreen(
navigateToBattleOnWebSocketError: () -> Unit
) {
// 3초 딜레이 후 navigateToBattleOnWebSocketError 호출
LaunchedEffect(Unit) {
delay(3000L)
navigateToBattleOnWebSocketError()
}

Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = stringResource(id = R.string.battle_loadfailed_comment),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onPrimary
)
LottieImage(modifier = Modifier.size(60.dp), rawAnimation = R.raw.battle_progress)
}
}

@Composable
private fun CheckStartTime(
battleContentUiState: BattleContentUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class BattleContentViewModel @Inject constructor(
private lateinit var runnersState: StateFlow<BattleEvent>

init {
getBattleId()
getUserId()
getBattleId()
}

fun clearSnackbarMessage() {
Expand Down Expand Up @@ -92,6 +92,11 @@ class BattleContentViewModel @Inject constructor(
}.onFailure { errorMessage, code ->
_snackbarMessage.value = "배틀 정보를 가져올 수 없습니다."
Timber.e("$code $errorMessage")
_battleContentUiState.update { state ->
state.copy(
screenState = BattleScreenState.LoadFailed
)
}
}
}
}
Expand Down Expand Up @@ -141,7 +146,7 @@ class BattleContentViewModel @Inject constructor(
}

else -> {
Timber.e("다른 Type의 BattleEvent 수신", it)
Timber.e("다른 Type의 BattleEvent 수신 $it")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ sealed class BattleScreenState {
object Ready : BattleScreenState()
object Running : BattleScreenState()
object Finish : BattleScreenState()
object LoadFailed : BattleScreenState()
}
1 change: 1 addition & 0 deletions feature/running/src/main/res/raw/battle_progress.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions feature/running/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="ic_robot_desc">로봇 이미지</string>
<string name="finish">Finish</string>
<string name="finish_comment">대결이 종료됐습니다.</string>
<string name="battle_loadfailed_comment">잠시 후 메인으로 돌아갑니다.</string>

<string name="exit_dialog_title">대결을 종료하시겠습니까?</string>
<string name="exit_dialog_battle_subtitle">종료 시 현재 대결을 이어 달릴 수 없습니다.</string>
Expand Down

0 comments on commit 5d98221

Please sign in to comment.