我的应用中包含以下代码:
main_graph
,它会根据用户的响应(通过单击“住院”,“急诊”或“非住院”)弹出一个新按钮(“描述性”,“趋势”或“排名”)。我希望这些新按钮与动画一起显示,例如argument
或android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06
包下的按钮。但是,我遇到了一个问题,其中android.arch.navigation:navigation-ui-ktx:1.0.0-alpha06
)要求我已经预先创建了UI,并且2)无法允许我使用{{1 }}。有没有办法将动画功能合并到androidx.navigation.safeargs
中,从而使我能够绕过这些问题?谢谢!
答案 0 :(得分:0)
我知道这是一个古老的问题,但只需回答即可,以便将来对任何偶然发现此问题的人有所帮助。
您可以使用insertUI
将Animation合并到shinyanimate
中。
免责声明:我是Shinyanimate软件包的作者
这是您上面提供的代码段中的一个最小示例:
library(shinyBS)
library(shiny)
library(shinyanimate)
#ui----
ui = basicPage(
withAnim(),
actionButton("show", "Create a New Analysis")
)
#server----
server = function(input, output, session) {
#Show modal when button is clicked.
observeEvent(input$show, {
showModal(dataModal())
})
#dataModal----
#The main modal dialog function. Sets the initial buttons shown on the dialog.
dataModal <- function() {
modalDialog(
h2("Analysis Setup", align = "center"),
h4("Choose a Setting of Care:", align = "center"),
#Level0----
#Inpatient button. The HTML function (i.e. div, style) is used to evenly space
#the buttons in the dialog window.
div(style="display:inline-block;width:32%;text-align: center;",
popify(actionButton("Inpatientz", "Inpatient", icon("user-md")),
"Inpatient",
"Dialogue 1.")),
tags$div(id = 'placeholder'),
footer = tagList(
modalButton("Cancel"),
actionButton("ok", "OK")
),
#easyClose is an argument which allows the user to click outside the
#dialog window or press the escape key to close the dialog window.
easyClose = TRUE
)
}
#Level1----
observeEvent(input$Inpatientz, {
#Adds Descriptive Statistics button with popover.
insertUI(selector = '#placeholder',
ui = bsButton("Descriptivez", "Descriptive Statistics", style = "default", size = "default"), immediate = TRUE
)
startAnim(session, 'Descriptivez', 'bounce')
# addPopover(session, "Descriptivez", "Descriptive Statistics", "Quote 1")
})
#Close Modal
observeEvent(input$ok, {
removeModal()
})
}
shinyApp(ui, server)