Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-114] 회원가입 화면 플로우 연결 #37

Merged
merged 16 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ fun TnTOutlinedTextField(
placeholder: String? = stringResource(R.string.placeholder_content_input),
maxLength: Int = 15,
isError: Boolean = false,
warningMessage: String? = null,
keyboardType: KeyboardType = KeyboardType.Text,
) {
var isFocused by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -291,14 +292,24 @@ fun TnTOutlinedTextField(
keyboardType = keyboardType,
),
)
Text(
text = "${value.length}/$maxLength",
style = TnTTheme.typography.label2Medium,
color = counterColor,
modifier = Modifier
.padding(vertical = 8.dp)
.align(Alignment.End),
)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(vertical = 8.dp),
) {
if (isError && warningMessage.isNullOrEmpty().not()) {
Text(
text = warningMessage ?: "",
style = TnTTheme.typography.body2Medium,
color = counterColor,
)
}
Spacer(modifier = Modifier.weight(1f))
Text(
text = "${value.length}/$maxLength",
style = TnTTheme.typography.label2Medium,
color = counterColor,
)
}
}
}

Expand Down Expand Up @@ -412,6 +423,7 @@ private fun TnTOutlinedTextFieldPreview() {
onValueChange = { text = it },
maxLength = maxLength,
isError = warningState,
warningMessage = "에러",
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
Expand Down
10 changes: 8 additions & 2 deletions core/navigation/src/main/java/co/kr/tnt/navigation/RouteModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ sealed interface Route {
data object Login : Route

@Serializable
data object TrainerConnect : Route
data object TrainerSignUp : Route

@Serializable
data object TraineeConnect : Route
data object TraineeSignUp : Route

@Serializable
data class TrainerConnect(val isFromMyPage: Boolean) : Route

@Serializable
data class TraineeConnect(val isFromMyPage: Boolean) : Route

@Serializable
data class RoleSelection(
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="start">시작하기</string>
<string name="skip">건너뛰기</string>

<string name="name">이름</string>
<string name="age_label">나이</string>
<string name="height_label">키</string>
<string name="weight_label">체중</string>
Expand Down
2 changes: 2 additions & 0 deletions feature/login/src/main/java/co/kr/tnt/login/LoginViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.kr.tnt.login

import android.util.Log
import androidx.lifecycle.viewModelScope
import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
Expand Down Expand Up @@ -28,6 +29,7 @@ internal class LoginViewModel @Inject constructor(
is LoginUiEvent.OnAuthFail -> {
if (event.throwable !is LoginException.CancelException) {
// TODO resource
Log.w("test", "exception : ${event.throwable}")
sendEffect(LoginSideEffect.ShowToast("로그인에 실패하였습니다. 다시 시도해주세요."))
}
}
Expand Down
2 changes: 2 additions & 0 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies {
implementation(projects.feature.login)
implementation(projects.feature.trainer.connect)
implementation(projects.feature.trainee.connect)
implementation(projects.feature.trainee.signup)
implementation(projects.feature.trainer.signup)
implementation(projects.feature.roleselect)

implementation(libs.androidx.core.ktx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class TnTAppState(
@Composable get() = navController
.currentBackStackEntryAsState().value?.destination

val startDestination = Route.TrainerConnect
val startDestination = Route.Login
}
12 changes: 12 additions & 0 deletions feature/main/src/main/java/co/kr/tnt/main/ui/TnTNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import co.kr.tnt.login.navigation.loginScreen
import co.kr.tnt.navigation.Route
import co.kr.tnt.roleselect.navigateToRoleSelection
import co.kr.tnt.roleselect.roleSelectionScreen
import co.kr.tnt.trainee.connect.navigation.navigateToTraineeConnect
import co.kr.tnt.trainee.connect.navigation.traineeConnectScreen
import co.kr.tnt.trainee.signup.navigation.traineeSignUpScreen
import co.kr.tnt.trainer.connect.navigation.navigateToTrainerConnect
import co.kr.tnt.trainer.connect.navigation.trainerConnectScreen
import co.kr.tnt.trainer.signup.navigation.trainerSignUpScreen

@Composable
fun TnTNavHost(
Expand Down Expand Up @@ -46,6 +50,14 @@ fun TnTNavHost(
)
},
)
trainerSignUpScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToConnect = { navController.navigateToTrainerConnect(isFromMyPage = false) },
)
traineeSignUpScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToConnect = { navController.navigateToTraineeConnect(isFromMyPage = false) },
)
trainerConnectScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToHome = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.kr.tnt.trainee.connect

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -9,17 +10,13 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import co.kr.tnt.designsystem.component.TnTPopupDialog
import co.kr.tnt.designsystem.component.TnTTopBar
import co.kr.tnt.designsystem.component.TnTTopBarWithBackButton
import co.kr.tnt.designsystem.component.button.TnTBottomButton
import co.kr.tnt.designsystem.component.button.TnTTextButton
import co.kr.tnt.designsystem.component.button.model.ButtonSize
Expand All @@ -33,28 +30,43 @@ import co.kr.tnt.core.ui.R as uiResource
@Composable
internal fun CodeEntryPage(
state: TraineeConnectUiState,
isFromMyPage: Boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm...

onSkipClick: () -> Unit,
onBackClick: () -> Unit,
onNextClick: () -> Unit,
onCodeChanged: (String) -> Unit,
onValidateClick: (String) -> Unit,
) {
var showDialog by rememberSaveable { mutableStateOf(true) }
BackHandler {
if (isFromMyPage) {
onBackClick()
} else {
onSkipClick()
}
}

Scaffold(
topBar = {
TnTTopBar(
title = stringResource(uiResource.string.connect),
trailingComponent = {
Text(
text = stringResource(uiResource.string.skip),
color = TnTTheme.colors.neutralColors.Neutral400,
style = TnTTheme.typography.body2Medium,
modifier = Modifier.clickable {
onSkipClick()
},
)
},
)
if (isFromMyPage) {
TnTTopBarWithBackButton(
title = stringResource(uiResource.string.connect),
onBackClick = onBackClick,
)
} else {
TnTTopBar(
title = stringResource(uiResource.string.connect),
trailingComponent = {
Text(
text = stringResource(uiResource.string.skip),
color = TnTTheme.colors.neutralColors.Neutral400,
style = TnTTheme.typography.body2Medium,
modifier = Modifier.clickable {
onSkipClick()
},
)
},
)
}
},
containerColor = TnTTheme.colors.commonColors.Common0,
) { innerPadding ->
Expand All @@ -77,6 +89,7 @@ internal fun CodeEntryPage(
TnTTextButton(
text = stringResource(R.string.verification),
size = ButtonSize.Small,
enabled = state.inviteCode.isNotBlank(),
onClick = { onValidateClick(state.inviteCode) },
)
},
Expand All @@ -89,20 +102,6 @@ internal fun CodeEntryPage(
modifier = Modifier.align(Alignment.BottomCenter),
)
}
if (showDialog) {
TnTPopupDialog(
title = stringResource(R.string.enter_invite_code_from_trainer),
content = stringResource(R.string.not_connected_warning),
leftButtonText = stringResource(R.string.next_time),
rightButtonText = stringResource(uiResource.string.ok),
onLeftButtonClick = {
showDialog = false
onSkipClick()
},
onRightButtonClick = { showDialog = false },
onDismiss = { showDialog = false },
)
}
}
}

Expand All @@ -111,11 +110,13 @@ internal fun CodeEntryPage(
private fun CodeEntryPagePreview() {
TnTTheme {
CodeEntryPage(
isFromMyPage = false,
onSkipClick = {},
onNextClick = {},
state = TODO(),
onValidateClick = {},
onCodeChanged = TODO(),
onBackClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import co.kr.tnt.trainee.connect.model.PTSessionFormData

@Composable
internal fun TraineeConnectRoute(
isFromMyPage: Boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm..

navigateToPrevious: () -> Unit,
navigateToHome: (Boolean) -> Unit,
viewModel: TraineeConnectViewModel = hiltViewModel(),
Expand All @@ -21,6 +22,7 @@ internal fun TraineeConnectRoute(

TraineeConnectScreen(
state = state,
isFromMyPage = isFromMyPage,
onFormNextClick = { formData ->
viewModel.setEvent(TraineeConnectUiEvent.UpdatePTSessionData(formData))
},
Expand Down Expand Up @@ -48,6 +50,7 @@ internal fun TraineeConnectRoute(
@Composable
private fun TraineeConnectScreen(
state: TraineeConnectUiState,
isFromMyPage: Boolean,
onCodeValidationClick: (String) -> Unit,
onCodeChanged: (String) -> Unit,
onFormNextClick: (PTSessionFormData) -> Unit,
Expand All @@ -58,7 +61,9 @@ private fun TraineeConnectScreen(
when (state.page) {
TraineeConnectPage.CodeEntry -> CodeEntryPage(
state = state,
isFromMyPage = isFromMyPage,
onNextClick = onNextClick,
onBackClick = onBackClick,
onSkipClick = onSkipClick,
onCodeChanged = { code ->
onCodeChanged(code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import co.kr.tnt.navigation.Route
import co.kr.tnt.trainee.connect.TraineeConnectRoute

fun NavController.navigateToTraineeConnect(
isFromMyPage: Boolean,
navOptions: NavOptionsBuilder.() -> Unit = {},
) = navigate(
route = Route.TraineeConnect,
route = Route.TraineeConnect(isFromMyPage),
builder = navOptions,
)

Expand All @@ -22,6 +23,7 @@ fun NavGraphBuilder.traineeConnectScreen(
composable<Route.TraineeConnect> { backstackEntry ->
backstackEntry.toRoute<Route.TraineeConnect>().apply {
TraineeConnectRoute(
isFromMyPage = isFromMyPage,
navigateToPrevious = navigateToPrevious,
navigateToHome = { navigateToHome(false) },
)
Expand Down
Loading
Loading