Unity Scopes API
|
The following widget types are recognized by Unity:
audio
video
image
gallery
header
actions
progress
text
rating-input
rating-edit
reviews
expandable
The audio widget displays a list of tracks with play/pause controls.
List of attributes:
tracks
A composite attribute containing an array of tuples, where each tuple has up to four fields: title
(mandatory string), subtitle
(optional string), source
(mandatory URI), and length
(optional integer specifying the track length in seconds)You can construct composite attributes with unity::scopes::VariantBuilder:
The video widget displays a still from a video and allows playing the video.
List of attributes:
source
A URI pointing to the video screenshot
A URI pointing to a screenshot of the video (optional)The image widget displays a single image.
List of attributes:
source
A URI pointing to the image zoomable
A boolean specifying whether the image is zoomable (default: false
) fallback
A fallback image to be used if the image URI cannot be retrieved (default: none)The gallery widget displays a set of images.
List of attributes:
sources
An array of image URIs fallback
A fallback image to be used if an image URI cannot be resolved (default: none)The header widget displays basic infomation about the result.
List of attributes:
title
A string specifying the title subtitle
A string specifying the subtitle mascot
A URI specifying the mascot fallback
A fallback image to be used if the mascot URI cannot be retrieved (default: none) emblem
A URI specifying the emblemThe actions widget displays one or more buttons.
List of attributes:
actions
A composite attribute containing an array of tuples, where each tuple has at least these fields: id
(a mandatory string that is passed to unity::scopes::ScopeBase::activate_preview_action()), label
(mandatory string), and icon
(optional URI).You can construct composite attributes with unity::scopes::VariantBuilder:
The progress widget displays the progress of an action, such as download progress.
On completion, the scope receives a preview action activation with the id "finished"
or "failed"
, depending on the outcome of the operation.
List of attributes:
source
A tuple with keys understood by a progress providerA text widget can be used for text of any length (without formatting).
List of attributes:
title
Optional string text
A string containing the textThe rating-input widget allows users to rate content. It consists of two types of widget: a star-based rating and an input field for the user to enter his/her review. It is possible to hide each widget as well as to require them to be filled in.
When a user presses the "Send" button, the scope receives a preview action activation with the id "rated"
. The actual rating and/or review can be accessed via unity::scopes::ActionMetadata::scope_data. The scope data will be a VariantMap with the following keys:
"rating"
- a double holding the number of stars the user selected (1 to 5)"review"
- a string holding the free text reviewList of attributes:
rating-label
String for the star-based rating (default: "Rate this") review-label
String for the review input (default: "Add a review") submit-label
String for the confirmation button (default: "Send") rating-icon-empty
URI for an empty rating icon rating-icon-full
URI for a full rating icon visible
String specifying which of the two widgets are visible ("rating"
, "review"
or default:"both"
) required
String specifying which of the two widgets are required to be filled in ("rating"
, "review"
or default:"both"
)The rating-edit widget allows users to edit an existing review and rating. When used in a preview, the widget displays an existing review and a small "pen" icon; user can update the review and/or rating after tapping the "pen" icon.
This widget supports all the attributes of rating-input widget, plus three extra attributes ("review"
, "rating"
, "author"
) to pre-fill the widget with data of an existing review.
List of attributes:
rating-label
String for the star-based rating (default: "Rate this") review-label
String for the review input (default: "Add a review") submit-label
String for the confirmation button (default: "Send") rating-icon-empty
URI for an empty rating icon rating-icon-full
URI for a full rating icon visible
String specifying which of the two widgets are visible ("rating"
, "review"
or default:"both"
) required
String specifying which of the two widgets are required to be filled in ("rating"
, "review"
or default:"both"
) author
String for the name of the reviewer (optional) review
String for the text of existing review (optional) rating
Number for the rating value (optional)Note: The rating-edit widget may not be supported by older versions of unity8 shell.
The reviews widget is used to display previously-rated content.
List of attributes:
rating-icon-empty
URI for an empty rating icon rating-icon-half
URI for an half-full rating icon rating-icon-full
URI for a full rating icon reviews
A composite attribute containing an array of tuples, where each tuple has up to three fields: rating
(optional integer specifying the number of stars), author
(mandatory string) and review
(optional string).You can construct composite attributes with unity::scopes::VariantBuilder:
The expandable widget is used to group several widgets into an expandable pane.
List of attributes:
title
A string specifying the title collapsed-widgets
Optional number of collapsed widgets (0 makes all of them visible)