mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 04:27:02 +05:30
Merge #54
54: Cleanup and reformat r=msfjarvis a=msfjarvis bors r+ Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
commit
97dc62afe1
16 changed files with 236 additions and 241 deletions
|
@ -1,4 +1,5 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<!--
|
<!--
|
||||||
If you don't need the activityTestRule, then you can switch to createComposeRule and add
|
If you don't need the activityTestRule, then you can switch to createComposeRule and add
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Providers
|
import androidx.compose.runtime.Providers
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.platform.setContent
|
import androidx.compose.ui.platform.setContent
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.navigation.compose.KEY_ROUTE
|
import androidx.navigation.compose.KEY_ROUTE
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
|
@ -47,9 +48,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LobstersApp(
|
fun LobstersApp(
|
||||||
viewModel: LobstersViewModel
|
viewModel: LobstersViewModel,
|
||||||
) {
|
) {
|
||||||
val urlLauncher = UrlLauncherAmbient.current
|
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val destinations = arrayOf(Destination.Hottest, Destination.Saved)
|
val destinations = arrayOf(Destination.Hottest, Destination.Saved)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ fun LobstersApp(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = { Text(screen.label) },
|
label = { Text(stringResource(id = screen.labelRes)) },
|
||||||
selected = currentRoute == screen.route,
|
selected = currentRoute == screen.route,
|
||||||
onClick = {
|
onClick = {
|
||||||
// This is the equivalent to popUpTo the start destination
|
// This is the equivalent to popUpTo the start destination
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package dev.msfjarvis.lobsters.ui
|
package dev.msfjarvis.lobsters.ui
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import dev.msfjarvis.lobsters.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destinations for navigation within the app.
|
* Destinations for navigation within the app.
|
||||||
*/
|
*/
|
||||||
sealed class Destination(
|
sealed class Destination(
|
||||||
val route: String,
|
val route: String,
|
||||||
val label: String,
|
@StringRes val labelRes: Int,
|
||||||
) {
|
) {
|
||||||
object Hottest : Destination("hottest", "Hottest")
|
object Hottest : Destination("hottest", R.string.hottest_posts)
|
||||||
object Saved : Destination("saved", "Saved")
|
object Saved : Destination("saved", R.string.saved_posts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,3 @@ fun SavedPosts(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M17.65,6.35c-1.63,-1.63 -3.94,-2.57 -6.48,-2.31 -3.67,0.37 -6.69,3.35 -7.1,7.02C3.52,15.91 7.27,20 12,20c3.19,0 5.93,-1.87 7.21,-4.56 0.32,-0.67 -0.16,-1.44 -0.9,-1.44 -0.37,0 -0.72,0.2 -0.88,0.53 -1.13,2.43 -3.84,3.97 -6.8,3.31 -2.22,-0.49 -4.01,-2.3 -4.48,-4.52C5.31,9.44 8.26,6 12,6c1.66,0 3.14,0.69 4.22,1.78l-1.51,1.51c-0.63,0.63 -0.19,1.71 0.7,1.71H19c0.55,0 1,-0.45 1,-1V6.41c0,-0.89 -1.08,-1.34 -1.71,-0.71l-0.64,0.65z"/>
|
|
||||||
</vector>
|
|
|
@ -2,4 +2,6 @@
|
||||||
<string name="app_name">lobste.rs</string>
|
<string name="app_name">lobste.rs</string>
|
||||||
<string name="loading">Loading posts…</string>
|
<string name="loading">Loading posts…</string>
|
||||||
<string name="no_saved_posts">You don\'t have any saved 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>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue