|
|
@ -28,18 +28,11 @@ 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 = {},
|
|
|
|
onClick: () -> Unit,
|
|
|
|
onFollowClick: () -> Unit,
|
|
|
|
|
|
|
|
onUnfollowClick: () -> Unit,
|
|
|
|
|
|
|
|
onBrowseClick: () -> Unit,
|
|
|
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
enabled: Boolean = true,
|
|
|
|
enabled: Boolean = true,
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
followText: @Composable () -> Unit = { Text(stringResource(R.string.follow)) },
|
|
|
|
|
|
|
|
unFollowText: @Composable () -> Unit = { Text(stringResource(R.string.unfollow)) },
|
|
|
|
|
|
|
|
browseText: @Composable () -> Unit = { Text(stringResource(R.string.browse_topic)) }
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
|
|
Box(modifier = modifier) {
|
|
|
|
Box(modifier = modifier) {
|
|
|
@ -49,7 +42,7 @@ fun NiaTopicTag(
|
|
|
|
MaterialTheme.colorScheme.surfaceVariant
|
|
|
|
MaterialTheme.colorScheme.surfaceVariant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NiaTextButton(
|
|
|
|
NiaTextButton(
|
|
|
|
onClick = { onDropMenuToggle(true) },
|
|
|
|
onClick = onClick,
|
|
|
|
enabled = enabled,
|
|
|
|
enabled = enabled,
|
|
|
|
small = true,
|
|
|
|
small = true,
|
|
|
|
colors = NiaButtonDefaults.textButtonColors(
|
|
|
|
colors = NiaButtonDefaults.textButtonColors(
|
|
|
@ -65,25 +58,6 @@ fun NiaTopicTag(
|
|
|
|
),
|
|
|
|
),
|
|
|
|
text = text
|
|
|
|
text = text
|
|
|
|
)
|
|
|
|
)
|
|
|
|
NiaDropdownMenu(
|
|
|
|
|
|
|
|
expanded = expanded,
|
|
|
|
|
|
|
|
onDismissRequest = { onDropMenuToggle(false) },
|
|
|
|
|
|
|
|
items = if (followed) listOf(UNFOLLOW, BROWSE) else listOf(FOLLOW, BROWSE),
|
|
|
|
|
|
|
|
onItemClick = { item ->
|
|
|
|
|
|
|
|
when (item) {
|
|
|
|
|
|
|
|
FOLLOW -> onFollowClick()
|
|
|
|
|
|
|
|
UNFOLLOW -> onUnfollowClick()
|
|
|
|
|
|
|
|
BROWSE -> onBrowseClick()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
itemText = { item ->
|
|
|
|
|
|
|
|
when (item) {
|
|
|
|
|
|
|
|
FOLLOW -> followText()
|
|
|
|
|
|
|
|
UNFOLLOW -> unFollowText()
|
|
|
|
|
|
|
|
BROWSE -> browseText()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|