Skip to content

Commit

Permalink
Adding favorites to the bottombar
Browse files Browse the repository at this point in the history
  • Loading branch information
jakepurple13 committed Dec 22, 2023
1 parent fb3c5ad commit e9f5fcc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import androidx.compose.material.icons.filled.BookmarkRemove
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.OpenInBrowser
import androidx.compose.material.icons.filled.Save
Expand Down Expand Up @@ -319,9 +321,12 @@ fun DetailBottomBar(
topBarColor: Color,
modifier: Modifier = Modifier,
containerColor: Color = Color.Transparent,
isFavorite: Boolean,
onFavoriteClick: (Boolean) -> Unit,
bottomAppBarScrollBehavior: BottomAppBarScrollBehavior? = null,
windowInsets: WindowInsets = WindowInsets(0.dp),
) {
val swatchInfo = LocalSwatchInfo.current.colors
BottomAppBar(
actions = {
ToolTipWrapper(
Expand All @@ -340,6 +345,15 @@ fun DetailBottomBar(
) { Icon(Icons.Default.Search, null) }
}

ToolTipWrapper(info = { Text(stringResource(if (isFavorite) R.string.removeFromFavorites else R.string.addToFavorites)) }) {
IconButton(onClick = { onFavoriteClick(isFavorite) }) {
Icon(
if (isFavorite) Icons.Default.Favorite else Icons.Default.FavoriteBorder,
contentDescription = null,
)
}
}

customActions()
},
floatingActionButton = {
Expand All @@ -349,7 +363,6 @@ fun DetailBottomBar(
exit = slideOutHorizontally { it },
label = "",
) {
val swatchInfo = LocalSwatchInfo.current.colors
ExtendedFloatingActionButton(
onClick = removeFromSaved,
text = { Text("Remove from Saved") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ fun DetailsView(
isSaved = isSaved,
bottomAppBarScrollBehavior = bottomAppBarScrollBehavior,
topBarColor = topBarColor,
isFavorite = isFavorite,
onFavoriteClick = onFavoriteClick,
modifier = Modifier
.padding(LocalNavHostPadding.current)
.drawWithCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ private fun DetailsLandscapeContent(
windowInsets = BottomAppBarDefaults.windowInsets,
topBarColor = topBarColor,
containerColor = c,
isFavorite = isFavorite,
onFavoriteClick = onFavoriteClick,
modifier = Modifier
.padding(LocalNavHostPadding.current)
.drawWithCache {
Expand Down

0 comments on commit e9f5fcc

Please sign in to comment.