generated from ajou4095/template-android
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] LoginNavGraph & LoginMainDestination 만들기
- Loading branch information
Showing
10 changed files
with
135 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 4 additions & 25 deletions
29
...on/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/LoginNavGraph.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,18 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login | ||
|
||
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState | ||
import androidx.compose.runtime.remember | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import ac.dnd.bookkeeping.android.presentation.ui.main.login.main.LoginMainConstant | ||
import ac.dnd.bookkeeping.android.presentation.ui.main.login.main.loginMainDestination | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.navigation | ||
|
||
fun NavGraphBuilder.loginNavGraph( | ||
appState: ApplicationState | ||
) { | ||
navigation( | ||
startDestination = LoginConstant.ROUTE_STEP_1, | ||
startDestination = LoginMainConstant.ROUTE, | ||
route = LoginConstant.ROUTE | ||
) { | ||
// TODO : 분리 | ||
composable( | ||
route = LoginConstant.ROUTE_STEP_1 | ||
) { | ||
val backStackEntry = remember(it) { | ||
appState.navController.getBackStackEntry(LoginConstant.ROUTE_STEP_1) | ||
} | ||
val loginViewModel: LoginViewModel = hiltViewModel(backStackEntry) | ||
LoginScreen(appState = appState, viewModel = loginViewModel) | ||
} | ||
|
||
// TODO : 분리 | ||
composable( | ||
route = LoginConstant.ROUTE_STEP_2 | ||
) { | ||
val backStackEntry = remember(it) { | ||
appState.navController.getBackStackEntry(LoginConstant.ROUTE) | ||
} | ||
val loginViewModel: LoginViewModel = hiltViewModel(backStackEntry) | ||
OnBoardScreen(appState = appState, viewModel = loginViewModel) | ||
} | ||
loginMainDestination(appState = appState) | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
...on/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/OnBoardScreen.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...in/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainConstant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login.main | ||
|
||
import ac.dnd.bookkeeping.android.presentation.ui.main.login.LoginConstant | ||
|
||
object LoginMainConstant { | ||
const val ROUTE: String = "${LoginConstant.ROUTE}/main" | ||
} |
17 changes: 17 additions & 0 deletions
17
...kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainDestination.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login.main | ||
|
||
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
|
||
fun NavGraphBuilder.loginMainDestination( | ||
appState: ApplicationState | ||
) { | ||
composable( | ||
route = LoginMainConstant.ROUTE | ||
) { | ||
LoginMainScreen( | ||
appState = appState | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login.main | ||
|
||
import ac.dnd.bookkeeping.android.domain.model.error.ServerException | ||
|
||
sealed interface LoginMainEvent { | ||
sealed interface Login : LoginMainEvent { | ||
data object Success : Login | ||
data class Failure(val exception: ServerException) : Login | ||
data class Error(val exception: Throwable) : Login | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login.main | ||
|
||
sealed interface LoginMainState { | ||
data object Init : LoginMainState | ||
} |
24 changes: 24 additions & 0 deletions
24
...n/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ac.dnd.bookkeeping.android.presentation.ui.main.login.main | ||
|
||
import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel | ||
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow | ||
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow | ||
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow | ||
import androidx.lifecycle.SavedStateHandle | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class LoginMainViewModel @Inject constructor( | ||
private val savedStateHandle: SavedStateHandle, | ||
) : BaseViewModel() { | ||
|
||
private val _state: MutableStateFlow<LoginMainState> = MutableStateFlow(LoginMainState.Init) | ||
val state: StateFlow<LoginMainState> = _state.asStateFlow() | ||
|
||
private val _event: MutableEventFlow<LoginMainEvent> = MutableEventFlow() | ||
val event: EventFlow<LoginMainEvent> = _event.asEventFlow() | ||
} |