-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [BASE] #25 hilt 미적용 feature 모듈에 대해 hilt 라이브러리 설정 및 hiltViewModel 적용 * [BASE] #25 루트 네비게이션 로직 초기 구현 - 아직 각 화면간 이동 로직은 구현되지 않고 navHost내 화면들만 구성한 상태 * [BASE] #25 optional한 인자 전달 관련 코드 수정 및 아래 구현된 Screen에 화면 이동 로직 적용 - 링크 추가/수정 - 포킷 상세 - 검색
- Loading branch information
Showing
17 changed files
with
284 additions
and
11 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
47 changes: 47 additions & 0 deletions
47
app/src/main/java/pokitmons/pokit/navigation/RootDestination.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,47 @@ | ||
package pokitmons.pokit.navigation | ||
|
||
import androidx.navigation.NavType | ||
import androidx.navigation.navArgument | ||
|
||
object Login { | ||
val route: String = "login" | ||
} | ||
|
||
object Home { | ||
val route: String = "home" | ||
} | ||
|
||
object AddLink { | ||
val route: String = "addLink" | ||
val linkIdArg = "link_id" | ||
val routeWithArgs = "$route?$linkIdArg={$linkIdArg}" | ||
var arguments = listOf( | ||
navArgument(linkIdArg) { | ||
nullable = true | ||
type = NavType.StringType | ||
} | ||
) | ||
} | ||
|
||
object AddPokit { | ||
val route: String = "addPokit" | ||
val pokitIdArg = "pokit_id" | ||
val routeWithArgs = "$route?$pokitIdArg={$pokitIdArg}" | ||
var arguments = listOf( | ||
navArgument(pokitIdArg) { | ||
nullable = true | ||
type = NavType.StringType | ||
} | ||
) | ||
} | ||
|
||
object PokitDetail { | ||
val route: String = "pokitDetail" | ||
val pokitIdArg = "pokit_id" | ||
val routeWithArgs = "$route/{$pokitIdArg}" | ||
var arguments = listOf(navArgument(pokitIdArg) { defaultValue = "-" }) | ||
} | ||
|
||
object Search { | ||
val route: String = "search" | ||
} |
96 changes: 96 additions & 0 deletions
96
app/src/main/java/pokitmons/pokit/navigation/RootNavHost.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,96 @@ | ||
package pokitmons.pokit.navigation | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.navigation.NavHostController | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import com.strayalpaca.addlink.AddLinkScreenContainer | ||
import com.strayalpaca.addlink.AddLinkViewModel | ||
import com.strayalpaca.addpokit.AddPokitScreenContainer | ||
import com.strayalpaca.addpokit.AddPokitViewModel | ||
import com.strayalpaca.pokitdetail.PokitDetailScreenContainer | ||
import com.strayalpaca.pokitdetail.PokitDetailViewModel | ||
import pokitmons.pokit.LoginViewModel | ||
import pokitmons.pokit.login.LoginScreen | ||
import pokitmons.pokit.search.SearchScreenContainer | ||
import pokitmons.pokit.search.SearchViewModel | ||
|
||
@Composable | ||
fun RootNavHost( | ||
navHostController: NavHostController, | ||
) { | ||
NavHost(navController = navHostController, startDestination = Login.route) { | ||
composable(Login.route) { | ||
val viewModel: LoginViewModel = hiltViewModel() | ||
LoginScreen( | ||
loginViewModel = viewModel, | ||
onNavigateToTermsOfServiceScreen = {} | ||
) | ||
} | ||
|
||
composable(Home.route) { | ||
Box(modifier = Modifier.fillMaxSize()) | ||
} | ||
|
||
composable( | ||
route = AddLink.routeWithArgs, | ||
arguments = AddLink.arguments | ||
) { navBackStackEntry -> | ||
val viewModel: AddLinkViewModel = hiltViewModel() | ||
val linkId = navBackStackEntry.arguments?.getString(AddLink.linkIdArg) | ||
AddLinkScreenContainer( | ||
linkId = linkId, | ||
viewModel = viewModel, | ||
onBackPressed = navHostController::popBackStack, | ||
onNavigateToAddPokit = { | ||
navHostController.navigate(AddPokit.route) | ||
} | ||
) | ||
} | ||
|
||
composable( | ||
route = AddPokit.routeWithArgs, | ||
arguments = AddPokit.arguments | ||
) { | ||
val viewModel: AddPokitViewModel = hiltViewModel() | ||
AddPokitScreenContainer( | ||
viewModel = viewModel, | ||
onBackPressed = navHostController::popBackStack | ||
) | ||
} | ||
|
||
composable( | ||
route = PokitDetail.routeWithArgs, | ||
arguments = PokitDetail.arguments | ||
) { | ||
val viewModel: PokitDetailViewModel = hiltViewModel() | ||
PokitDetailScreenContainer( | ||
viewModel = viewModel, | ||
onBackPressed = navHostController::popBackStack, | ||
onNavigateToLinkModify = { linkId -> | ||
navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$linkId") | ||
}, | ||
onNavigateToPokitModify = { pokitId -> | ||
navHostController.navigate("${AddPokit.route}?${AddPokit.pokitIdArg}=$pokitId") | ||
} | ||
) | ||
} | ||
|
||
composable( | ||
route = Search.route | ||
) { | ||
val viewModel: SearchViewModel = hiltViewModel() | ||
SearchScreenContainer( | ||
viewModel = viewModel, | ||
onBackPressed = navHostController::popBackStack, | ||
onNavigateToLinkModify = { linkId -> | ||
navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$linkId") | ||
} | ||
) | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.