From 3dfa2273e341f890cad02e4dcf8ed609da6bfc59 Mon Sep 17 00:00:00 2001 From: Aleksander Dietrichson Date: Thu, 4 Apr 2024 03:00:16 +0000 Subject: [PATCH 1/3] fixes #257 --- R/f7Card.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/f7Card.R b/R/f7Card.R index 6e66943c..705168ec 100644 --- a/R/f7Card.R +++ b/R/f7Card.R @@ -266,7 +266,7 @@ f7SocialCard <- function(..., image = NULL, author = NULL, date = NULL, #' @export f7ExpandableCard <- function(..., id = NULL, title = NULL, subtitle = NULL, color = NULL, - image = NULL, fullBackground = FALSE) { + image = NULL, fullBackground = FALSE, height = "300px") { cardColorCl <- if (!is.null(color)) paste0("bg-color-", color) @@ -328,6 +328,7 @@ f7ExpandableCard <- function(..., id = NULL, title = NULL, # main wrapper shiny::tags$div( class = "card card-expandable", + style = paste0("height: ",height), `data-card` = paste0("#", id), id = id, shiny::tags$div( @@ -345,6 +346,7 @@ f7ExpandableCard <- function(..., id = NULL, title = NULL, } else { shiny::tags$div( class = cardColorCl, + #style = paste0("height: ",height), style = "height: 300px;", cardHeader, closeCard From 1e057109b3aa5ce5379947f359ab27d80a4e351b Mon Sep 17 00:00:00 2001 From: Aleksander Dietrichson Date: Sun, 7 Apr 2024 18:20:06 +0000 Subject: [PATCH 2/3] Override of f7Popup --- R/f7PopupKai.R | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ man/f7Popup2.Rd | 98 +++++++++++++++++++++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 R/f7PopupKai.R create mode 100644 man/f7Popup2.Rd diff --git a/R/f7PopupKai.R b/R/f7PopupKai.R new file mode 100644 index 00000000..530448a2 --- /dev/null +++ b/R/f7PopupKai.R @@ -0,0 +1,125 @@ +#' Framework7 popup +#' +#' \code{f7Popup} creates a popup window with any UI content that pops up over App's main content. +#' Popup as all other overlays is part of so called "Temporary Views". +#' +#' @param ... UI elements for the body of the popup window. +#' @param id Popup unique id. Useful if you want to access the popup state. +#' input$ is TRUE when the popup is opened and inversely. +#' @param title Title for the popup window, use \code{NULL} for no title. +#' @param backdrop Enables Popup backdrop (dark semi transparent layer behind). +#' Default to \code{TRUE}. +#' @param closeByBackdropClick When enabled, popup will be closed on backdrop click. +#' Default to \code{TRUE}. +#' @param closeOnEscape When enabled, popup will be closed on ESC keyboard key press. +#' Default to \code{FALSE}. +#' @param animate Whether the Popup should be opened/closed with animation or not. +#' Default to \code{TRUE}. +#' @param swipeToClose Whether the Popup can be closed with swipe gesture. +#' Can be true to allow to close popup with swipes to top and to bottom. +#' Default to \code{FALSE}. +#' @param fullsize Open popup in full width or not. Default to \code{FALSE}. +#' @param closeButton Add or not a button to easily close the popup. +#' Default to \code{TRUE}. +#' @param session Shiny session object. +#' +#' @export +#' +#' @examples +#' if (interactive()) { +#' library(shiny) +#' library(shinyMobile) +#' shinyApp( +#' ui = f7Page( +#' title = "Popup", +#' f7SingleLayout( +#' navbar = f7Navbar( +#' title = "f7Popup", +#' hairline = FALSE, +#' shadow = TRUE +#' ), +#' f7Button("togglePopup", "Toggle Popup") +#' ) +#' ), +#' server = function(input, output, session) { +#' +#' output$popupContent <- renderPrint(input$text) +#' +#' observeEvent(input$togglePopup, { +#' f7Popup( +#' id = "popup1", +#' title = "My first popup", +#' f7Text("text", "Popup content", "This is my first popup ever, I swear!"), +#' verbatimTextOutput("popupContent") +#' ) +#' }) +#' +#' observeEvent(input$popup1, { +#' +#' popupStatus <- if (input$popup1) "opened" else "closed" +#' +#' f7Toast( +#' position = "top", +#' text = paste("Popup is", popupStatus) +#' ) +#' }) +#' } +#' ) +#' } +f7Popup2 <- function(..., id, title = NULL, + backdrop = TRUE, + closeByBackdropClick = TRUE, + closeOnEscape = FALSE, + animate = TRUE, + swipeToClose = FALSE, + fullsize = FALSE, + closeButton = TRUE, + closeButtonIcon = f7Icon("arrow_left"), + session = shiny::getDefaultReactiveDomain()) { + + message <- dropNulls( + list( + id = session$ns(id), + backdrop = backdrop, + closeByBackdropClick = closeByBackdropClick, + closeOnEscape = closeOnEscape, + animate = animate, + swipeToClose = swipeToClose + ) + ) + + content <- shiny::tags$div( + class = "block", + if (!is.null(title)) shiny::tags$div(class = "block-title", title), + ... + ) + + if (closeButton) { + content <- htmltools::tagAppendChild( + content, + shiny::tags$a( + class = "link popup-close", + style = "position: absolute; top: -15px; left: 10px;", + href = "#", + closeButtonIcon + ) + ) + } + + popup_tag <- shiny::tags$div( + class = paste0("popup", if (fullsize) "popup-tablet-fullscreen"), + content + ) + + message$content <- as.character(popup_tag) + + # see my-app.js function + session$sendCustomMessage( + type = "popup", + message = jsonlite::toJSON( + message, + auto_unbox = TRUE, + json_verbatim = TRUE + ) + ) +} diff --git a/man/f7Popup2.Rd b/man/f7Popup2.Rd new file mode 100644 index 00000000..353ea32d --- /dev/null +++ b/man/f7Popup2.Rd @@ -0,0 +1,98 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/f7PopupKai.R +\name{f7Popup2} +\alias{f7Popup2} +\title{Framework7 popup} +\usage{ +f7Popup2( + ..., + id, + title = NULL, + backdrop = TRUE, + closeByBackdropClick = TRUE, + closeOnEscape = FALSE, + animate = TRUE, + swipeToClose = FALSE, + fullsize = FALSE, + closeButton = TRUE, + closeButtonIcon = Iconf7Icon("multiply"), + session = shiny::getDefaultReactiveDomain() +) +} +\arguments{ +\item{...}{UI elements for the body of the popup window.} + +\item{id}{Popup unique id. Useful if you want to access the popup state. +input$ is TRUE when the popup is opened and inversely.} + +\item{title}{Title for the popup window, use \code{NULL} for no title.} + +\item{backdrop}{Enables Popup backdrop (dark semi transparent layer behind). +Default to \code{TRUE}.} + +\item{closeByBackdropClick}{When enabled, popup will be closed on backdrop click. +Default to \code{TRUE}.} + +\item{closeOnEscape}{When enabled, popup will be closed on ESC keyboard key press. +Default to \code{FALSE}.} + +\item{animate}{Whether the Popup should be opened/closed with animation or not. +Default to \code{TRUE}.} + +\item{swipeToClose}{Whether the Popup can be closed with swipe gesture. +Can be true to allow to close popup with swipes to top and to bottom. +Default to \code{FALSE}.} + +\item{fullsize}{Open popup in full width or not. Default to \code{FALSE}.} + +\item{closeButton}{Add or not a button to easily close the popup. +Default to \code{TRUE}.} + +\item{session}{Shiny session object.} +} +\description{ +\code{f7Popup} creates a popup window with any UI content that pops up over App's main content. +Popup as all other overlays is part of so called "Temporary Views". +} +\examples{ +if (interactive()) { + library(shiny) + library(shinyMobile) + shinyApp( + ui = f7Page( + title = "Popup", + f7SingleLayout( + navbar = f7Navbar( + title = "f7Popup", + hairline = FALSE, + shadow = TRUE + ), + f7Button("togglePopup", "Toggle Popup") + ) + ), + server = function(input, output, session) { + + output$popupContent <- renderPrint(input$text) + + observeEvent(input$togglePopup, { + f7Popup( + id = "popup1", + title = "My first popup", + f7Text("text", "Popup content", "This is my first popup ever, I swear!"), + verbatimTextOutput("popupContent") + ) + }) + + observeEvent(input$popup1, { + + popupStatus <- if (input$popup1) "opened" else "closed" + + f7Toast( + position = "top", + text = paste("Popup is", popupStatus) + ) + }) + } + ) +} +} From ade6ef573d531e6643a54b22eb13dc281637cb72 Mon Sep 17 00:00:00 2001 From: Aleksander Dietrichson Date: Sun, 7 Apr 2024 18:51:19 +0000 Subject: [PATCH 3/3] trying to re-fix this... --- .Rbuildignore | 3 ++ .gitignore | 3 ++ DESCRIPTION | 2 +- NAMESPACE | 1 + R/f7Popup2.R | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ man/card.Rd | 3 +- man/f7Popup2.Rd | 21 ++++++++++++-- 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 R/f7Popup2.R diff --git a/.Rbuildignore b/.Rbuildignore index 48ac0ed5..5980245b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,6 @@ ^tools$ ^index\.Rmd$ ^CRAN-SUBMISSION$ +^shinyMobile\.Rcheck$ +^shinyMobile.*\.tar\.gz$ +^shinyMobile.*\.tgz$ diff --git a/.gitignore b/.gitignore index b31bb79a..c9ece6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ inst/examples/chat_widget docs inst/examples/chat_widget inst/tests/** +shinyMobile.Rcheck/ +shinyMobile*.tar.gz +shinyMobile*.tgz diff --git a/DESCRIPTION b/DESCRIPTION index 8202ea07..cfaea545 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ License: GPL-2 Encoding: UTF-8 URL: https://github.com/RinteRface/shinyMobile, https://rinterface.github.io/shinyMobile/ BugReports: https://github.com/RinteRface/shinyMobile/issues -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: knitr, rmarkdown, diff --git a/NAMESPACE b/NAMESPACE index 1624fcce..64b25bf8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -76,6 +76,7 @@ export(f7Picker) export(f7Popover) export(f7PopoverTarget) export(f7Popup) +export(f7Popup2) export(f7Progress) export(f7Radio) export(f7RemoveTab) diff --git a/R/f7Popup2.R b/R/f7Popup2.R new file mode 100644 index 00000000..fdc859ae --- /dev/null +++ b/R/f7Popup2.R @@ -0,0 +1,75 @@ +#' Title +#' +#' @param ... +#' @param id +#' @param title +#' @param backdrop +#' @param closeByBackdropClick +#' @param closeOnEscape +#' @param animate +#' @param swipeToClose +#' @param fullsize +#' @param closeButton +#' @param session +#' +#' @return +#' @export +#' +#' @examples +f7Popup2 <- function(..., id, title = NULL, + backdrop = TRUE, + closeByBackdropClick = TRUE, + closeOnEscape = FALSE, + animate = TRUE, + swipeToClose = FALSE, + fullsize = FALSE, + closeButton = TRUE, + session = shiny::getDefaultReactiveDomain()) { + + message <- dropNulls( + list( + id = session$ns(id), + backdrop = backdrop, + closeByBackdropClick = closeByBackdropClick, + closeOnEscape = closeOnEscape, + animate = animate, + swipeToClose = swipeToClose + ) + ) + + content <- shiny::tags$div( + class = "block", + if (!is.null(title)) shiny::tags$div(class = "block-title", title), + ... + ) + + if (closeButton) { + content <- htmltools::tagAppendChild( + content, + shiny::tags$a( + class = "link popup-close", + style = "position: absolute; top: -15px; left: 10px;", + href = "#", + #f7Icon("multiply") + f7Icon("arrow_left") + ) + ) + } + + popup_tag <- shiny::tags$div( + class = paste0("popup", if (fullsize) "popup-tablet-fullscreen"), + content + ) + + message$content <- as.character(popup_tag) + + # see my-app.js function + session$sendCustomMessage( + type = "popup", + message = jsonlite::toJSON( + message, + auto_unbox = TRUE, + json_verbatim = TRUE + ) + ) +} diff --git a/man/card.Rd b/man/card.Rd index 63a39516..7c8252a9 100644 --- a/man/card.Rd +++ b/man/card.Rd @@ -25,7 +25,8 @@ f7ExpandableCard( subtitle = NULL, color = NULL, image = NULL, - fullBackground = FALSE + fullBackground = FALSE, + height = "300px" ) updateF7Card(id, session = shiny::getDefaultReactiveDomain()) diff --git a/man/f7Popup2.Rd b/man/f7Popup2.Rd index 353ea32d..2cbe32d3 100644 --- a/man/f7Popup2.Rd +++ b/man/f7Popup2.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/f7PopupKai.R +% Please edit documentation in R/f7Popup2.R, R/f7PopupKai.R \name{f7Popup2} \alias{f7Popup2} -\title{Framework7 popup} +\title{Title} \usage{ f7Popup2( ..., @@ -15,7 +15,22 @@ f7Popup2( swipeToClose = FALSE, fullsize = FALSE, closeButton = TRUE, - closeButtonIcon = Iconf7Icon("multiply"), + closeButtonIcon = f7Icon("arrow_left"), + session = shiny::getDefaultReactiveDomain() +) + +f7Popup2( + ..., + id, + title = NULL, + backdrop = TRUE, + closeByBackdropClick = TRUE, + closeOnEscape = FALSE, + animate = TRUE, + swipeToClose = FALSE, + fullsize = FALSE, + closeButton = TRUE, + closeButtonIcon = f7Icon("arrow_left"), session = shiny::getDefaultReactiveDomain() ) }