From f53f3d83e49c91b9431e44e013b7423fe7df684d Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Thu, 22 Aug 2024 23:11:39 +0900 Subject: [PATCH 1/4] Fix day of week list sorted on BoardBottomView. --- .../mission_mate/feature/board/component/BoardBottomView.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardBottomView.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardBottomView.kt index 632c3b2e..b68c8ecf 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardBottomView.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardBottomView.kt @@ -27,7 +27,6 @@ import com.goalpanzi.mission_mate.feature.board.model.MissionDetail import com.goalpanzi.mission_mate.feature.board.model.MissionState import com.goalpanzi.mission_mate.feature.onboarding.component.StableImage import com.goalpanzi.mission_mate.feature.onboarding.model.VerificationTimeType -import com.goalpanzi.mission_mate.feature.onboarding.util.getStringId @Composable fun BoardBottomView( @@ -52,9 +51,7 @@ fun BoardBottomView( ) { StableImage(drawableResId = com.goalpanzi.mission_mate.core.designsystem.R.drawable.ic_time) Text( - text = missionDetail.missionDays.map { - stringResource(id = it.getStringId()) - }.joinToString(" ") + " | " + when(VerificationTimeType.valueOf(missionDetail.timeOfDay)){ + text = missionDetail.missionDaysOfWeekTextLocale.joinToString(" ") + " | " + when(VerificationTimeType.valueOf(missionDetail.timeOfDay)){ VerificationTimeType.MORNING -> stringResource(id = R.string.board_verification_am_time_limit) VerificationTimeType.AFTERNOON -> stringResource(id = R.string.board_verification_pm_time_limit) VerificationTimeType.EVERYDAY -> stringResource(id = R.string.board_verification_all_day_time_limit) From 30d478158de23c27d3e8c93035156ea88e7aa1a7 Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Fri, 23 Aug 2024 02:50:19 +0900 Subject: [PATCH 2/4] Fix to show profile create dialog once. --- .../onboarding/screen/OnboardingViewModel.kt | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt index 55665b62..84123548 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt @@ -3,13 +3,14 @@ package com.goalpanzi.mission_mate.feature.onboarding.screen import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.goalpanzi.core.model.UserProfile +import com.goalpanzi.core.model.base.NetworkResult import com.goalpanzi.mission_mate.core.domain.usecase.GetJoinedMissionsUseCase import com.goalpanzi.mission_mate.core.domain.usecase.GetMissionJoinedUseCase import com.goalpanzi.mission_mate.core.domain.usecase.ProfileUseCase import com.goalpanzi.mission_mate.feature.onboarding.isAfterProfileCreateArg import com.goalpanzi.mission_mate.feature.onboarding.model.OnboardingResultEvent import com.goalpanzi.mission_mate.feature.onboarding.model.OnboardingUiModel -import com.goalpanzi.core.model.base.NetworkResult import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow @@ -20,8 +21,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.flatMapLatest -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch import javax.inject.Inject @@ -38,21 +37,20 @@ class OnboardingViewModel @Inject constructor( val onboardingUiModel: StateFlow = _onboardingUiModel.asStateFlow() private val _onboardingResultEvent = MutableSharedFlow() - val onboardingResultEvent: SharedFlow = _onboardingResultEvent.asSharedFlow() + val onboardingResultEvent: SharedFlow = + _onboardingResultEvent.asSharedFlow() - val profileCreateSuccessEvent = savedStateHandle - .getStateFlow(isAfterProfileCreateArg, false) - .flatMapLatest { - flow { - emit( - if (it) { - profileUseCase.getProfile() - } else { - null - } - ) + val profileCreateSuccessEvent = MutableSharedFlow() + + init { + viewModelScope.launch { + savedStateHandle.get(isAfterProfileCreateArg)?.let { + if (it) { + profileCreateSuccessEvent.emit(profileUseCase.getProfile()) + } } } + } fun getJoinedMissions() { viewModelScope.launch { From 156b08a0f995d3449617ea81e56fc40774d16f60 Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Fri, 23 Aug 2024 03:09:52 +0900 Subject: [PATCH 3/4] Fix character item size on ProfileScreen. --- .../feature/profile/ProfileScreen.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/feature/profile/src/main/java/com/goalpanzi/mission_mate/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/goalpanzi/mission_mate/feature/profile/ProfileScreen.kt index f58d8c87..0c2695a9 100644 --- a/feature/profile/src/main/java/com/goalpanzi/mission_mate/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/goalpanzi/mission_mate/feature/profile/ProfileScreen.kt @@ -1,6 +1,7 @@ package com.goalpanzi.mission_mate.feature.profile import android.app.Activity +import android.content.res.Configuration import android.widget.Toast import androidx.annotation.DrawableRes import androidx.compose.foundation.Image @@ -39,6 +40,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.paint import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalSoftwareKeyboardController @@ -130,8 +132,7 @@ fun ProfileRoute( viewModel.saveProfile(it) }, onBackClick = onBackClick, - isNicknameDuplicated = isNicknameDuplicated, - resetNicknameErrorState = { viewModel.resetNicknameErrorState() }, + isNicknameDuplicated = isNicknameDuplicated ) } } @@ -145,8 +146,7 @@ fun ProfileContent( onClickCharacter: (CharacterListItem) -> Unit = {}, onClickSave: (String) -> Unit = {}, onBackClick: (() -> Unit)? = null, - isNicknameDuplicated: Boolean, - resetNicknameErrorState: () -> Unit + isNicknameDuplicated: Boolean ) { Column( modifier = modifier @@ -174,7 +174,7 @@ fun ProfileContent( isNotChangedProfileInput = isNotChangedProfileInput, onClickCharacter = onClickCharacter, onClickSave = onClickSave, - isNicknameDuplicated = isNicknameDuplicated, + isNicknameDuplicated = isNicknameDuplicated ) } } @@ -196,6 +196,7 @@ fun ColumnScope.ProfileScreen( val scrollState = rememberScrollState() val regex = Regex("^[가-힣ㅏ-ㅣㄱ-ㅎa-zA-Z0-9]{1,6}$") var invalidNicknameError by remember { mutableStateOf(false) } + val configuration = LocalConfiguration.current LaunchedEffect(nicknameInput) { if (nicknameInput.isEmpty()) return@LaunchedEffect @@ -228,7 +229,7 @@ fun ColumnScope.ProfileScreen( Box( modifier = modifier .padding(top = 32.dp) - .size(220.dp) + .size(configuration.screenWidthDp.dp * 0.55f) .align(Alignment.CenterHorizontally) ) { CharacterLargeImage( @@ -239,6 +240,7 @@ fun ColumnScope.ProfileScreen( } CharacterRow( characters = characters, + configuration = configuration, onClick = onClickCharacter ) @@ -304,6 +306,7 @@ fun CharacterLargeImage( @Composable fun CharacterRow( modifier: Modifier = Modifier, + configuration: Configuration, characters: List, onClick: (CharacterListItem) -> Unit ) { @@ -325,6 +328,7 @@ fun CharacterRow( items(items = characters, key = { it.imageResId }) { CharacterElement( character = it, + configuration = configuration, onClick = onClick ) } @@ -335,11 +339,15 @@ fun CharacterRow( fun CharacterElement( modifier: Modifier = Modifier, character: CharacterListItem, + configuration: Configuration = LocalConfiguration.current, onClick: (CharacterListItem) -> Unit = {} ) { Box( modifier = modifier - .size(width = 100.dp, height = 124.dp) + .size( + width = configuration.screenWidthDp.dp * 100f / 390f, + height = configuration.screenWidthDp.dp * 100f / 390f * 1.24f + ) .alpha(if (character.isSelected) 1f else 0.3f) .clickable( indication = null, @@ -411,7 +419,7 @@ fun ColumnScope.ProfileScreenPreview() { onClickCharacter = {}, onClickSave = {}, isNicknameDuplicated = false, - isNotChangedProfileInput = false, + isNotChangedProfileInput = false ) } From f805af95e215dfe16f4d67015fbff5744d3833a4 Mon Sep 17 00:00:00 2001 From: Changyeop Lee Date: Fri, 23 Aug 2024 03:25:48 +0900 Subject: [PATCH 4/4] Fix character image size on ProfileCreateSuccessDialog. --- .../onboarding/screen/OnboardingScreen.kt | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingScreen.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingScreen.kt index 89bb52f3..1284af19 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingScreen.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentSize @@ -274,23 +275,13 @@ fun ProfileCreateSuccessDialog( textAlign = TextAlign.Center, color = ColorGray2_FF4F505C ) - Image( - painter = painterResource( - id = when (character) { - CharacterType.RABBIT -> designSystemResource.drawable.img_rabbit_selected - CharacterType.CAT -> designSystemResource.drawable.img_cat_selected - CharacterType.DOG -> designSystemResource.drawable.img_dog_selected - CharacterType.PANDA -> designSystemResource.drawable.img_panda_selected - CharacterType.BEAR -> designSystemResource.drawable.img_bear_selected - CharacterType.BIRD -> designSystemResource.drawable.img_bird_selected - } - ), - contentDescription = null, + Box( modifier = Modifier .padding(vertical = 32.dp) + .size(180.dp) .paint( painter = painterResource( - when (character) { + id = when (character) { CharacterType.RABBIT -> designSystemResource.drawable.background_rabbit CharacterType.CAT -> designSystemResource.drawable.background_cat CharacterType.DOG -> designSystemResource.drawable.background_dog @@ -301,7 +292,26 @@ fun ProfileCreateSuccessDialog( ), contentScale = ContentScale.FillWidth, ) - ) + ) { + Image( + painter = painterResource( + id = when (character) { + CharacterType.RABBIT -> designSystemResource.drawable.img_rabbit_default + CharacterType.CAT -> designSystemResource.drawable.img_cat_default + CharacterType.DOG -> designSystemResource.drawable.img_dog_default + CharacterType.PANDA -> designSystemResource.drawable.img_panda_default + CharacterType.BEAR -> designSystemResource.drawable.img_bear_default + CharacterType.BIRD -> designSystemResource.drawable.img_bird_default + } + ), + contentDescription = null, + contentScale = ContentScale.FillWidth, + modifier = Modifier + .fillMaxSize() + .padding(18.dp) + .align(Alignment.Center) + ) + } } } } @@ -327,7 +337,7 @@ fun OnboardingScreenPreview() { fun ProfileCreateSuccessDialogPreview() { ProfileCreateSuccessDialog( nickname = "Test", - character = CharacterType.CAT, + character = CharacterType.RABBIT, onClickOk = {} ) }