mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Move hardcoded strings to resources
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
1be10010c8
commit
e37d71fba6
4 changed files with 10 additions and 6 deletions
|
@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.Providers
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.platform.setContent
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.compose.KEY_ROUTE
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
|
@ -67,7 +68,7 @@ fun LobstersApp(
|
|||
}
|
||||
)
|
||||
},
|
||||
label = { Text(screen.label) },
|
||||
label = { Text(stringResource(id = screen.labelRes)) },
|
||||
selected = currentRoute == screen.route,
|
||||
onClick = {
|
||||
// This is the equivalent to popUpTo the start destination
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package dev.msfjarvis.lobsters.ui
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import dev.msfjarvis.lobsters.R
|
||||
|
||||
/**
|
||||
* Destinations for navigation within the app.
|
||||
*/
|
||||
sealed class Destination(
|
||||
val route: String,
|
||||
val label: String,
|
||||
@StringRes val labelRes: Int,
|
||||
) {
|
||||
object Hottest : Destination("hottest", "Hottest")
|
||||
object Saved : Destination("saved", "Saved")
|
||||
object Hottest : Destination("hottest", R.string.hottest_posts)
|
||||
object Saved : Destination("saved", R.string.saved_posts)
|
||||
}
|
||||
|
|
|
@ -37,5 +37,3 @@ fun SavedPosts(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
<string name="app_name">lobste.rs</string>
|
||||
<string name="loading">Loading posts…</string>
|
||||
<string name="no_saved_posts">You don\'t have any saved posts</string>
|
||||
<string name="hottest_posts">Hottest</string>
|
||||
<string name="saved_posts">Saved</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue