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