Anchored Layout Plugin
The Anchored Layout plugin allows you to create simple layouts that consist of a main content view and optional views that can be anchored to the top or bottom.
Anchored Layout is limited to adding views vertically - there is currently no support for adding views horizontally. If this is a feature you'd like, please let us know in our Astro Community Slack!
Sample Usage
const mainWebView = await WebViewPlugin.init()
const bottomWebView = await WebViewPlugin.init()
const layout = await AnchoredLayoutPlugin.init()
mainWebView.navigate('http://icanhas.cheezburger.com')
bottomWebView.navigate('http://www2.warnerbros.com/spacejam/movie/jam.htm')
layout.setContentView(mainWebView)
layout.addBottomView(bottomWebView, { height: 256 })
Application.setMainViewPlugin(layout)
Methods
AnchoredLayoutPlugin.init(options)
#
Creates and returns an instance of the anchored layout plugin that is used to make subsequent method calls.
- options: an optional dictionary that may include:
- anchorToLayoutGuides: (iOS only) a boolean that indicates whether the anchored layout's child views should be anchored against the layout guides or directly against the superview edges. More info here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instp/UIViewController/topLayoutGuide
Note: In Android, an empty view is set as the anchored layout's content view on initialization as a placeholder.
setContentView(plugin)
#
Sets a plugin's view as the layout's main content view.
- plugin: the plugin with the view to set as the main content view
addTopView(plugin, options)
#
Anchors a plugin's view to the top of the layout. You should use this without the height option if the view you're anchoring has a natural height, otherwise you should explicitly specify the height of the anchored view with the height option.
- plugin: the plugin with the view to anchor to the top
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
- height: the height of the anchored view in dips
- visible: a boolean to indicate whether or not the view should be visible.
addBottomView(plugin, options)
#
Anchors a plugin's view to the bottom of the layout. You should use this without the height option if the view you're anchoring has a natural height, otherwise you should explicitly specify the height of the anchored view with the height option.
- plugin: the plugin with the view to anchor to the bottom
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
- height: the height of the anchored view in dips
- visible: a boolean to indicate whether or not the view should be visible.
showView(plugin, options)
#
Shows the given plugin's view. Note that you must have previously added the
plugin to this layout's top or bottom bar using addTopView
or addBottomView
.
- plugin: the plugin with the view to show
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
hideView(plugin, options)
#
Hides the given plugin's view. Note that you must have previously added the
plugin to this layout's top or bottom bar using addTopView
or addBottomView
.
- plugin: the plugin with the view to hide
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
toggleView(plugin, options)
#
Toggles visibility of the given plugin's view (by delegating to showView()
and hideView()
). Note that you must have previously added the plugin to
this layout's top or bottom bar using addTopView()
or addBottomView()
.
- plugin: the plugin with the view to toggle
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
showTopViews(options)
#
Shows the top anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
hideTopViews(options)
#
Hides the top anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
showBottomViews(options)
#
Shows the bottom anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
hideBottomViews(options)
#
Hides the bottom anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
showAll(options)
#
Show the top and bottom anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
hideAll(options)
#
Hides the top and bottom anchored plugins.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
clearContentView()
#
Clears the layout's main content view. This only removes the view from the layout's view hierarchy and does not destroy it.
clearTopViews(options)
#
Clears the top anchored views from the layout. This only removes the views from the layout's view hierarchy and does not destroy them.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.
clearBottomViews(options)
#
Clears the bottom anchored views from the layout. This only removes the views from the layout's view hierarchy and does not destroy them.
- options: an optional dictionary that may include:
- animated: a boolean to indicate whether or not the action should be animated.
- animationDuration: the animation's duration in milliseconds, if this is not provided the default is 400 ms.