-
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.
Merge remote-tracking branch 'origin/feature/#28-interceptor-token' i…
…nto feature/#28-interceptor-token
- Loading branch information
Showing
259 changed files
with
8,465 additions
and
556 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
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
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
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" | ||
} | ||
|
||
object Setting { | ||
val route: String = "setting" | ||
} | ||
|
||
object EditNickname { | ||
val route: String = "editNickname" | ||
} | ||
|
||
object Alarm { | ||
val route: String = "alarm" | ||
} |
152 changes: 152 additions & 0 deletions
152
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,152 @@ | ||
package pokitmons.pokit.navigation | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
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.alarm.AlarmScreenContainer | ||
import pokitmons.pokit.alarm.AlarmViewModel | ||
import pokitmons.pokit.home.HomeScreen | ||
import pokitmons.pokit.home.pokit.PokitViewModel | ||
import pokitmons.pokit.login.LoginScreen | ||
import pokitmons.pokit.search.SearchScreenContainer | ||
import pokitmons.pokit.search.SearchViewModel | ||
import pokitmons.pokit.settings.SettingViewModel | ||
import pokitmons.pokit.settings.nickname.EditNicknameScreen | ||
import pokitmons.pokit.settings.setting.SettingsScreen | ||
|
||
@Composable | ||
fun RootNavHost( | ||
navHostController: NavHostController, | ||
) { | ||
NavHost(navController = navHostController, startDestination = Home.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 | ||
) { | ||
val viewModel: AddLinkViewModel = hiltViewModel() | ||
AddLinkScreenContainer( | ||
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, | ||
onBackWithModifySuccess = { modifiedPokitId -> | ||
navHostController.popBackStack() | ||
navHostController.currentBackStackEntry | ||
?.savedStateHandle | ||
?.set("modified_pokit_id", modifiedPokitId) | ||
} | ||
) | ||
} | ||
|
||
composable( | ||
route = PokitDetail.routeWithArgs, | ||
arguments = PokitDetail.arguments | ||
) { | ||
val viewModel: PokitDetailViewModel = hiltViewModel() | ||
LaunchedEffect(it) { | ||
val pokitId = navHostController.currentBackStackEntry?.savedStateHandle?.get<Int>("modified_pokit_id") ?: return@LaunchedEffect | ||
viewModel.getPokit(pokitId) | ||
} | ||
|
||
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") | ||
} | ||
) | ||
} | ||
|
||
composable(route = Setting.route) { | ||
val viewModel: SettingViewModel = hiltViewModel() | ||
SettingsScreen( | ||
settingViewModel = viewModel, | ||
onNavigateToEditNickname = { navHostController.navigate(EditNickname.route) } | ||
) | ||
} | ||
|
||
composable(route = EditNickname.route) { | ||
val viewModel: SettingViewModel = hiltViewModel() | ||
EditNicknameScreen( | ||
settingViewModel = viewModel, | ||
onBackPressed = navHostController::popBackStack | ||
) | ||
} | ||
|
||
composable(route = Home.route) { | ||
val viewModel: PokitViewModel = hiltViewModel() | ||
HomeScreen( | ||
viewModel = viewModel, | ||
onNavigateToSearch = { navHostController.navigate(Search.route) }, | ||
onNavigateToSetting = { navHostController.navigate(Setting.route) }, | ||
onNavigateToPokitDetail = { navHostController.navigate("${PokitDetail.route}/$it") }, | ||
onNavigateAddLink = { navHostController.navigate(AddLink.route) }, | ||
onNavigateAddPokit = { navHostController.navigate(AddPokit.route) } | ||
) | ||
} | ||
|
||
composable(route = Alarm.route) { | ||
val viewModel: AlarmViewModel = hiltViewModel() | ||
AlarmScreenContainer( | ||
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
Oops, something went wrong.