inst/templates/_shared/modules/mod_OptionsThemeSwitcherServer.R

#' Theme Switcher Module Server
#'
#' @return moduleServer() for theme switcher module

OptionsThemeSwitcherServer <- function(id="themeswitcher"){
    PREPShinyDashboardThemes <- function(theme){
        vAvailableThemes <-  c(
            "Blue gradient"     = "blue_gradient",
            "Flat Red   "       = "flat_red",
            "Grey light"        = "grey_light",
            "Grey dark"         = "grey_dark",
            "OneNote"           = "onenote",
            "Poor man's Flatly" = "poor_mans_flatly",
            "Purple gradient"   = "purple_gradient"
        )
        if( theme %in% vAvailableThemes ) {
            selectedTheme <- shinyDashboardThemes(theme)
        } else {
            selectedTheme <- do.call( theme, list() )$theme    # It was a known theme from the package.
        }
        return( selectedTheme )
    }

    retModule <- function( input, output, session ){
        reactive(
            {PREPShinyDashboardThemes(theme = input$dbxChangeTheme)}
        )
    }

    retServer <- moduleServer( id, module = retModule )

    return( retServer )
}
BioPharmSoftGrp/BaSS documentation built on April 2, 2021, 2:34 a.m.