|
|
|
@ -18,22 +18,20 @@ package com.google.samples.apps.nowinandroid.feature.interests
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
|
import androidx.compose.material3.ListItem
|
|
|
|
|
import androidx.compose.material3.ListItemDefaults
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
|
import androidx.compose.material3.Surface
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.semantics.semantics
|
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
|
import androidx.compose.ui.unit.Dp
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.component.DynamicAsyncImage
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconToggleButton
|
|
|
|
@ -51,23 +49,18 @@ fun InterestsItem(
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
|
iconModifier: Modifier = Modifier,
|
|
|
|
|
description: String = "",
|
|
|
|
|
itemSeparation: Dp = 16.dp,
|
|
|
|
|
) {
|
|
|
|
|
Row(
|
|
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
|
|
modifier = modifier,
|
|
|
|
|
) {
|
|
|
|
|
Row(
|
|
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.weight(1f)
|
|
|
|
|
.clickable { onClick() }
|
|
|
|
|
.padding(vertical = itemSeparation),
|
|
|
|
|
) {
|
|
|
|
|
ListItem(
|
|
|
|
|
leadingContent = {
|
|
|
|
|
InterestsIcon(topicImageUrl, iconModifier.size(64.dp))
|
|
|
|
|
Spacer(modifier = Modifier.width(24.dp))
|
|
|
|
|
InterestContent(name, description)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
headlineContent = {
|
|
|
|
|
Text(text = name)
|
|
|
|
|
},
|
|
|
|
|
supportingContent = {
|
|
|
|
|
Text(text = description)
|
|
|
|
|
},
|
|
|
|
|
trailingContent = {
|
|
|
|
|
NiaIconToggleButton(
|
|
|
|
|
checked = following,
|
|
|
|
|
onCheckedChange = onFollowButtonClick,
|
|
|
|
@ -88,26 +81,14 @@ fun InterestsItem(
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
private fun InterestContent(name: String, description: String, modifier: Modifier = Modifier) {
|
|
|
|
|
Column(modifier) {
|
|
|
|
|
Text(
|
|
|
|
|
text = name,
|
|
|
|
|
style = MaterialTheme.typography.headlineSmall,
|
|
|
|
|
modifier = Modifier.padding(
|
|
|
|
|
vertical = if (description.isEmpty()) 0.dp else 4.dp,
|
|
|
|
|
},
|
|
|
|
|
colors = ListItemDefaults.colors(
|
|
|
|
|
containerColor = Color.Transparent,
|
|
|
|
|
),
|
|
|
|
|
modifier = modifier
|
|
|
|
|
.semantics(mergeDescendants = true) { /* no-op */ }
|
|
|
|
|
.clickable(enabled = true, onClick = onClick),
|
|
|
|
|
)
|
|
|
|
|
if (description.isNotEmpty()) {
|
|
|
|
|
Text(
|
|
|
|
|
text = description,
|
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|