mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 03:17:03 +05:30
build: upgrade to Compose alpha11
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
b87e242de2
commit
cdfa20b9a7
7 changed files with 35 additions and 7 deletions
|
@ -106,7 +106,12 @@ fun LobstersBottomNav(
|
|||
navBackStackEntry?.arguments?.getString(KEY_ROUTE) ?: Destination.startDestination.route
|
||||
Destination.values().forEach { screen ->
|
||||
BottomNavigationItem(
|
||||
icon = { IconResource(resourceId = screen.badgeRes) },
|
||||
icon = {
|
||||
IconResource(
|
||||
resourceId = screen.badgeRes,
|
||||
contentDescription = stringResource(screen.labelRes),
|
||||
)
|
||||
},
|
||||
label = { Text(stringResource(id = screen.labelRes)) },
|
||||
selected = currentRoute == screen.route,
|
||||
alwaysShowLabels = false,
|
||||
|
|
|
@ -25,11 +25,16 @@ fun EmptyList(saved: Boolean) {
|
|||
IconResource(
|
||||
R.drawable.ic_favorite_border_24px,
|
||||
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))
|
||||
} 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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.IconToggleButton
|
||||
import androidx.compose.material.Surface
|
||||
|
@ -132,9 +133,17 @@ fun LobstersItem(
|
|||
) {
|
||||
Crossfade(current = isSaved) {
|
||||
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 {
|
||||
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),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.msfjarvis.lobsters.ui.posts
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
|
@ -27,12 +27,18 @@ import androidx.compose.ui.res.loadVectorResource
|
|||
@Composable
|
||||
fun IconResource(
|
||||
@DrawableRes resourceId: Int,
|
||||
contentDescription: String,
|
||||
modifier: Modifier = Modifier,
|
||||
tint: Color = AmbientContentColor.current
|
||||
) {
|
||||
val deferredResource = loadVectorResource(resourceId)
|
||||
deferredResource.onLoadRun { vector ->
|
||||
Icon(imageVector = vector, modifier = modifier, tint = tint)
|
||||
Icon(
|
||||
imageVector = vector,
|
||||
modifier = modifier,
|
||||
tint = tint,
|
||||
contentDescription = contentDescription,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
<string name="hottest_posts">Hottest</string>
|
||||
<string name="saved_posts">Saved</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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue