diff --git a/build-logic/convention/src/main/kotlin/com/plottwist/tuk/Extension.kt b/build-logic/convention/src/main/kotlin/com/plottwist/tuk/Extension.kt index 267d6781..d91ae8e9 100644 --- a/build-logic/convention/src/main/kotlin/com/plottwist/tuk/Extension.kt +++ b/build-logic/convention/src/main/kotlin/com/plottwist/tuk/Extension.kt @@ -11,8 +11,8 @@ fun ApplicationExtension.configureDefaultConfig() { defaultConfig { applicationId = "com.plottwist.tuk" targetSdk = 36 - versionCode = 6 - versionName = "1.0.1" + versionCode = 8 + versionName = "1.0.3" vectorDrawables { useSupportLibrary = true diff --git a/core/data/src/main/java/com/plottwist/core/data/gathering/repository/JoinGatheringRepositoryImpl.kt b/core/data/src/main/java/com/plottwist/core/data/gathering/repository/JoinGatheringRepositoryImpl.kt index 72e60e98..f2000b5e 100644 --- a/core/data/src/main/java/com/plottwist/core/data/gathering/repository/JoinGatheringRepositoryImpl.kt +++ b/core/data/src/main/java/com/plottwist/core/data/gathering/repository/JoinGatheringRepositoryImpl.kt @@ -28,7 +28,7 @@ class JoinGatheringRepositoryImpl @Inject constructor( return if (response.success) { val name = response.data?.gatheringName if (name != null) Result.success(name) - else Result.failure(Exception("이름 없음")) + else Result.failure(Exception("닉네임 없음")) } else { Result.failure(Exception(response.meta?.errorMessage ?: "알 수 없는 에러")) } diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index 487f48af..996cbb7a 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -29,10 +29,10 @@ 다음 %s 친구들에게 - 어떤 이름으로 친구들에게\n인사할까요? - 모임 안에서 나를 알아볼 수 있게,\n실명을 적어주세요. - 이름 - 이름을 입력해 주세요 + 어떤 닉네임으로 친구들에게\n인사할까요? + 모임 안에서 나를 알아볼 수 있게 작성해 주세요. + 닉네임 + 닉네임을 입력해 주세요 모임 선택 어떤 모임에게\n넌지시 제안할까요 diff --git a/feature/home/src/main/java/com/plottwist/feature/home/HomeContract.kt b/feature/home/src/main/java/com/plottwist/feature/home/HomeContract.kt index 96ea0add..6eee8471 100644 --- a/feature/home/src/main/java/com/plottwist/feature/home/HomeContract.kt +++ b/feature/home/src/main/java/com/plottwist/feature/home/HomeContract.kt @@ -16,7 +16,9 @@ data class HomeState( val whenLabel: String = "", val whereLabel: String = "", val whatLabel: String = "", - val proposalTags: UiState = UiState.Loading + val proposalTags: UiState = UiState.Loading, + val isRandomPlaying: Boolean = true, + val currentIndex : Int = 0 ) sealed class HomeAction { @@ -29,6 +31,8 @@ sealed class HomeAction { data class ClickPropose(val index : Int): HomeAction() data object ClickProposals: HomeAction() data object OnPermissionGranted: HomeAction() + data object ClickPlay: HomeAction() + data object ClickStop: HomeAction() } sealed class HomeSideEffect { diff --git a/feature/home/src/main/java/com/plottwist/feature/home/HomeScreen.kt b/feature/home/src/main/java/com/plottwist/feature/home/HomeScreen.kt index dcb88176..08fe2ce5 100644 --- a/feature/home/src/main/java/com/plottwist/feature/home/HomeScreen.kt +++ b/feature/home/src/main/java/com/plottwist/feature/home/HomeScreen.kt @@ -97,7 +97,6 @@ fun HomeScreen( var homeBottomSheetAction: HomeBottomSheetAction by remember { mutableStateOf(HomeBottomSheetAction.IDLE) } - var hasBottomSheetShook by remember { mutableStateOf(false) } var bottomSheetState by remember { mutableStateOf(HomeBottomSheetState.COLLAPSED) } BackHandler(bottomSheetState == HomeBottomSheetState.EXPANDED) { @@ -109,10 +108,6 @@ fun HomeScreen( homeBottomSheetAction = HomeBottomSheetAction.IDLE } - LaunchedEffect(Unit) { - delay(800) - hasBottomSheetShook = true - } viewModel.collectSideEffect { sideEffect -> when (sideEffect) { @@ -170,6 +165,8 @@ fun HomeScreen( loginState = state.loginState, gatherings = state.gatherings, homeBottomSheetAction = homeBottomSheetAction, + isPlayed = state.isRandomPlaying, + selectedCurrentIndex = state.currentIndex, onMyPageClick = { viewModel.handleAction(HomeAction.ClickMyPage) }, @@ -181,6 +178,9 @@ fun HomeScreen( }, onChangedState = { bottomSheetState = it + if(it == HomeBottomSheetState.COLLAPSED) { + viewModel.handleAction(HomeAction.ClickPlay) + } }, onWhenRefreshClick = { viewModel.handleAction(HomeAction.ClickRefreshWhen) @@ -196,7 +196,13 @@ fun HomeScreen( }, onProposalsClick = { viewModel.handleAction(HomeAction.ClickProposals) - } + }, + onStopClick = { + viewModel.handleAction(HomeAction.ClickStop) + }, + onPlayClick = { + viewModel.handleAction(HomeAction.ClickPlay) + }, ) if(isShownNoGatheringsPopup) { @@ -245,9 +251,11 @@ private fun HomeScreen( statusBarHeight: Dp, userName: UiState, loginState: LoginState, + selectedCurrentIndex: Int, gatherings: UiState, proposalTags: UiState, homeBottomSheetAction: HomeBottomSheetAction, + isPlayed: Boolean, onWhenRefreshClick: () -> Unit, onWhereRefreshClick: () -> Unit, onWhatRefreshClick: () -> Unit, @@ -257,21 +265,29 @@ private fun HomeScreen( onChangedState: (HomeBottomSheetState) -> Unit, onProposeClick: (Int) -> Unit, onProposalsClick: () -> Unit, + onStopClick: () -> Unit, + onPlayClick: () -> Unit, modifier: Modifier = Modifier, verticalScrollState : ScrollState = rememberScrollState() ) { val homeContentTopPadding = screenHeight / 2 - statusBarHeight - TOP_APP_BAR_HEIGHT.dp val shake = remember { Animatable(0f) } + var isShook by rememberSaveable { mutableStateOf(false) } - LaunchedEffect(Unit) { - delay(200) - for (i in 0..10) { - when (i % 2) { - 0 -> shake.animateTo(3f, spring(stiffness = 50_000f)) - else -> shake.animateTo(-3f, spring(stiffness = 50_000f)) + + LaunchedEffect(isShook) { + if(!isShook) { + delay(1200) + for (i in 0..10) { + when (i % 2) { + 0 -> shake.animateTo(3f, spring(stiffness = 50_000f)) + else -> shake.animateTo(-3f, spring(stiffness = 50_000f)) + } } + shake.animateTo(0f) + isShook = true } - shake.animateTo(0f) + } @@ -331,12 +347,16 @@ private fun HomeScreen( whatLabels = proposalTags.value.whatTags, sheetPeekHeight = BOTTOM_SHEET_PEEK_HEIGHT.dp, sheetFullHeight = BOTTOM_SHEET_FULL_HEIGHT.dp, + isPlayed = isPlayed, + selectedCurrentIndex = selectedCurrentIndex, homeBottomSheetAction = homeBottomSheetAction, onWhenRefreshClick = onWhenRefreshClick, onWhereRefreshClick = onWhereRefreshClick, onWhatRefreshClick = onWhatRefreshClick, onChangedState = onChangedState, - onProposeClick = onProposeClick + onProposeClick = onProposeClick, + onStopClick = onStopClick, + onPlayClick = onPlayClick, ) } @@ -481,6 +501,7 @@ fun HomeScreenPreview(modifier: Modifier = Modifier) { loginState = LoginState.LoggedIn, gatherings = UiState.Success(Gatherings()), userName = UiState.Success(""), + isPlayed = false, onMyPageClick = {}, onAddGatheringClick = {}, onGatheringClick = {}, @@ -494,5 +515,8 @@ fun HomeScreenPreview(modifier: Modifier = Modifier) { onProposalsClick = {}, screenHeight = 720.dp, statusBarHeight = 28.dp, + onStopClick = {}, + onPlayClick = {}, + selectedCurrentIndex = 0 ) } diff --git a/feature/home/src/main/java/com/plottwist/feature/home/HomeViewModel.kt b/feature/home/src/main/java/com/plottwist/feature/home/HomeViewModel.kt index a49f438c..6db76e65 100644 --- a/feature/home/src/main/java/com/plottwist/feature/home/HomeViewModel.kt +++ b/feature/home/src/main/java/com/plottwist/feature/home/HomeViewModel.kt @@ -116,6 +116,13 @@ class HomeViewModel @Inject constructor( HomeAction.OnPermissionGranted -> { handleOnPermissionGranted() } + + HomeAction.ClickPlay -> { + handleRandomClick(isStop = false) + } + HomeAction.ClickStop -> { + handleRandomClick(isStop = true) + } } } @@ -216,6 +223,7 @@ class HomeViewModel @Inject constructor( val gatherings = state.gatherings as UiState.Success val proposalTags = state.proposalTags as UiState.Success if (gatherings.value.gatheringOverviews.isNotEmpty()) { + reduce { state.copy(currentIndex = index) } postSideEffect( HomeSideEffect.NavigateToSelectGatheringScreen( whereLabel = proposalTags.value.whereTags[index], @@ -224,6 +232,7 @@ class HomeViewModel @Inject constructor( ) ) } else { + reduce { state.copy(currentIndex = index) } postSideEffect( HomeSideEffect.NavigateToCreateProposalScreen( whereLabel = proposalTags.value.whereTags[index], @@ -235,6 +244,7 @@ class HomeViewModel @Inject constructor( } else -> { + reduce { state.copy(currentIndex = index) } postSideEffect(HomeSideEffect.NavigateToLoginScreen) } } @@ -284,4 +294,12 @@ class HomeViewModel @Inject constructor( private fun handleOnPermissionGranted() = intent { updateDeviceTokenUseCase() } + + private fun handleRandomClick(isStop: Boolean) = intent { + reduce { + state.copy( + isRandomPlaying = !isStop + ) + } + } } diff --git a/feature/home/src/main/java/com/plottwist/feature/home/component/HomeBottomSheet.kt b/feature/home/src/main/java/com/plottwist/feature/home/component/HomeBottomSheet.kt index 787172b9..f5377383 100644 --- a/feature/home/src/main/java/com/plottwist/feature/home/component/HomeBottomSheet.kt +++ b/feature/home/src/main/java/com/plottwist/feature/home/component/HomeBottomSheet.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment @@ -48,23 +49,28 @@ import kotlinx.coroutines.launch @Composable fun HomeBottomSheet( + selectedCurrentIndex: Int, whenLabels: List, whereLabels: List, whatLabels: List, sheetPeekHeight: Dp, sheetFullHeight: Dp, homeBottomSheetAction: HomeBottomSheetAction, + isPlayed: Boolean, onChangedState: (HomeBottomSheetState) -> Unit, onWhenRefreshClick: () -> Unit, onWhereRefreshClick: () -> Unit, onWhatRefreshClick: () -> Unit, onProposeClick: (Int) -> Unit, + onStopClick: () -> Unit, + onPlayClick: () -> Unit, modifier: Modifier = Modifier ) { - var isPlayed by remember { mutableStateOf(true) } + DraggableBottomSheet( modifier = modifier, + selectedCurrentIndex = selectedCurrentIndex, isPlayed = isPlayed, whenLabels = whenLabels, whereLabels = whereLabels, @@ -77,8 +83,8 @@ fun HomeBottomSheet( sheetFullHeight = sheetFullHeight, onChangedState = onChangedState, onProposeClick = onProposeClick, - onStopClick = { isPlayed = !isPlayed }, - onPlayClick = { isPlayed = !isPlayed } + onStopClick = onStopClick, + onPlayClick = onPlayClick, ) } @@ -86,6 +92,7 @@ fun HomeBottomSheet( fun DraggableBottomSheet( modifier: Modifier = Modifier, isPlayed: Boolean, + selectedCurrentIndex: Int, whenLabels: List, whereLabels: List, whatLabels: List, @@ -111,7 +118,14 @@ fun DraggableBottomSheet( val sheetFullPx = with(density) { sheetFullHeight.toPx() } val thresholdPx = with(density) { thresholdHeight.toPx() } - val offsetY = remember { Animatable(sheetFullPx - sheetPeekPx) } + val savedOffset = rememberSaveable { mutableStateOf(sheetFullPx - sheetPeekPx) } + val offsetY = remember { + Animatable(savedOffset.value) + } + + LaunchedEffect(offsetY.value) { + savedOffset.value = offsetY.value + } var dragDelta by remember { mutableFloatStateOf(0f) } LaunchedEffect(Unit) { @@ -263,6 +277,7 @@ fun DraggableBottomSheet( RandomProposal( modifier = Modifier.padding(top = 4.dp), isPlayed = isPlayed, + selectedCurrentIndex = selectedCurrentIndex, whenLabels = whenLabels, whereLabels = whereLabels, whatLabels = whatLabels, @@ -271,7 +286,7 @@ fun DraggableBottomSheet( onWhatRefreshClick = onWhatRefreshClick, onProposeClick = onProposeClick, onStopClick = onStopClick, - onPlayClick = onPlayClick + onPlayClick = onPlayClick, ) } } diff --git a/feature/home/src/main/java/com/plottwist/feature/home/component/RandomProposal.kt b/feature/home/src/main/java/com/plottwist/feature/home/component/RandomProposal.kt index 51189fbe..7ad183c7 100644 --- a/feature/home/src/main/java/com/plottwist/feature/home/component/RandomProposal.kt +++ b/feature/home/src/main/java/com/plottwist/feature/home/component/RandomProposal.kt @@ -53,6 +53,7 @@ import kotlinx.coroutines.isActive @Composable fun RandomProposal( isPlayed: Boolean, + selectedCurrentIndex: Int, whenLabels: List, whereLabels: List, whatLabels: List, @@ -64,7 +65,7 @@ fun RandomProposal( onPlayClick: () -> Unit, modifier: Modifier = Modifier ) { - var currentIndex by remember { mutableIntStateOf(0) } + var currentIndex by remember { mutableIntStateOf(selectedCurrentIndex) } val lifecycleOwner = LocalLifecycleOwner.current val minSize = arrayOf(whatLabels.size, whereLabels.size, whenLabels.size).min() diff --git a/feature/mypage/src/main/java/com/plottwist/feature/mypage/MyPageScreen.kt b/feature/mypage/src/main/java/com/plottwist/feature/mypage/MyPageScreen.kt index 97f27f3a..b6e88497 100644 --- a/feature/mypage/src/main/java/com/plottwist/feature/mypage/MyPageScreen.kt +++ b/feature/mypage/src/main/java/com/plottwist/feature/mypage/MyPageScreen.kt @@ -188,7 +188,7 @@ fun MyPageContent( ) { item { SectionTitle("내 정보관리") - MyPageItem("이름 설정", onEditNameClick) + MyPageItem("닉네임 설정", onEditNameClick) MyPageItem("알림 설정", onNotificationClick) } diff --git a/feature/mypage/src/main/java/com/plottwist/feature/mypage/edit_name/EditNameScreen.kt b/feature/mypage/src/main/java/com/plottwist/feature/mypage/edit_name/EditNameScreen.kt index d3414bd5..0278d476 100644 --- a/feature/mypage/src/main/java/com/plottwist/feature/mypage/edit_name/EditNameScreen.kt +++ b/feature/mypage/src/main/java/com/plottwist/feature/mypage/edit_name/EditNameScreen.kt @@ -45,7 +45,7 @@ fun EditNameScreen( EditNameSideEffect.SaveSuccess -> { Toast.makeText( context, - "이름이 변경되었어요!", + "닉네임이 변경되었어요!", Toast.LENGTH_SHORT ).show() onBack() @@ -116,7 +116,7 @@ fun EditNameAppBar( TukTopAppBar( modifier = modifier, type = TukTopAppBarType.DEPTH, - title = "이름 설정", + title = "닉네임 설정", onBack = onBackClick ) } diff --git a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/CreateProposalScreen.kt b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/CreateProposalScreen.kt index d221b47e..de0ab6dd 100644 --- a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/CreateProposalScreen.kt +++ b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/CreateProposalScreen.kt @@ -86,7 +86,7 @@ fun CreateProposalScreen( } LaunchedEffect(selectedGatheringParam) { - if(selectedGatheringParam != null) { + if(selectedGatheringParam?.id != null && selectedGatheringParam.name != null) { viewModel.handleAction( CreateProposalAction.SelectedGathering( gatheringId = selectedGatheringParam.id, diff --git a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringScreen.kt b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringScreen.kt index 84b715ce..e8ce9d87 100644 --- a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringScreen.kt +++ b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringScreen.kt @@ -76,7 +76,6 @@ private fun SelectGatheringScreen( modifier = Modifier.fillMaxWidth() .padding(horizontal = 20.dp, vertical = 16.dp), text = stringResource(R.string.create_proposal_propose), - buttonType = TukSolidButtonType.from(gatherings.any { it.selected }), onClick = onProposalClick ) } diff --git a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringViewModel.kt b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringViewModel.kt index a332821d..c65a857b 100644 --- a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringViewModel.kt +++ b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/gathering_select/SelectGatheringViewModel.kt @@ -76,13 +76,13 @@ class SelectGatheringViewModel @Inject constructor( } private fun handleProposeClick() = intent { - val selectedGathering = state.gatherings.find { it.selected } ?: return@intent + val selectedGathering = state.gatherings.find { it.selected } postSideEffect( SelectGatheringSideEffect.NavigateToCreateProposal( SelectedGatheringParam( - id = selectedGathering.id, - name = selectedGathering.name, + id = selectedGathering?.id, + name = selectedGathering?.name, whenLabel = state.whenLabel, whereLabel = state.whereLabel, whatLabel = state.whatLabel diff --git a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/model/SelectedGatheringParam.kt b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/model/SelectedGatheringParam.kt index c98bec5c..bade5b2b 100644 --- a/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/model/SelectedGatheringParam.kt +++ b/feature/proposal-create/src/main/java/com/plottwist/feature/proposal_create/model/SelectedGatheringParam.kt @@ -5,8 +5,8 @@ import kotlinx.parcelize.Parcelize @Parcelize data class SelectedGatheringParam( - val id: Long, - val name: String, + val id: Long?, + val name: String?, val whenLabel: String, val whereLabel: String, val whatLabel: String