Skip to content

Commit

Permalink
strava app: start add sample new manual activity
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Apr 25, 2024
1 parent 188d47f commit 9da3517
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 35 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/strava/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
131 changes: 97 additions & 34 deletions inst/examples/strava/pages/home_page.R
Original file line number Diff line number Diff line change
@@ -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 = "/",
Expand All @@ -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(
Expand All @@ -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]]
)
)
}
Expand Down

0 comments on commit 9da3517

Please sign in to comment.