feat: 楼中楼用户昵称点击打开用户资料

This commit is contained in:
HuanCheng65 2023-07-17 14:15:15 +08:00
parent 618cc74f9c
commit ea0bcc9384
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
1 changed files with 16 additions and 8 deletions

View File

@ -77,10 +77,13 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.text.withAnnotation
import androidx.compose.ui.text.withStyle import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
@ -1238,6 +1241,7 @@ private fun BottomBar(
} }
} }
@OptIn(ExperimentalTextApi::class)
@Composable @Composable
fun PostCard( fun PostCard(
postHolder: ImmutableHolder<Post>, postHolder: ImmutableHolder<Post>,
@ -1296,6 +1300,7 @@ fun PostCard(
fontWeight = FontWeight.Bold fontWeight = FontWeight.Bold
) )
) { ) {
withAnnotation("user", "${subPostList.author?.id}") {
append( append(
StringUtil.getUsernameAnnotatedString( StringUtil.getUsernameAnnotatedString(
context, context,
@ -1306,6 +1311,7 @@ fun PostCard(
append(": ") append(": ")
} }
} }
}
val contentStrings = subPostList.content.renders.map { it.toAnnotationString() } val contentStrings = subPostList.content.renders.map { it.toAnnotationString() }
userNameString + contentStrings.reduce { acc, annotatedString -> acc + annotatedString } userNameString + contentStrings.reduce { acc, annotatedString -> acc + annotatedString }
@ -1389,7 +1395,9 @@ fun PostCard(
color = ExtendedTheme.colors.text, color = ExtendedTheme.colors.text,
fontSize = 13.sp, fontSize = 13.sp,
style = MaterialTheme.typography.body2, style = MaterialTheme.typography.body2,
emoticonSize = 0.9f emoticonSize = 0.9f,
overflow = TextOverflow.Ellipsis,
maxLines = 4,
) )
} }