Skip to content

Commit

Permalink
Merge branch 'f7-v8.3.2' of github.com:RinteRface/shinyMobile into f7…
Browse files Browse the repository at this point in the history
…-v8.3.2
  • Loading branch information
DivadNojnarg committed Apr 29, 2024
2 parents d2f36ad + f8ead32 commit 43f33a1
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/f7Button.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' @param active Button active state. Default to FALSE. This is useful when
#' used in \link{f7Segment} with the strong parameter set to TRUE.
#' @param tonal Button tonal style. Default to FALSE
#' @param icon Button icon. Expect link{f7Icon}.
#' @param icon Button icon. Expect \link{f7Icon}.
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
Expand Down
8 changes: 8 additions & 0 deletions R/update-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
#'
#' @export
updateF7App <- function(options, session = shiny::getDefaultReactiveDomain()) {

# if color in options, convert color to hex
if (!is.null(options$color)) {
if (options$color %in% getF7Colors()) {
options$color <- colorToHex(options$color)
}
}

sendCustomMessage("update-app", options, session)
}

Expand Down
47 changes: 46 additions & 1 deletion inst/examples/gallery/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,24 @@ shinyApp(
f7Panel(
title = "Right Panel",
side = "right",
"Blabla",
f7Radio(
inputId = "theme",
label = "Theme",
choices = c("md", "ios"),
selected = "md"
),
f7Radio(
inputId = "dark",
label = "Mode",
choices = c("dark", "light"),
selected = "dark"
),
f7Radio(
inputId = "color",
label = "Color",
choices = getF7Colors(),
selected = "primary"
),
effect = "floating",
options = list(swipe = TRUE)
)
Expand Down Expand Up @@ -124,6 +141,34 @@ shinyApp(
)
),
server = function(input, output, session) {

# update theme
observeEvent(input$theme, ignoreInit = TRUE, {
updateF7App(
options = list(
theme = input$theme
)
)
})

# update mode
observeEvent(input$dark, ignoreInit = TRUE, {
updateF7App(
options = list(
dark = ifelse(input$dark == "dark", TRUE, FALSE)
)
)
})

# update color
observeEvent(input$color, ignoreInit = TRUE, {
updateF7App(
options = list(
color = input$color
)
)
})

# input validation
observe({
validateF7Input(inputId = "text", info = "Whatever")
Expand Down
3 changes: 2 additions & 1 deletion inst/examples/update_app/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ app <- shinyApp(
server = function(input, output, session) {
observeEvent(input$goButton, {
f7Dialog(
id = "test2",
title = "Dialog title",
text = "This is an alert dialog"
text = "This is an alert dialog",
type = "confirm"
)
})
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyMobile-2.0.0/dist/shinyMobile.min.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/shinyMobile-2.0.0/dist/shinyMobile.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/shinyMobile-2.0.0/dist/shinyMobile.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion man/button.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/updateF7App.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions srcjs/handlers/updateApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $(function() {
app.setColorTheme(message.color);
}

// Note that app.setDarkMode does not work in tab layout
// That's why we need to manually add/remove dark/light class
if (message.hasOwnProperty("dark")) {
if (message.dark) {
$("html").addClass("dark");
Expand All @@ -36,11 +38,6 @@ $(function() {
}
}

// Remove color, dark and theme params from message
delete message.color;
delete message.dark;
delete message.theme;

// Merge new config to existing one
app.utils.extend(app.params, message);
});
Expand Down
5 changes: 3 additions & 2 deletions vignettes/update-app.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ shinyApp(
}
)
```
TODO: shinylive example

Note that the given `color` should be a valid hexadecimal color. You can call `updateF7App` multiple times, and the app will update the given configuration settings accordingly.
Note that the color can both be a color of `getF7Colors()` (like "primary", "pink" or "teal") or a hexadecimal color. You can call `updateF7App` multiple times, and the app will update the given configuration settings accordingly.

TODO: shinylive example

### Updating component configuration

Expand Down

0 comments on commit 43f33a1

Please sign in to comment.