-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use type-safe compose navigation (#43)
* chore: 🤖 upgrade navigation-compose to 2.8.0 beta * refactor: 💡 use type-safe navigation * refactor: 💡 remove old navigation folder * refactor: 💡 move navigation code to MainNavHost
- Loading branch information
Showing
6 changed files
with
36 additions
and
56 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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/rickyhu/hushkeyboard/main/MainNavHost.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,34 @@ | ||
package com.rickyhu.hushkeyboard.main | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import com.rickyhu.hushkeyboard.home.HomeScreen | ||
import com.rickyhu.hushkeyboard.settings.SettingsScreen | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
object HomeRoute | ||
|
||
@Serializable | ||
object SettingsRoute | ||
|
||
@Composable | ||
fun MainNavHost() { | ||
val navController = rememberNavController() | ||
|
||
NavHost( | ||
navController = navController, | ||
startDestination = HomeRoute | ||
) { | ||
composable<HomeRoute> { | ||
HomeScreen( | ||
onSettingsClick = { navController.navigate(route = SettingsRoute) } | ||
) | ||
} | ||
composable<SettingsRoute> { | ||
SettingsScreen() | ||
} | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
app/src/main/java/com/rickyhu/hushkeyboard/navigation/AppNavHost.kt
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/src/main/java/com/rickyhu/hushkeyboard/navigation/HomeRoute.kt
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/src/main/java/com/rickyhu/hushkeyboard/navigation/SettingsRoute.kt
This file was deleted.
Oops, something went wrong.
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