diff --git a/R/f7Page.R b/R/f7Page.R index c1b637e1..c19ea91d 100644 --- a/R/f7Page.R +++ b/R/f7Page.R @@ -467,67 +467,7 @@ f7TabLayout <- function(..., navbar, messagebar = NULL, panels = NULL) { #' @param panel Slot for \link{f7Panel}. Expect only a right panel, for instance: #' \code{f7Panel(title = "Left Panel", side = "right", theme = "light", "Blabla", style = "cover")} #' -#' @examples -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' shinyApp( -#' ui = f7Page( -#' title = "Split layout", -#' f7SplitLayout( -#' sidebar = f7Panel( -#' id = "sidebar", -#' title = "Sidebar", -#' side = "left", -#' f7PanelMenu( -#' id = "menu", -#' f7PanelItem( -#' tabName = "tab1", -#' title = "Tab 1", -#' icon = f7Icon("envelope"), -#' active = TRUE -#' ), -#' f7PanelItem( -#' tabName = "tab2", -#' title = "Tab 2", -#' icon = f7Icon("house") -#' ) -#' ), -#' uiOutput("selected_tab") -#' ), -#' navbar = f7Navbar( -#' title = "Split Layout" -#' ), -#' toolbar = f7Toolbar( -#' position = "bottom", -#' f7Link(label = "Link 1", href = "https://www.google.com"), -#' f7Link(label = "Link 2", href = "https://www.google.com") -#' ), -#' # main content -#' f7Items( -#' f7Item( -#' tabName = "tab1", -#' f7Slider("obs", "Number of observations:", -#' min = 0, max = 1000, value = 500 -#' ), -#' plotOutput("distPlot") -#' ), -#' f7Item(tabName = "tab2", "Tab 2 content") -#' ) -#' ) -#' ), -#' server = function(input, output) { -#' output$selected_tab <- renderUI({ -#' HTML(paste0("Selected tab: ", strong(input$menu))) -#' }) -#' -#' output$distPlot <- renderPlot({ -#' dist <- rnorm(input$obs) -#' hist(dist) -#' }) -#' } -#' ) -#' } +#' @example inst/examples/split_layout/app.R #' #' @author David Granjon, \email{dgranjon@@ymail.com} #' @export diff --git a/man/f7SplitLayout.Rd b/man/f7SplitLayout.Rd index d3664895..203a6c3e 100644 --- a/man/f7SplitLayout.Rd +++ b/man/f7SplitLayout.Rd @@ -24,67 +24,170 @@ This is a modified version of the \link{f7SingleLayout}. It is intended to be used with tablets. } \examples{ -if (interactive()) { - library(shiny) - library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Split layout", - f7SplitLayout( - sidebar = f7Panel( - id = "sidebar", - title = "Sidebar", - side = "left", - f7PanelMenu( - id = "menu", - f7PanelItem( - tabName = "tab1", - title = "Tab 1", - icon = f7Icon("envelope"), - active = TRUE - ), - f7PanelItem( - tabName = "tab2", - title = "Tab 2", - icon = f7Icon("house") - ) +library(shiny) +library(ggplot2) +library(shinyMobile) +library(apexcharter) + +fruits <- data.frame( + name = c('Apples', 'Oranges', 'Bananas', 'Berries'), + value = c(44, 55, 67, 83) +) + +new_mtcars <- reshape( + data = head(mtcars), + idvar = "model", + varying = list(c("drat", "wt")), + times = c("drat", "wt"), + direction = "long", + v.names = "value", + drop = c("mpg", "cyl", "hp", "dist", "qsec", "vs", "am", "gear", "carb") +) + +shinyApp( + ui = f7Page( + title = "Split layout", + options = list( + theme = "auto", + dark = TRUE, + filled = FALSE, + color = "#007aff", + touch = list( + tapHold = TRUE, + tapHoldDelay = 750, + iosTouchRipple = FALSE + ), + iosTranslucentBars = FALSE, + navbar = list( + iosCenterTitle = TRUE, + hideOnPageScroll = TRUE + ), + toolbar = list( + hideOnPageScroll = FALSE + ), + pullToRefresh = FALSE + ), + f7SplitLayout( + sidebar = f7Panel( + id = "sidebar", + title = "Sidebar", + side = "left", + f7PanelMenu( + id = "menu", + f7PanelItem( + tabName = "tab1", + title = "Tab 1", + icon = f7Icon("equal_circle"), + active = TRUE ), - uiOutput("selected_tab") + f7PanelItem( + tabName = "tab2", + title = "Tab 2", + icon = f7Icon("equal_circle") + ), + f7PanelItem( + tabName = "tab3", + title = "Tab 3", + icon = f7Icon("equal_circle") + ) ), - navbar = f7Navbar( - title = "Split Layout" + uiOutput("selected_tab") + ), + navbar = f7Navbar( + title = "Split Layout", + hairline = FALSE + ), + toolbar = f7Toolbar( + position = "bottom", + f7Link(label = "Link 1", href = "https://www.google.com"), + f7Link(label = "Link 2", href = "https://www.google.com") + ), + # main content + f7Items( + f7Item( + tabName = "tab1", + f7Button("toggleSheet", "Plot parameters"), + f7Sheet( + id = "sheet1", + label = "Plot Parameters", + orientation = "bottom", + swipeToClose = TRUE, + backdrop = TRUE, + f7Slider( + "obs", + "Number of observations:", + min = 0, max = 1000, + value = 500 + ) + ), + br(), + plotOutput("distPlot") ), - toolbar = f7Toolbar( - position = "bottom", - f7Link(label = "Link 1", href = "https://www.google.com"), - f7Link(label = "Link 2", href = "https://www.google.com") + f7Item( + tabName = "tab2", + apexchartOutput("radar") ), - # main content - f7Items( - f7Item( - tabName = "tab1", - f7Slider("obs", "Number of observations:", - min = 0, max = 1000, value = 500 - ), - plotOutput("distPlot") + f7Item( + tabName = "tab3", + f7Toggle( + inputId = "plot_show", + label = "Show Plot?", + checked = TRUE ), - f7Item(tabName = "tab2", "Tab 2 content") + apexchartOutput("multi_radial") ) ) - ), - server = function(input, output) { - output$selected_tab <- renderUI({ - HTML(paste0("Selected tab: ", strong(input$menu))) - }) + ) + ), + server = function(input, output, session) { - output$distPlot <- renderPlot({ - dist <- rnorm(input$obs) - hist(dist) - }) - } - ) -} + observeEvent(input$toggleSheet, { + updateF7Sheet(id = "sheet1") + }) + + observeEvent(input$obs, { + if (input$obs < 500) { + f7Notif( + text = paste0( + "The slider value is only ", input$obs, ". Please + increase it" + ), + icon = f7Icon("bolt_fill"), + title = "Alert", + titleRightText = Sys.Date() + ) + } + }) + + + output$radar <- renderApexchart({ + apex( + data = new_mtcars, + type = "radar", + mapping = aes( + x = model, + y = value, + group = time) + ) + }) + + output$selected_tab <- renderUI({ + HTML(paste0("Access the currently selected tab: ", strong(input$menu))) + }) + + output$distPlot <- renderPlot({ + dist <- rnorm(input$obs) + hist(dist) + }) + + output$multi_radial <- renderApexchart({ + if (input$plot_show) { + apex(data = fruits, type = "radialBar", mapping = aes(x = name, y = value)) + } + }) + } +) } \author{ David Granjon, \email{dgranjon@ymail.com}