diff --git a/NEWS.md b/NEWS.md index 5415550b..762daa80 100644 --- a/NEWS.md +++ b/NEWS.md @@ -86,6 +86,7 @@ the new router layout. Items must be wrapped in a `shiny::tagList()`. - New `f7DefaultOptions()`: can be used in `f7Page()` to pass app options. - `f7Picker`, `f7DatePicker` and `f7ColorPicker` now have an additional `style` parameter to set the input style and inherit from `f7List` options such as outline, inset, strong and dividers. - `f7Toggle()` and `f7Stepper()` automatically detect when they are called inside a `f7List` and adjust accordingly to the list style. +- `f7TabLink()`: `href` can now be different of `#` if passed in `...` (Default is still `#` when no custom `href` is detected). This allows to use tab links as routable links but with a better rendering in the toolbar/tabbar than classic `f7Link()`. - Fix various issues in documentation. # shinyMobile 1.0.1 diff --git a/inst/examples/strava/app.R b/inst/examples/strava/app.R index dc13c749..d0d5a108 100644 --- a/inst/examples/strava/app.R +++ b/inst/examples/strava/app.R @@ -27,7 +27,7 @@ brochureApp( # That's not what we want here so we'll have # a global server function. server = function(input, output, session) { - + add_post("new") }, wrapped = f7MultiLayout, wrapped_options = list( diff --git a/inst/examples/strava/pages/home_page.R b/inst/examples/strava/pages/home_page.R index 6e06f401..b43c1b58 100644 --- a/inst/examples/strava/pages/home_page.R +++ b/inst/examples/strava/pages/home_page.R @@ -1,3 +1,98 @@ +add_post_ui <- function(id) { + ns <- shiny::NS(id) + tagList( + tags$a( + href = "#", + class = "link sheet-open", + f7Icon("splus_circle"), + `data-sheet` = sprintf("#%s", ns("sheet")) + ), + f7Sheet( + id = ns("sheet"), + orientation = "top", + swipeHandler = FALSE, + f7Segment( + tags$a( + href = "#", + class = "link sheet-open", + f7Icon("text_alignleft"), + `data-sheet` = "#post", + "Post" + ), + tags$a( + href = "#", + class = "link sheet-open", + f7Icon("photo"), + `data-sheet` = "#photo-post", + "Photos" + ), + tagAppendAttributes( + f7Link( + href = "#", + icon = f7Icon("pencil"), + label = "Manual" + ), + id = ns("manual_post"), + class = "action-button" + ) + ) + ) + ) +} + +add_post <- function(id) { + moduleServer( + id, + function(input, output, session) { + ns <- session$ns + + observeEvent(input$manual_post, { + # Close sheet + updateF7Sheet("sheet") + # Open popup + f7Popup( + id = "manual_pos_popup", + title = "Add Activity", + f7Text( + inputId = ns("activity_name"), + label = "Name", + placeholder = "My activity", + style = list( + media = NULL, + description = NULL, + floating = FALSE, + outline = TRUE, + clearable = TRUE + ) + ), + f7TextArea( + inputId = ns("activity_descr"), + label = "Description", + placeholder = "How'd it go? Share more + about your activity and use @ to tag someone.", + style = list( + media = NULL, + description = NULL, + floating = FALSE, + outline = TRUE, + clearable = TRUE + ) + ), + f7Select( + inputId = ns("activity_type"), + "Type", + choices = c("Walk", "Ride") + ) + ) + }) + + observe({ + print(input$activity_type) + }) + } + ) +} + home_page <- function() { page( href = "/", @@ -8,12 +103,7 @@ home_page <- function() { f7Navbar( title = "Home", leftPanel = tagList( - tags$a( - href = "#", - class = "link sheet-open", - f7Icon("splus_circle"), - `data-sheet` = "#new" - ), + add_post_ui("new")[[1]], f7Link(icon = f7Icon("search"), href = "#") ), rightPanel = tagList( @@ -27,34 +117,7 @@ home_page <- function() { ), tags$div( class = "page-content", - f7Sheet( - id = "new", - orientation = "top", - swipeHandler = FALSE, - f7Segment( - tags$a( - href = "#", - class = "link sheet-open", - f7Icon("text_alignleft"), - `data-sheet` = "#post", - "Post" - ), - tags$a( - href = "#", - class = "link sheet-open", - f7Icon("photo"), - `data-sheet` = "#photo-post", - "Photos" - ), - tags$a( - href = "#", - class = "link sheet-open", - f7Icon("pencil"), - `data-sheet` = "#manual-post", - "Manual" - ) - ) - ) + add_post_ui("new")[[2]] ) ) }