diff --git a/NAMESPACE b/NAMESPACE index 17ac98d3..45107b48 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,6 +38,7 @@ export(f7Float) export(f7Found) export(f7Gallery) export(f7Gauge) +export(f7Grid) export(f7HideOnEnable) export(f7HideOnSearch) export(f7HidePreloader) @@ -92,6 +93,7 @@ export(f7Skeleton) export(f7Slide) export(f7Slider) export(f7SmartSelect) +export(f7SocialCard) export(f7SplitLayout) export(f7Stepper) export(f7SubNavbar) @@ -128,6 +130,7 @@ export(updateF7App) export(updateF7AutoComplete) export(updateF7Button) export(updateF7Card) +export(updateF7Checkbox) export(updateF7DatePicker) export(updateF7Entity) export(updateF7Fab) diff --git a/NEWS.md b/NEWS.md index 4909072a..78063d51 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,7 @@ - `shadow` and `subtitle` have been removed in Framework7. - `f7SocialCard()` is deprecated as the same result can be achieved with `f7Card()`. - `f7AutoComplete()`: `expandInput` is deprecated, removed from Framework7. +- `f7Row()`, `f7Col()` and `f7Flex()` are deprecated in favor of `f7Grid()`, as specified by Framework7. ## Minor change - `f7Messages()`: the corresponding input is now a list of lists, each item diff --git a/R/f7-inputs.R b/R/f7-inputs.R index 92e400b3..0969fef9 100644 --- a/R/f7-inputs.R +++ b/R/f7-inputs.R @@ -932,6 +932,7 @@ f7Checkbox <- function(inputId, label, value = FALSE) { #' @param label The label to set for the input object. Does not work. #' @param value The value to set for the input object. #' @param session The Shiny session object. +#' @export updateF7Checkbox <- function(inputId, label = NULL, value = NULL, session = shiny::getDefaultReactiveDomain()) { message <- dropNulls(list(label = label, value = value)) diff --git a/R/f7Card.R b/R/f7Card.R index 00489002..41393ad5 100644 --- a/R/f7Card.R +++ b/R/f7Card.R @@ -119,9 +119,10 @@ f7Card <- function(..., image = NULL, title = NULL, footer = NULL, outline = FAL #' @param footer Footer content, if any. Must be wrapped in a tagList. #' #' @keywords internal +#' @export f7SocialCard <- function(..., image = NULL, author = NULL, date = NULL, footer = NULL) { - lifecycle::deprecate_warn("1.1.0", "f7SocialCard", "f7Card()") + lifecycle::deprecate_warn("1.1.0", "f7SocialCard()", "f7Card()") headerTag <- shiny::tags$div( class = "card-header", diff --git a/R/f7Dialog.R b/R/f7Dialog.R index 9f2bdc8c..330f35fb 100644 --- a/R/f7Dialog.R +++ b/R/f7Dialog.R @@ -11,131 +11,10 @@ #' #' @export #' -#' @examples -#' # simple alert -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' shinyApp( -#' ui = f7Page( -#' title = "Simple Dialog", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Dialog"), -#' f7Button(inputId = "goButton", "Go!") -#' ) -#' ), -#' server = function(input, output, session) { -#' observeEvent(input$goButton,{ -#' f7Dialog( -#' title = "Dialog title", -#' text = "This is an alert dialog" -#' ) -#' }) -#' } -#' ) -#' } -#' # confirm alert -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' shinyApp( -#' ui = f7Page( -#' title = "Confirm Dialog", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Dialog"), -#' f7Button(inputId = "goButton", "Go!") -#' ) -#' ), -#' server = function(input, output, session) { -#' -#' observeEvent(input$goButton,{ -#' f7Dialog( -#' id = "test", -#' title = "Dialog title", -#' type = "confirm", -#' text = "This is an alert dialog" -#' ) -#' }) -#' -#' observeEvent(input$test, { -#' f7Toast(text = paste("Alert input is:", input$test)) -#' }) -#' -#' } -#' ) -#' } -#' # prompt dialog -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' shinyApp( -#' ui = f7Page( -#' title = "Prompt Dialog", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Dialog"), -#' f7Button(inputId = "goButton", "Go!"), -#' uiOutput("res") -#' ) -#' ), -#' server = function(input, output, session) { -#' -#' observe({ -#' print(input$prompt) -#' }) -#' -#' observeEvent(input$goButton,{ -#' f7Dialog( -#' id = "prompt", -#' title = "Dialog title", -#' type = "prompt", -#' text = "This is a prompt dialog" -#' ) -#' }) -#' -#' output$res <- renderUI(f7BlockTitle(title = input$prompt, size = "large")) -#' } -#' ) -#' } -#' -#' # login dialog -#' if (interactive()) { -#' library(shiny) -#' library(shinyMobile) -#' shinyApp( -#' ui = f7Page( -#' title = "Login Dialog", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Dialog"), -#' f7Button(inputId = "goButton", "Go!"), -#' uiOutput("ui") -#' ) -#' ), -#' server = function(input, output, session) { -#' -#' observe({ -#' print(input$login) -#' }) -#' -#' observeEvent(input$goButton,{ -#' f7Dialog( -#' id = "login", -#' title = "Dialog title", -#' type = "login", -#' text = "This is an login dialog" -#' ) -#' }) -#' -#' output$ui <- renderUI({ -#' req(input$login$user == "David" & input$login$password == "prout") -#' img(src = "https://media2.giphy.com/media/12gfL8Xxrhv7C1fXiV/giphy.gif") -#' }) -#' } -#' ) -#' } +#' @example inst/examples/dialog/app.R f7Dialog <- function(id = NULL, title = NULL, text, type = c("alert", "confirm", "prompt", "login"), session = shiny::getDefaultReactiveDomain()) { - type <- match.arg(type) if (is.null(id) && type %in% c("confirm", "prompt", "login")) { @@ -144,7 +23,11 @@ f7Dialog <- function(id = NULL, title = NULL, text, # force to render shiny.tag and convert it to character # since text does not accept anything else - text <- if (class(text) %in% c("shiny.tag" , "shiny.tag.list")) as.character(force(text)) else text + text <- if (class(text) %in% c("shiny.tag", "shiny.tag.list")) { + as.character(force(text)) + } else { + text + } message <- dropNulls( list( @@ -163,5 +46,4 @@ f7Dialog <- function(id = NULL, title = NULL, text, json_verbatim = TRUE ) ) - } diff --git a/R/f7Grid.R b/R/f7Grid.R index ff5f14a7..528f7ba9 100644 --- a/R/f7Grid.R +++ b/R/f7Grid.R @@ -1,59 +1,41 @@ -#' Framework7 row container +#' Framework7 grid container #' -#' Build a Framework7 row container +#' Grid container for elements #' #' @param ... Row content. +#' @param cols Columns number. Numeric between 1 and 20. #' @param gap Whether to display gap between columns. TRUE by default. #' -#' @examples -#' if(interactive()){ -#' library(shiny) -#' library(shinyMobile) +#' @author David Granjon, \email{dgranjon@@ymail.com} +#' @export +f7Grid <- function(..., cols, gap = TRUE) { + cl <- sprintf("grid grid-cols-%s", cols) + if (gap) cl <- paste(cl, "grid-gap") + shiny::tags$div(class = cl, ...) +} + + +#' Framework7 row container +#' +#' `r lifecycle::badge("deprecated")` +#' \link{f7Grid} is a replacement #' -#' shinyApp( -#' ui = f7Page( -#' title = "Grid", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Row, f7Col"), -#' f7Row( -#' f7Col( -#' f7Card( -#' "This is a simple card with plain text, -#' but cards can also contain their own header, -#' footer, list view, image, or any other element." -#' ) -#' ), -#' f7Col( -#' f7Card( -#' title = "Card header", -#' "This is a simple card with plain text, -#' but cards can also contain their own header, -#' footer, list view, image, or any other element.", -#' footer = tagList( -#' f7Button(color = "blue", label = "My button"), -#' f7Badge("Badge", color = "green") -#' ) -#' ) -#' ) -#' ) -#' ) -#' ), -#' server = function(input, output) {} -#' ) -#' } +#' @param ... Row content. +#' @param gap Whether to display gap between columns. TRUE by default. #' #' @author David Granjon, \email{dgranjon@@ymail.com} #' +#' @keywords internal #' @export f7Row <- function(..., gap = TRUE) { - shiny::tags$div(class = if (gap) "row" else "row no-gap", ...) + lifecycle::deprecate_warn("1.1.0", "f7Row()", "f7Grid()") + shiny::tags$div(class = if (gap) "row" else "row no-gap", ...) } - - #' Framework7 column container #' -#' Build a Framework7 column container +#' `r lifecycle::badge("deprecated")` +#' \link{f7Grid} is a replacement #' #' @param ... Column content. The width is automatically handled depending #' on the number of columns. @@ -63,131 +45,27 @@ f7Row <- function(..., gap = TRUE) { #' @note The dark theme does not work for items embedded in a column. Use \link{f7Flex} #' instead. #' +#' @keywords internal #' @export -f7Col <- function(...) shiny::tags$div(class = "col", ...) - - - +f7Col <- function(...) { + lifecycle::deprecate_warn("1.1.0", "f7Row()", "f7Grid()") + shiny::tags$div(class = "col", ...) +} #' Framework7 flex container #' -#' Build a Framework7 flex container +#' `r lifecycle::badge("deprecated")` +#' \link{f7Grid} is a replacement #' #' @param ... Items. -#' -#' @examples -#' if(interactive()){ -#' library(shiny) -#' library(shinyMobile) -#' -#' shinyApp( -#' ui = f7Page( -#' title = "Align", -#' f7SingleLayout( -#' navbar = f7Navbar(title = "f7Flex"), -#' f7Flex( -#' f7Block(strong = TRUE), -#' f7Block(strong = TRUE), -#' f7Block(strong = TRUE) -#' ) -#' ) -#' ), -#' server = function(input, output) {} -#' ) -#' } -#' #' @author David Granjon, \email{dgranjon@@ymail.com} #' #' @export +#' @keywords internal f7Flex <- function(...) { + lifecycle::deprecate_warn("1.1.0", "f7Row()", "f7Grid()") shiny::tags$div( class = "display-flex justify-content-space-between align-items-flex-start", ... ) } - - - - - -# #' Allow to resize a row or column -# #' -# #' Use with \link{f7Row} and/or \link{f7Col}. -# #' -# #' @param tag Tag to resize. -# #' @param fixed Whether to fix the element size. FALSE by default. -# #' @param minWidth Tag minimum width when resizing. Default to 100px. Ignored -# #' if the tag is a row. -# #' @param minHeight Tag minimum height when resizing. Default to 100px. Ignored -# #' if the tag is a col. -# #' @export -# #' @examples -# #' if (interactive()) { -# #' library(shiny) -# #' library(shinyMobile) -# #' -# #' shiny::shinyApp( -# #' ui = f7Page( -# #' title = "Grid", -# #' f7SingleLayout( -# #' navbar = f7Navbar(title = "f7Row, f7Col"), -# #' f7Row( -# #' f7Col( -# #' f7Card( -# #' "This is a simple card with plain text, -# #' but cards can also contain their own header, -# #' footer, list view, image, or any other element." -# #' ) -# #' ) %>% f7Resize(), -# #' f7Col( -# #' f7Row( -# #' f7Col( -# #' f7Card( -# #' "This is a simple card with plain text, -# #' but cards can also contain their own header, -# #' footer, list view, image, or any other element." -# #' ) -# #' ) -# #' ) %>% f7Resize(), -# #' f7Row( -# #' f7Col( -# #' f7Card( -# #' "This is a simple card with plain text, -# #' but cards can also contain their own header, -# #' footer, list view, image, or any other element." -# #' ) -# #' ) -# #' ) %>% f7Resize() -# #' ) %>% f7Resize(), -# #' f7Col( -# #' f7Card( -# #' title = "Card header", -# #' "This is a simple card with plain text, -# #' but cards can also contain their own header, -# #' footer, list view, image, or any other element.", -# #' footer = tagList( -# #' f7Button(color = "blue", label = "My button"), -# #' f7Badge("Badge", color = "green") -# #' ) -# #' ) -# #' ) %>% f7Resize() -# #' ) %>% f7Resize() -# #' ) -# #' ), -# #' server = function(input, output) {} -# #' ) -# #' -# #' } -# f7Resize <- function(tag, fixed = FALSE, minWidth = "100px", minHeight = "100px") { -# -# resizeCl <- if (fixed) "resizable-fixed" else "resizable" -# -# style <- switch(tag$attribs$class, -# "row" = paste0("min-height: ", minWidth), -# "col" = paste0("min-width: ", minWidth) -# ) -# tag %>% shiny::tagAppendAttributes(class = resizeCl, style = style) %>% -# shiny::tagAppendChild(shiny::tags$span(class = "resize-handler")) -# -# } -# diff --git a/inst/examples/dialog/app.R b/inst/examples/dialog/app.R new file mode 100644 index 00000000..225713a6 --- /dev/null +++ b/inst/examples/dialog/app.R @@ -0,0 +1,76 @@ +library(shiny) +library(shinyMobile) + +app <- shinyApp( + ui = f7Page( + title = "Dialogs", + f7SingleLayout( + navbar = f7Navbar(title = "f7Dialog"), + f7Block( + f7Grid( + cols = 4, + f7Button(inputId = "alert", "Alert"), + f7Button(inputId = "confirm", "Confirm"), + f7Button(inputId = "prompt", "Prompt"), + f7Button(inputId = "login", "Login") + ), + f7Grid( + cols = 2, + uiOutput("prompt_res"), + uiOutput("login_res") + ) + ) + ) + ), + server = function(input, output, session) { + observeEvent(input$alert, { + f7Dialog( + title = "Dialog title", + text = "This is an alert dialog" + ) + }) + + observeEvent(input$confirm, { + f7Dialog( + id = "comfirm_dialog", + title = "Dialog title", + type = "confirm", + text = "This is an alert dialog" + ) + }) + + observeEvent(input$comfirm_dialog, { + f7Toast(text = paste("Alert input is:", input$comfirm_dialog)) + }) + + observeEvent(input$prompt, { + f7Dialog( + id = "prompt_dialog", + title = "Dialog title", + type = "prompt", + text = "This is a prompt dialog" + ) + }) + output$prompt_res <- renderText({ + req(input$prompt_dialog) + input$prompt_dialog + }) + + observeEvent(input$login, { + f7Dialog( + id = "login_dialog", + title = "Dialog title", + type = "login", + text = "This is an login dialog" + ) + }) + + output$login_res <- renderUI({ + req(input$login_dialog$user, input$login_dialog$password) + img(src = "https://media2.giphy.com/media/12gfL8Xxrhv7C1fXiV/giphy.gif") + }) + } +) + +app +# if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app diff --git a/man/f7Col.Rd b/man/f7Col.Rd index 46d9534c..79be23e2 100644 --- a/man/f7Col.Rd +++ b/man/f7Col.Rd @@ -11,7 +11,8 @@ f7Col(...) on the number of columns.} } \description{ -Build a Framework7 column container +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +\link{f7Grid} is a replacement } \note{ The dark theme does not work for items embedded in a column. Use \link{f7Flex} @@ -20,3 +21,4 @@ instead. \author{ David Granjon, \email{dgranjon@ymail.com} } +\keyword{internal} diff --git a/man/f7Dialog.Rd b/man/f7Dialog.Rd index 5de857a6..7da1bef9 100644 --- a/man/f7Dialog.Rd +++ b/man/f7Dialog.Rd @@ -28,124 +28,80 @@ f7Dialog( \code{f7Dialog} generates a modal window. } \examples{ -# simple alert -if (interactive()) { - library(shiny) - library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Simple Dialog", - f7SingleLayout( - navbar = f7Navbar(title = "f7Dialog"), - f7Button(inputId = "goButton", "Go!") - ) - ), - server = function(input, output, session) { - observeEvent(input$goButton,{ - f7Dialog( - title = "Dialog title", - text = "This is an alert dialog" - ) - }) - } - ) -} -# confirm alert -if (interactive()) { - library(shiny) - library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Confirm Dialog", - f7SingleLayout( - navbar = f7Navbar(title = "f7Dialog"), - f7Button(inputId = "goButton", "Go!") - ) - ), - server = function(input, output, session) { - - observeEvent(input$goButton,{ - f7Dialog( - id = "test", - title = "Dialog title", - type = "confirm", - text = "This is an alert dialog" - ) - }) +library(shiny) +library(shinyMobile) - observeEvent(input$test, { - f7Toast(text = paste("Alert input is:", input$test)) - }) - - } - ) -} -# prompt dialog -if (interactive()) { - library(shiny) - library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Prompt Dialog", - f7SingleLayout( - navbar = f7Navbar(title = "f7Dialog"), - f7Button(inputId = "goButton", "Go!"), - uiOutput("res") - ) - ), - server = function(input, output, session) { - - observe({ - print(input$prompt) - }) +app <- shinyApp( + ui = f7Page( + title = "Dialogs", + f7SingleLayout( + navbar = f7Navbar(title = "f7Dialog"), + f7Block( + f7Grid( + cols = 4, + f7Button(inputId = "alert", "Alert"), + f7Button(inputId = "confirm", "Confirm"), + f7Button(inputId = "prompt", "Prompt"), + f7Button(inputId = "login", "Login") + ), + f7Grid( + cols = 2, + uiOutput("prompt_res"), + uiOutput("login_res") + ) + ) + ) + ), + server = function(input, output, session) { + observeEvent(input$alert, { + f7Dialog( + title = "Dialog title", + text = "This is an alert dialog" + ) + }) - observeEvent(input$goButton,{ - f7Dialog( - id = "prompt", - title = "Dialog title", - type = "prompt", - text = "This is a prompt dialog" - ) - }) + observeEvent(input$confirm, { + f7Dialog( + id = "comfirm_dialog", + title = "Dialog title", + type = "confirm", + text = "This is an alert dialog" + ) + }) - output$res <- renderUI(f7BlockTitle(title = input$prompt, size = "large")) - } - ) -} + observeEvent(input$comfirm_dialog, { + f7Toast(text = paste("Alert input is:", input$comfirm_dialog)) + }) -# login dialog -if (interactive()) { - library(shiny) - library(shinyMobile) - shinyApp( - ui = f7Page( - title = "Login Dialog", - f7SingleLayout( - navbar = f7Navbar(title = "f7Dialog"), - f7Button(inputId = "goButton", "Go!"), - uiOutput("ui") - ) - ), - server = function(input, output, session) { + observeEvent(input$prompt, { + f7Dialog( + id = "prompt_dialog", + title = "Dialog title", + type = "prompt", + text = "This is a prompt dialog" + ) + }) + output$prompt_res <- renderText({ + req(input$prompt_dialog) + input$prompt_dialog + }) - observe({ - print(input$login) - }) + observeEvent(input$login, { + f7Dialog( + id = "login_dialog", + title = "Dialog title", + type = "login", + text = "This is an login dialog" + ) + }) - observeEvent(input$goButton,{ - f7Dialog( - id = "login", - title = "Dialog title", - type = "login", - text = "This is an login dialog" - ) - }) + output$login_res <- renderUI({ + req(input$login_dialog$user, input$login_dialog$password) + img(src = "https://media2.giphy.com/media/12gfL8Xxrhv7C1fXiV/giphy.gif") + }) + } +) - output$ui <- renderUI({ - req(input$login$user == "David" & input$login$password == "prout") - img(src = "https://media2.giphy.com/media/12gfL8Xxrhv7C1fXiV/giphy.gif") - }) - } - ) -} +app +# if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app } diff --git a/man/f7Flex.Rd b/man/f7Flex.Rd index ff32b614..c3461aed 100644 --- a/man/f7Flex.Rd +++ b/man/f7Flex.Rd @@ -10,30 +10,10 @@ f7Flex(...) \item{...}{Items.} } \description{ -Build a Framework7 flex container -} -\examples{ -if(interactive()){ - library(shiny) - library(shinyMobile) - - shinyApp( - ui = f7Page( - title = "Align", - f7SingleLayout( - navbar = f7Navbar(title = "f7Flex"), - f7Flex( - f7Block(strong = TRUE), - f7Block(strong = TRUE), - f7Block(strong = TRUE) - ) - ) - ), - server = function(input, output) {} - ) -} - +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +\link{f7Grid} is a replacement } \author{ David Granjon, \email{dgranjon@ymail.com} } +\keyword{internal} diff --git a/man/f7Grid.Rd b/man/f7Grid.Rd new file mode 100644 index 00000000..11d98bf1 --- /dev/null +++ b/man/f7Grid.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/f7Grid.R +\name{f7Grid} +\alias{f7Grid} +\title{Framework7 grid container} +\usage{ +f7Grid(..., cols, gap = TRUE) +} +\arguments{ +\item{...}{Row content.} + +\item{cols}{Columns number. Numeric between 1 and 20.} + +\item{gap}{Whether to display gap between columns. TRUE by default.} +} +\description{ +Grid container for elements +} +\author{ +David Granjon, \email{dgranjon@ymail.com} +} diff --git a/man/f7Row.Rd b/man/f7Row.Rd index f541d654..276672a1 100644 --- a/man/f7Row.Rd +++ b/man/f7Row.Rd @@ -12,46 +12,10 @@ f7Row(..., gap = TRUE) \item{gap}{Whether to display gap between columns. TRUE by default.} } \description{ -Build a Framework7 row container -} -\examples{ -if(interactive()){ - library(shiny) - library(shinyMobile) - - shinyApp( - ui = f7Page( - title = "Grid", - f7SingleLayout( - navbar = f7Navbar(title = "f7Row, f7Col"), - f7Row( - f7Col( - f7Card( - "This is a simple card with plain text, - but cards can also contain their own header, - footer, list view, image, or any other element." - ) - ), - f7Col( - f7Card( - title = "Card header", - "This is a simple card with plain text, - but cards can also contain their own header, - footer, list view, image, or any other element.", - footer = tagList( - f7Button(color = "blue", label = "My button"), - f7Badge("Badge", color = "green") - ) - ) - ) - ) - ) - ), - server = function(input, output) {} - ) -} - +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +\link{f7Grid} is a replacement } \author{ David Granjon, \email{dgranjon@ymail.com} } +\keyword{internal} diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-002_.png b/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-002_.png deleted file mode 100644 index bc00ffe1..00000000 Binary files a/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-002_.png and /dev/null differ diff --git a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png index e54cbf2f..19b49b00 100644 Binary files a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png and b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png index 972e775a..299291f5 100644 Binary files a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png and b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png differ diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkbox-app-001.json b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-001.json similarity index 100% rename from tests/testthat/_snaps/mac-4.3/checkbox/checkbox-app-001.json rename to tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-001.json diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkbox-app-001_.png b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-001_.png similarity index 100% rename from tests/testthat/_snaps/mac-4.3/checkbox/checkbox-app-001_.png rename to tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-001_.png diff --git a/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002.json b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002.json new file mode 100644 index 00000000..92a1d0d8 --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002.json @@ -0,0 +1,5 @@ +{ + "input": { + "checkbox": true + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.new.png b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.new.png new file mode 100644 index 00000000..ebbeac37 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.new.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.png b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.png new file mode 100644 index 00000000..4c52f9ca Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkbox-app-002_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-001.json b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-001.json similarity index 100% rename from tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-001.json rename to tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-001.json diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-001_.png b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-001_.png similarity index 100% rename from tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-001_.png rename to tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-001_.png diff --git a/tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-002.json b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-002.json similarity index 100% rename from tests/testthat/_snaps/mac-4.3/checkbox/checkboxgroup-app-002.json rename to tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-002.json diff --git a/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-002_.png b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-002_.png new file mode 100644 index 00000000..7888fd91 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Checkbox/checkboxgroup-app-002_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001.json new file mode 100644 index 00000000..083d6778 --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001.json @@ -0,0 +1,5 @@ +{ + "input": { + + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001_.png new file mode 100644 index 00000000..3c173920 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-001_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002.json new file mode 100644 index 00000000..083d6778 --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002.json @@ -0,0 +1,5 @@ +{ + "input": { + + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002_.png new file mode 100644 index 00000000..0a454c25 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-002_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003.json new file mode 100644 index 00000000..1e0d195c --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003.json @@ -0,0 +1,5 @@ +{ + "input": { + "comfirm_dialog": false + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003_.png new file mode 100644 index 00000000..02fb3fd3 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-003_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004.json new file mode 100644 index 00000000..3c41effa --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004.json @@ -0,0 +1,5 @@ +{ + "input": { + "comfirm_dialog": true + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004_.png new file mode 100644 index 00000000..0dce2a98 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-004_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005.json new file mode 100644 index 00000000..cc22fbf9 --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005.json @@ -0,0 +1,6 @@ +{ + "input": { + "comfirm_dialog": true, + "prompt_dialog": "" + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005_.png new file mode 100644 index 00000000..3c173920 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-005_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006.json b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006.json new file mode 100644 index 00000000..02699e1f --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006.json @@ -0,0 +1,10 @@ +{ + "input": { + "comfirm_dialog": true, + "login_dialog": { + "user": "", + "password": "test" + }, + "prompt_dialog": "" + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006_.png b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006_.png new file mode 100644 index 00000000..3c173920 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7Dialog/dialog-app-006_.png differ diff --git a/tests/testthat/test-checkbox.R b/tests/testthat/test-f7Checkbox.R similarity index 100% rename from tests/testthat/test-checkbox.R rename to tests/testthat/test-f7Checkbox.R diff --git a/tests/testthat/test-f7Dialog.R b/tests/testthat/test-f7Dialog.R new file mode 100644 index 00000000..bfd9323c --- /dev/null +++ b/tests/testthat/test-f7Dialog.R @@ -0,0 +1,69 @@ +library(shinytest2) + +test_that("dialog R function", { + session <- as.environment(list( + ns = identity, + sendCustomMessage = function(type, message) { + session$lastCustomMessage <- list(type = type, message = message) + } + )) + + f7Dialog( + title = "Dialog title", + text = "This is an alert dialog", + session = session + ) + + res <- session$lastCustomMessage + res$message <- jsonlite::fromJSON(res$message) + expect_length(res, 2) + expect_equal(res$type, "dialog") + expect_length(res$message, 3) + expect_identical(res$message$title, "Dialog title") + expect_identical(res$message$text, "This is an alert dialog") + expect_identical(res$message$type, "alert") +}) + +test_that("dialog works as expected", { + # Don't run these tests on the CRAN build servers + skip_on_cran() + shiny_app_path <- + system.file("examples/dialog/app.R", package = "shinyMobile") + app <- AppDriver$new( + shiny_app_path, + name = "dialog-app", + variant = platform_variant() + ) + + inputs <- c("comfirm_dialog", "prompt_dialog", "login_dialog") + + app$expect_values(input = inputs) + app$click(selector = "#alert") + app$wait_for_idle(2000) + app$expect_values(input = inputs) + app$click(selector = ".dialog-button") + app$wait_for_idle(2000) + + app$click(selector = "#confirm") + app$click(selector = ".dialog-button:nth-child(1)") + app$wait_for_idle(2000) + app$expect_values(input = inputs) + + app$click(selector = "#confirm") + app$click(selector = ".dialog-button:nth-child(2)") + app$wait_for_idle(2000) + app$expect_values(input = inputs) + + app$click(selector = "#prompt") + app$run_js("$('.dialog-input').val('test');") + app$click(selector = ".dialog-button:nth-child(2)") + app$wait_for_idle(2000) + app$expect_values(input = inputs) + + app$click(selector = "#login") + app$run_js("$('.dialog-input[name=\"dialog-username\"]').val('test');") + app$run_js("$('.dialog-input[name=\"dialog-password\"]').val('test');") + app$click(selector = ".dialog-button:nth-child(2)") + app$wait_for_idle(2000) + app$expect_values(input = inputs) +}) diff --git a/tests/testthat/test-f7Grid.R b/tests/testthat/test-f7Grid.R new file mode 100644 index 00000000..211d1fd3 --- /dev/null +++ b/tests/testthat/test-f7Grid.R @@ -0,0 +1,8 @@ +test_that("grid works", { + grid <- f7Grid(cols = 2) + expect_s3_class(grid, "shiny.tag") + expect_identical(grid$attribs$class, "grid grid-cols-2 grid-gap") + + grid <- f7Grid(cols = 2, gap = FALSE) + expect_identical(grid$attribs$class, "grid grid-cols-2") +})