|
|
@ -21,10 +21,6 @@ import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.contentColorFor
|
|
|
|
import androidx.compose.material3.contentColorFor
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
@ -32,7 +28,9 @@ import com.google.samples.apps.nowinandroid.core.designsystem.R
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun NiaTopicTag(
|
|
|
|
fun NiaTopicTag(
|
|
|
|
|
|
|
|
expanded: Boolean = false,
|
|
|
|
followed: Boolean,
|
|
|
|
followed: Boolean,
|
|
|
|
|
|
|
|
onDropMenuToggle: (show: Boolean) -> Unit = {},
|
|
|
|
onFollowClick: () -> Unit,
|
|
|
|
onFollowClick: () -> Unit,
|
|
|
|
onUnfollowClick: () -> Unit,
|
|
|
|
onUnfollowClick: () -> Unit,
|
|
|
|
onBrowseClick: () -> Unit,
|
|
|
|
onBrowseClick: () -> Unit,
|
|
|
@ -43,7 +41,7 @@ fun NiaTopicTag(
|
|
|
|
unFollowText: @Composable () -> Unit = { Text(stringResource(R.string.unfollow)) },
|
|
|
|
unFollowText: @Composable () -> Unit = { Text(stringResource(R.string.unfollow)) },
|
|
|
|
browseText: @Composable () -> Unit = { Text(stringResource(R.string.browse_topic)) }
|
|
|
|
browseText: @Composable () -> Unit = { Text(stringResource(R.string.browse_topic)) }
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
var expanded by remember { mutableStateOf(false) }
|
|
|
|
|
|
|
|
Box(modifier = modifier) {
|
|
|
|
Box(modifier = modifier) {
|
|
|
|
val containerColor = if (followed) {
|
|
|
|
val containerColor = if (followed) {
|
|
|
|
MaterialTheme.colorScheme.primaryContainer
|
|
|
|
MaterialTheme.colorScheme.primaryContainer
|
|
|
@ -51,7 +49,7 @@ fun NiaTopicTag(
|
|
|
|
MaterialTheme.colorScheme.surfaceVariant
|
|
|
|
MaterialTheme.colorScheme.surfaceVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NiaTextButton(
|
|
|
|
NiaTextButton(
|
|
|
|
onClick = { expanded = true },
|
|
|
|
onClick = { onDropMenuToggle(true) },
|
|
|
|
enabled = enabled,
|
|
|
|
enabled = enabled,
|
|
|
|
small = true,
|
|
|
|
small = true,
|
|
|
|
colors = NiaButtonDefaults.textButtonColors(
|
|
|
|
colors = NiaButtonDefaults.textButtonColors(
|
|
|
@ -69,7 +67,7 @@ fun NiaTopicTag(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
NiaDropdownMenu(
|
|
|
|
NiaDropdownMenu(
|
|
|
|
expanded = expanded,
|
|
|
|
expanded = expanded,
|
|
|
|
onDismissRequest = { expanded = false },
|
|
|
|
onDismissRequest = { onDropMenuToggle(false) },
|
|
|
|
items = if (followed) listOf(UNFOLLOW, BROWSE) else listOf(FOLLOW, BROWSE),
|
|
|
|
items = if (followed) listOf(UNFOLLOW, BROWSE) else listOf(FOLLOW, BROWSE),
|
|
|
|
onItemClick = { item ->
|
|
|
|
onItemClick = { item ->
|
|
|
|
when (item) {
|
|
|
|
when (item) {
|
|
|
|