Skip to content

Commit

Permalink
[feature/login_term] 로그인 네비게이션 생성 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Aug 28, 2023
1 parent 9ed4986 commit cd97fe2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.meongmoryteam.presentation.ui.theme.MeongmoryTheme
import dagger.hilt.android.AndroidEntryPoint

sealed class LoginNaviRoute(val route: String) {
object CertificationScreen : LoginNaviRoute("CertificationScreen")
object TermScreen : LoginNaviRoute("TermScreen")
}

@AndroidEntryPoint
class LoginActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -19,7 +30,7 @@ class LoginActivity : ComponentActivity() {
private fun setUnivSelectScreen() {
setContent {
MeongmoryTheme {
LoginScreen()
LoginNavigation()
}
}
}
Expand All @@ -30,4 +41,23 @@ class LoginActivity : ComponentActivity() {
context.startActivity(intent)
}
}
}

@Composable
fun LoginNavigation(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController()
) {
NavHost(
navController = navController,
startDestination = LoginNaviRoute.CertificationScreen.route,
modifier = modifier
) {
composable(route = LoginNaviRoute.CertificationScreen.route) {
LoginScreen(
navController = navController,
navigateToTermScreen = { navController.navigate(LoginNaviRoute.TermScreen.route) }
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.meongmoryteam.presentation.R
import com.meongmoryteam.presentation.base.TextButtonComponent
import com.meongmoryteam.presentation.base.TextFieldComponent
import com.meongmoryteam.presentation.ui.register_family.RouteScreen
import com.meongmoryteam.presentation.ui.theme.ButtonContent
import com.meongmoryteam.presentation.ui.theme.DarkGrey
import com.meongmoryteam.presentation.ui.theme.LightGrey
Expand All @@ -43,7 +46,9 @@ import kotlinx.coroutines.launch

@Composable
fun LoginScreen(
navController: NavHostController,
loginViewModel: LoginViewModel = hiltViewModel(),
navigateToTermScreen: () -> Unit,
) {
val loginViewState by loginViewModel.viewState.collectAsState()

Expand Down Expand Up @@ -76,15 +81,15 @@ fun LoginScreen(
.height(50.dp)
.padding(horizontal = 16.dp),
) {

loginViewModel.setEvent(LoginContract.LoginEvent.ToTermScreenButtonClicked)
}
}

LaunchedEffect(key1 = loginViewModel.effect) {
loginViewModel.effect.collect { effect ->
when (effect) {
is LoginContract.LoginEffect.MoveToTerm -> {

navigateToTermScreen()
}
is LoginContract.LoginEffect.FailCertification -> {
/*
Expand Down

0 comments on commit cd97fe2

Please sign in to comment.