shinyMobile icon indicating copy to clipboard operation
shinyMobile copied to clipboard

rnederUI dont works in render tabs

Open lemuelemos opened this issue 3 years ago • 1 comments

library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.0.5
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)
#> Warning: package 'tidyr' was built under R version 4.0.5
library(echarts4r)
#> Warning: package 'echarts4r' was built under R version 4.0.5
library(shinyWidgets)
library(shinyMobile)
#> Warning: package 'shinyMobile' was built under R version 4.0.5
library(shiny)


tabs <- function(background,nome,icon,html_extra,...){
  tab <- f7Tab(
    tabName = nome,
    icon = f7Icon(icon),
    active = F,
    html_extra,
    ...
  )
  tab[[1]][[2]]$style <- stringr::str_replace("background-color: cor;","cor",background)
  return(tab)
}

ui = f7Page(
  title = "7RD App",
  options = list(theme = "md",
                 dark = F),
  f7TabLayout(
    navbar = f7Navbar(title = textOutput("nome_assessor"),
                      shadow = F,
                      leftPanel = T),
    uiOutput("tabs")
  )
)

server = function(input, output, session) {
  
  output$tabs <- renderUI({
    f7Tabs(id = "tab_id",
           animated = F,
           swipeable = T,
           style = "toolbar",
           tabs("white",
                "Descrição da Campanha",
                "text_bubble",
                includeHTML(h1("Hi One"))),
           tabs("white",
                "Números",
                "chart_bar",
                includeHTML(h1("Hi One"))
           )
    )
  })
  
  output$nome_assessor <- renderText({
    paste0("Bem-Vindo ",session$userData$auth0_info$name)
  })
  
  output$nome_assessor_rel <- renderText({
    session$userData$auth0_info$name
  })
  
  observe({
    print(session$userData$auth0_info)
  })
  
}
options(shiny.port = 8181)
shinyApp(ui, server)
#> PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.

Shiny applications not supported in static R Markdown documents

Created on 2021-09-03 by the reprex package (v2.0.0)

lemuelemos avatar Sep 03 '21 11:09 lemuelemos

Have any solution for this problem?

lemuelemos avatar Sep 03 '21 11:09 lemuelemos

Hi,

Now that you can insert tabs in empty tabsetpanel, there is no need anymore for renderUI (see why here: https://mastering-shiny.org/action-dynamic.html#programming-ui):

library(shiny)
 ui <- f7Page(
   f7SingleLayout(
     navbar = f7Navbar(),
     f7Button("add", "Add 'Dynamic' tab"),
     br(),
     f7Tabs(id = "tabs"),
   )
 )
 server <- function(input, output, session) {
   observeEvent(input$add, {
     insertF7Tab(
       id = "tabs",
       f7Tab(title = "Dynamic", tabName = "Dynamic", "This a dynamically-added tab"),
       target = NULL
     )
   })
 }
 shinyApp(ui, server)

DivadNojnarg avatar Nov 30 '22 05:11 DivadNojnarg