Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?: "알 수 없는 에러"))
}
Expand Down
8 changes: 4 additions & 4 deletions core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<string name="create_proposal_propose">다음</string>
<string name="create_proposal_selected_gathering_name">%s 친구들에게</string>

<string name="onboarding_name_title">어떤 이름으로 친구들에게\n인사할까요?</string>
<string name="onboarding_name_description">모임 안에서 나를 알아볼 수 있게,\n실명을 적어주세요.</string>
<string name="onboarding_name_text_field_label">이름</string>
<string name="onboarding_name_text_field_hint">이름을 입력해 주세요</string>
<string name="onboarding_name_title">어떤 닉네임으로 친구들에게\n인사할까요?</string>
<string name="onboarding_name_description">모임 안에서 나를 알아볼 수 있게 작성해 주세요.</string>
<string name="onboarding_name_text_field_label">닉네임</string>
<string name="onboarding_name_text_field_hint">닉네임을 입력해 주세요</string>

<string name="select_gathering_topbar_title">모임 선택</string>
<string name="select_gathering_title">어떤 모임에게\n넌지시 제안할까요</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ data class HomeState(
val whenLabel: String = "",
val whereLabel: String = "",
val whatLabel: String = "",
val proposalTags: UiState<ProposalTags> = UiState.Loading
val proposalTags: UiState<ProposalTags> = UiState.Loading,
val isRandomPlaying: Boolean = true,
val currentIndex : Int = 0
)

sealed class HomeAction {
Expand All @@ -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 {
Expand Down
52 changes: 38 additions & 14 deletions feature/home/src/main/java/com/plottwist/feature/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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>(HomeBottomSheetState.COLLAPSED) }

BackHandler(bottomSheetState == HomeBottomSheetState.EXPANDED) {
Expand All @@ -109,10 +108,6 @@ fun HomeScreen(
homeBottomSheetAction = HomeBottomSheetAction.IDLE
}

LaunchedEffect(Unit) {
delay(800)
hasBottomSheetShook = true
}

viewModel.collectSideEffect { sideEffect ->
when (sideEffect) {
Expand Down Expand Up @@ -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)
},
Expand All @@ -181,6 +178,9 @@ fun HomeScreen(
},
onChangedState = {
bottomSheetState = it
if(it == HomeBottomSheetState.COLLAPSED) {
viewModel.handleAction(HomeAction.ClickPlay)
}
},
onWhenRefreshClick = {
viewModel.handleAction(HomeAction.ClickRefreshWhen)
Expand All @@ -196,7 +196,13 @@ fun HomeScreen(
},
onProposalsClick = {
viewModel.handleAction(HomeAction.ClickProposals)
}
},
onStopClick = {
viewModel.handleAction(HomeAction.ClickStop)
},
onPlayClick = {
viewModel.handleAction(HomeAction.ClickPlay)
},
)

if(isShownNoGatheringsPopup) {
Expand Down Expand Up @@ -245,9 +251,11 @@ private fun HomeScreen(
statusBarHeight: Dp,
userName: UiState<String>,
loginState: LoginState,
selectedCurrentIndex: Int,
gatherings: UiState<Gatherings>,
proposalTags: UiState<ProposalTags>,
homeBottomSheetAction: HomeBottomSheetAction,
isPlayed: Boolean,
onWhenRefreshClick: () -> Unit,
onWhereRefreshClick: () -> Unit,
onWhatRefreshClick: () -> Unit,
Expand All @@ -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)

}


Expand Down Expand Up @@ -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,
)
}

Expand Down Expand Up @@ -481,6 +501,7 @@ fun HomeScreenPreview(modifier: Modifier = Modifier) {
loginState = LoginState.LoggedIn,
gatherings = UiState.Success(Gatherings()),
userName = UiState.Success(""),
isPlayed = false,
onMyPageClick = {},
onAddGatheringClick = {},
onGatheringClick = {},
Expand All @@ -494,5 +515,8 @@ fun HomeScreenPreview(modifier: Modifier = Modifier) {
onProposalsClick = {},
screenHeight = 720.dp,
statusBarHeight = 28.dp,
onStopClick = {},
onPlayClick = {},
selectedCurrentIndex = 0
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class HomeViewModel @Inject constructor(
HomeAction.OnPermissionGranted -> {
handleOnPermissionGranted()
}

HomeAction.ClickPlay -> {
handleRandomClick(isStop = false)
}
HomeAction.ClickStop -> {
handleRandomClick(isStop = true)
}
}
}

Expand Down Expand Up @@ -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],
Expand All @@ -224,6 +232,7 @@ class HomeViewModel @Inject constructor(
)
)
} else {
reduce { state.copy(currentIndex = index) }
postSideEffect(
HomeSideEffect.NavigateToCreateProposalScreen(
whereLabel = proposalTags.value.whereTags[index],
Expand All @@ -235,6 +244,7 @@ class HomeViewModel @Inject constructor(
}

else -> {
reduce { state.copy(currentIndex = index) }
postSideEffect(HomeSideEffect.NavigateToLoginScreen)
}
}
Expand Down Expand Up @@ -284,4 +294,12 @@ class HomeViewModel @Inject constructor(
private fun handleOnPermissionGranted() = intent {
updateDeviceTokenUseCase()
}

private fun handleRandomClick(isStop: Boolean) = intent {
reduce {
state.copy(
isRandomPlaying = !isStop
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,23 +49,28 @@ import kotlinx.coroutines.launch

@Composable
fun HomeBottomSheet(
selectedCurrentIndex: Int,
whenLabels: List<String>,
whereLabels: List<String>,
whatLabels: List<String>,
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,
Expand All @@ -77,15 +83,16 @@ fun HomeBottomSheet(
sheetFullHeight = sheetFullHeight,
onChangedState = onChangedState,
onProposeClick = onProposeClick,
onStopClick = { isPlayed = !isPlayed },
onPlayClick = { isPlayed = !isPlayed }
onStopClick = onStopClick,
onPlayClick = onPlayClick,
)
}

@Composable
fun DraggableBottomSheet(
modifier: Modifier = Modifier,
isPlayed: Boolean,
selectedCurrentIndex: Int,
whenLabels: List<String>,
whereLabels: List<String>,
whatLabels: List<String>,
Expand All @@ -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) {
Expand Down Expand Up @@ -263,6 +277,7 @@ fun DraggableBottomSheet(
RandomProposal(
modifier = Modifier.padding(top = 4.dp),
isPlayed = isPlayed,
selectedCurrentIndex = selectedCurrentIndex,
whenLabels = whenLabels,
whereLabels = whereLabels,
whatLabels = whatLabels,
Expand All @@ -271,7 +286,7 @@ fun DraggableBottomSheet(
onWhatRefreshClick = onWhatRefreshClick,
onProposeClick = onProposeClick,
onStopClick = onStopClick,
onPlayClick = onPlayClick
onPlayClick = onPlayClick,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import kotlinx.coroutines.isActive
@Composable
fun RandomProposal(
isPlayed: Boolean,
selectedCurrentIndex: Int,
whenLabels: List<String>,
whereLabels: List<String>,
whatLabels: List<String>,
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fun MyPageContent(
) {
item {
SectionTitle("내 정보관리")
MyPageItem("이름 설정", onEditNameClick)
MyPageItem("닉네임 설정", onEditNameClick)
MyPageItem("알림 설정", onNotificationClick)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun EditNameScreen(
EditNameSideEffect.SaveSuccess -> {
Toast.makeText(
context,
"이름이 변경되었어요!",
"닉네임이 변경되었어요!",
Toast.LENGTH_SHORT
).show()
onBack()
Expand Down Expand Up @@ -116,7 +116,7 @@ fun EditNameAppBar(
TukTopAppBar(
modifier = modifier,
type = TukTopAppBarType.DEPTH,
title = "이름 설정",
title = "닉네임 설정",
onBack = onBackClick
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
Loading
Loading