Skip to content

Commit

Permalink
feat: 로그인 네비게이션 처리 #52
Browse files Browse the repository at this point in the history
  • Loading branch information
easyhz committed Aug 11, 2024
1 parent a9ee82a commit 652a983
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/com/easyhz/noffice/NofficeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.easyhz.noffice.navigation.announcement.announcementGraph
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementDetail
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementNofficeSelection
import com.easyhz.noffice.navigation.home.homeGraph
import com.easyhz.noffice.navigation.home.navigateToHome
import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.my_page.myPageGraph
import com.easyhz.noffice.navigation.my_page.navigateToMyPage
Expand Down Expand Up @@ -119,7 +118,7 @@ internal fun NofficeApp(
navController = navController,
)
signGraph(
navigateToHome = navController::navigateToHome
navController = navController
)
announcementGraph(
navController = navController,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
package com.easyhz.noffice.navigation.home

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.ui.Modifier
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import com.easyhz.noffice.feature.home.screen.home.HomeScreen
import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.sign.screen.LogIn

internal fun NavGraphBuilder.homeGraph(
modifier: Modifier,
navigateToAnnouncementDetail: (Int, String) -> Unit,
navigateToMyPage: () -> Unit
) {
composable<Home>(
enterTransition = { fadeIn(animationSpec = tween(700)) },
enterTransition = {
if (this.enabledSlide()) null
else fadeIn(animationSpec = tween(700))
},
exitTransition = { fadeOut(animationSpec = tween(700)) },
popEnterTransition = { fadeIn(animationSpec = tween(700)) },
popExitTransition = { fadeOut(animationSpec = tween(700)) }
Expand All @@ -35,4 +41,7 @@ internal fun NavController.navigateToHome(navOptions: NavOptions? = null) {
route = Home,
navOptions = navOptions
)
}
}

private fun AnimatedContentTransitionScope<NavBackStackEntry>.enabledSlide() =
this.initialState.destination.route == LogIn::class.java.name
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
package com.easyhz.noffice.navigation.sign

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navOptions
import com.easyhz.noffice.feature.sign.screen.login.LoginScreen
import com.easyhz.noffice.feature.sign.screen.signUp.SignUpScreen
import com.easyhz.noffice.navigation.home.navigateToHome
import com.easyhz.noffice.navigation.sign.screen.LogIn
import com.easyhz.noffice.navigation.sign.screen.SignUp

internal fun NavGraphBuilder.signGraph(
navigateToHome: () -> Unit
navController: NavController
) {
composable<LogIn> {
val navOptions = navOptions {
popUpTo(navController.graph.startDestinationId) {
inclusive = true
}
launchSingleTop = true
}
LoginScreen(
navigateToHome = navigateToHome
navigateToHome = { navController.navigateToHome(navOptions) }
)
}
composable<SignUp> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ fun LoginScreen(
is LoginSideEffect.NavigateToHome -> {
navigateToHome()
}

is LoginSideEffect.NavigateToSignUp -> {}
is LoginSideEffect.NavigateToHome -> {}
is LoginSideEffect.NavigateToSignUp -> {}
is LoginSideEffect.NavigateToSignUp -> {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class LoginViewModel @Inject constructor(
}

private fun onClickToLogInWithGoogle(context: Context) = viewModelScope.launch {
// TODO 로그인 로직 처리
loginUseCase.invoke(context).onSuccess {
println("success")
// FIXME 가입 된 유저 네비게이션 처리
navigateToHome()
}.onFailure {
it.printStackTrace()
}
Expand Down

0 comments on commit 652a983

Please sign in to comment.