编程语言
首页 > 编程语言> > 手机直播源码,实现简单的聊天列表

手机直播源码,实现简单的聊天列表

作者:互联网

手机直播源码,实现简单的聊天列表

 

@Composable
fun MessageCard(msg: Message) {
Row(modifier = Modifier.padding(all = 8.dp)) {
//设置图片
Image(
painter = painterResource(R.drawable.img),
contentDescription = null,
modifier = Modifier
.size(40.dp)
.clip(CircleShape)
.border(1.5.dp, MaterialTheme.colors.secondaryVariant, CircleShape)
)

设置间距

 

Spacer(modifier = Modifier.width(8.dp))
    // We keep track if the message is expanded or not in this
    // variable 消息是否展开的动画
    var isExpanded by remember { mutableStateOf(false) }
    // We toggle the isExpanded variable when we click on this Column
    Column(modifier = Modifier.clickable { isExpanded = !isExpanded }) {
        //设置文本属性
        Text(
            text = msg.author,
            color = MaterialTheme.colors.secondaryVariant,
            style = MaterialTheme.typography.subtitle2
        )
        Spacer(modifier = Modifier.height(4.dp))
        Surface(
            shape = MaterialTheme.shapes.medium,
            elevation = 1.dp,
        ) {
            Text(
                text = msg.body,
                modifier = Modifier.padding(all = 4.dp),
                // If the message is expanded, we display all its content
                // otherwise we only display the first line
                maxLines = if (isExpanded) Int.MAX_VALUE else 1,
                style = MaterialTheme.typography.body2
            )
        }
    }
}
    // We keep track if the message is expanded or not in this
    // variable 消息是否展开的动画
    var isExpanded by remember { mutableStateOf(false) }
    // We toggle the isExpanded variable when we click on this Column
    Column(modifier = Modifier.clickable { isExpanded = !isExpanded }) {
        //设置文本属性
        Text(
            text = msg.author,
            color = MaterialTheme.colors.secondaryVariant,
            style = MaterialTheme.typography.subtitle2
        )
        Spacer(modifier = Modifier.height(4.dp))
        Surface(
            shape = MaterialTheme.shapes.medium,
            elevation = 1.dp,
        ) {
            Text(
                text = msg.body,
                modifier = Modifier.padding(all = 4.dp),
                // If the message is expanded, we display all its content
                // otherwise we only display the first line
                maxLines = if (isExpanded) Int.MAX_VALUE else 1,
                style = MaterialTheme.typography.body2
            )
        }
    }
}

 

以上就是手机直播源码,实现简单的聊天列表, 更多内容欢迎关注之后的文章

 

标签:isExpanded,modifier,MaterialTheme,列表,直播,msg,Modifier,源码,dp
来源: https://www.cnblogs.com/yunbaomengnan/p/16266579.html