This is the base view responsible for mixing in functions for focus management, keyhandling and providing the main framework. It light enough for use as a component; but not recommended for use in rowlists/grids/other aggregate views which are expected to have a large amount of items.
This view is itended to be extended by Components, which in turn are aggregates of views; but not whole screens.
isInitialized
- indicates ifinitialize
has yet been calledisShown
, true if the view is on screenname
, useful for logging
initialize
- must be called to start the view machinery
You can override these methods to safely drive your application behaviour
_applyStyle(styles, localizations, assets)
- will be called when the view is initialized, so it can apply required styles, etc_initialize(args)
- called when the view has been initialized_onFirstShow
- called the first time a view is shown_onShow
- called when a view is shown - note a view cannot be shown if it is not initialized. This method will be called immediately for a visible view, wheninitialize
is invoked_onHide
- called when a view is hidden
In addition you can override the methods in KeyMixin:
_isAnyKeyPressLocked()
- returns true if any keypress is locked - defualt impl is to return the value ofm.isKeyPressLocked
_isCapturingAnyKeyPress(key)
, return true if the keykey
is captured
Override the following, to return true, if the applicable key is captured
_onKeyPressDown()
_onKeyPressUp()
_onKeyPressLeft()
_onKeyPressRight()
_onKeyPressBack()
_onKeyPressOption()
_onKeyPressOK()
Also, BaseView allows entry points for overriding abstract methods from FocusMixin
_onGainedFocus(isSelfFocused)
_onLostFocus()
Extends Baseview and adds additional awareness for selections, loading state, if the user is reloading, and contains utility and application level functions. Application functions proxy main application activity such as playing a video, or showing a screen.
content
the content that this screen loadedselection
selection object for the currently selected contentisLoading
isUserChangePending
NavController
- reference to theNavController
this screen belongs to - this is the navController that will be used forpush
,pop
, andresetNavController
getTopScreen
- can be used to ask this screen what it consider's it's top view. Useful if the screen in turn composes other screens (e.g. via nested NavControllers)push
- pushes passed in screen to the navControllerpop
- pops the current navController screenresetNavController
- resets the navController - passing in a screen or index, will reset to that screen, or back to that index- other utility functions implemented for your app
BaseScreen provides the same lifecycle methods as Baseview; but also provides
_getTopScreen
- tempalte method used bygetTopScreen
_baseScreenOnShow
- special hook used to overcome needing moreonShow
overrides (SceneGraph has a limit to super method calls)_onUserChange
- called when the user changes, so the view can update itself with the latest data
A special BaseScreen subclass, which manages showing, or hiding views. The currentView
property informs which view is currently active (i.e. the selected tab, or current view on top of a NavController)
Only one screen is ever visible at a time. A screen's lifecycle methods for focus and visibility will all be managed and can be relied upon for ascertaining the proper state of the screen.
BaseAggregateView subclass which allows you to swtich various views. The tabController will display a screen which corresponds to the currently selected item. The screen is created lazily, unless it was specified using addExistingView
menuItems
array of items, which are used to create child screens. The menuItem must have an id, which matches the view passed in withaddExistingView
, or have it's screenType set to the valid type of aBaseScreen
subclasscurrentItem
readOnly the currently selected menuItem
addExistingView
- will register the passed in view to be displayed when a menu item with the same id is set as thecurrentItem
getViewForMenuItemContent
changeCurrentItem
- will set thecurrentItem
NavController controls a stack of views stacked one up on the other. When a BaseScreen is added to a NavController it's navController
field is set to the navController. In addition the lifecycle methods onAddedToAggregateView
and onRemovedFromAggregateView
are invoked in accordance with pop
, push
and reset
numberOfViews
readonly number of Views on the stackisLastViewPopped
readonly true, if the last view is popped, can be observedisAutoFocusEnabled
if true then pushed views receive focus
push
- pushes the passed in view onto the stack, and initializes itpop
- pops current view from the stackreset
- resets the stackresetToIndex
- resests the stack to the desired index
To make develpoment easier, and remove boilerplate, a lifecycle is provided, so that all views and screens can override a few methods to get accurate access to their perceived state on screen. the lifecycle methods are invokved as follows:
_initialize
- invoked once_onFirstShow
- onvoked once_onShow
- can be invoked multiple times_onHide
- can be invoked multiple times_onUserChange
- can be invoked multiple times