简体   繁体   English

已弃用 Snackbar 文本参数

[英]Snackbar text parameter deprecated

So i am working with an app in jetpack compose and i see this tutorial Tutorial .所以我正在使用 jetpack compose 中的应用程序,我看到了本教程Tutorial This tutorial builds a default snackbar within a snackbarhost and adds a text to this snackbar in the way below.本教程在一个snackbarhost 中构建一个默认的snackbar,并以下面的方式向这个snackbar 添加一个文本。 Though when i try to add this parameter it tells me that it doesn't exist.虽然当我尝试添加这个参数时它告诉我它不存在。 Why is this is the parameter deprecated and if so what did it get exchanged with?为什么这是不推荐使用的参数,如果是这样,它是用什么交换的? Plus i have the question of how to clear the que in the snackbarhost quz when i click more then once i first get myh last message and then the one i should get?另外,我还有一个问题是,当我单击更多时,如何清除snackbarhost quz 中的问题,然后一旦我第一次收到我的最后一条消息,然后是我应该收到的消息?

Snackbar(
  modifier = Modifier.padding(16.dp),
    text = {
      Text(
        text = data.message,
        style = MaterialTheme.typography.body2,
        color = Color.White
      )
      },
            action = {
                data.actionLabel?.let { actionLabel ->
                    TextButton(
                        onClick = {
                            onDismiss()
                        }
                    ) {
             Text(
                text = actionLabel,
                style = MaterialTheme.typography.body2,
                color = Color.White
            )
         }
      }
   }
)

I'm assume your talking about this line:我假设您在谈论这一行:

Snackbar(
  modifier = Modifier.padding(16.dp),
  text = { // <--

I found a usage example on the Compose Playground here: https://foso.github.io/Jetpack-Compose-Playground/material/snackbar/ (the page also contains a link to the reference of Snackbar )我在 Compose Playground 上找到了一个使用示例: https://foso.github.io/Jetpack-Compose-Playground/material/snackbar/ (该页面还包含指向Snackbar参考的链接

From what I can see, they probably replaced the text arg with the content of the Snackbar, which would result in something similar to this:据我所见,他们可能将text arg 替换为 Snackbar 的内容,这将导致类似于以下内容:

Snackbar(
  modifier = ... same as before ...,
  action = ... same as before ... 
) {
   // Move the text element here
   Text(...)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM