build: upgrade to Compose alpha11

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-02-08 13:15:12 +05:30
parent b87e242de2
commit cdfa20b9a7
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
7 changed files with 35 additions and 7 deletions

View file

@ -106,7 +106,12 @@ fun LobstersBottomNav(
navBackStackEntry?.arguments?.getString(KEY_ROUTE) ?: Destination.startDestination.route navBackStackEntry?.arguments?.getString(KEY_ROUTE) ?: Destination.startDestination.route
Destination.values().forEach { screen -> Destination.values().forEach { screen ->
BottomNavigationItem( BottomNavigationItem(
icon = { IconResource(resourceId = screen.badgeRes) }, icon = {
IconResource(
resourceId = screen.badgeRes,
contentDescription = stringResource(screen.labelRes),
)
},
label = { Text(stringResource(id = screen.labelRes)) }, label = { Text(stringResource(id = screen.labelRes)) },
selected = currentRoute == screen.route, selected = currentRoute == screen.route,
alwaysShowLabels = false, alwaysShowLabels = false,

View file

@ -25,11 +25,16 @@ fun EmptyList(saved: Boolean) {
IconResource( IconResource(
R.drawable.ic_favorite_border_24px, R.drawable.ic_favorite_border_24px,
tint = Color(0xFFD97373), tint = Color(0xFFD97373),
modifier = Modifier.padding(16.dp) modifier = Modifier.padding(16.dp),
contentDescription = stringResource(R.string.add_to_saved_posts),
) )
Text(stringResource(R.string.no_saved_posts)) Text(stringResource(R.string.no_saved_posts))
} else { } else {
IconResource(R.drawable.ic_sync_problem_24px, modifier = Modifier.padding(16.dp)) IconResource(
R.drawable.ic_sync_problem_24px,
modifier = Modifier.padding(16.dp),
contentDescription = stringResource(R.string.remove_from_saved_posts),
)
Text(stringResource(R.string.loading)) Text(stringResource(R.string.loading))
} }
} }

View file

@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.IconToggleButton import androidx.compose.material.IconToggleButton
import androidx.compose.material.Surface import androidx.compose.material.Surface
@ -132,9 +133,17 @@ fun LobstersItem(
) { ) {
Crossfade(current = isSaved) { Crossfade(current = isSaved) {
if (it) { if (it) {
IconResource(resourceId = R.drawable.ic_favorite_24px, tint = Color(0xFFD97373)) IconResource(
resourceId = R.drawable.ic_favorite_24px,
tint = Color(0xFFD97373),
contentDescription = stringResource(R.string.remove_from_saved_posts),
)
} else { } else {
IconResource(resourceId = R.drawable.ic_favorite_border_24px, tint = Color(0xFFD97373)) IconResource(
resourceId = R.drawable.ic_favorite_border_24px,
tint = Color(0xFFD97373),
contentDescription = stringResource(R.string.add_to_saved_posts),
)
} }
} }
} }

View file

@ -1,6 +1,7 @@
package dev.msfjarvis.lobsters.ui.posts package dev.msfjarvis.lobsters.ui.posts
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier

View file

@ -27,12 +27,18 @@ import androidx.compose.ui.res.loadVectorResource
@Composable @Composable
fun IconResource( fun IconResource(
@DrawableRes resourceId: Int, @DrawableRes resourceId: Int,
contentDescription: String,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
tint: Color = AmbientContentColor.current tint: Color = AmbientContentColor.current
) { ) {
val deferredResource = loadVectorResource(resourceId) val deferredResource = loadVectorResource(resourceId)
deferredResource.onLoadRun { vector -> deferredResource.onLoadRun { vector ->
Icon(imageVector = vector, modifier = modifier, tint = tint) Icon(
imageVector = vector,
modifier = modifier,
tint = tint,
contentDescription = contentDescription,
)
} }
} }

View file

@ -5,4 +5,6 @@
<string name="hottest_posts">Hottest</string> <string name="hottest_posts">Hottest</string>
<string name="saved_posts">Saved</string> <string name="saved_posts">Saved</string>
<string name="submitted_by">submitted by %1$s</string> <string name="submitted_by">submitted by %1$s</string>
<string name="add_to_saved_posts">Add to saved posts</string>
<string name="remove_from_saved_posts">Remove from saved posts</string>
</resources> </resources>

View file

@ -15,7 +15,7 @@ object Plugins {
} }
object Dependencies { object Dependencies {
const val COMPOSE_VERSION = "1.0.0-alpha10" const val COMPOSE_VERSION = "1.0.0-alpha11"
object Kotlin { object Kotlin {