Widget to implement a table pull-to-refresh header in Titanium Alloy
NOTE: Starting TiSDK 6.2 this widget is no longer needed as RefreshControl is build in for Android like previously for iOS, you can stick with the Ti.UI.RefreshControl
The Alloy Pull to Refresh widget is a cross-platform no-brainer wrapper of Ti.UI.RefreshControl for iOS and Ivan's fork of Ti.SwipeRefreshLayout for Android.
Before version 2.0.0 this widget emulated the native Pull to Refresh concept for
Ti.UI.TableViewon both platforms. Since 2.0.0 it uses the native controls now available in Titanium Core and through Ivan's module for both
Ti.UI.TableViewand
Ti.UI.ListView.
Also take a look at the Infinite Scroll widget.
Download and install the distribution 0.4.1 or later of Ivan's fork of Ti.SwipeRefreshLayout.
Install the widget via gitTio:
gittio install nl.fokkezb.pullToRefresh
`npm i --save nl.fokkezb.pulltorefresh`
Wrap the widget around your
or in the view:NOTE: The
tag can't be the root element due to an Alloy limitation!Add your
myRefresherfunction to the controller and call the
e.hide()callback when you're done:
function myRefresher(e) { myCollection.fetch({ success: e.hide, error: e.hide }); }
Call the widget's
refresh()to programmatically trigger the (initial) refresh:
$.ptr.refresh();
Ti.UI.createRefreshControland
createSwipeRefresh()simply pass them to the widget as attributes of or second arguments of
createWidget().
Both platforms share the same API:
| Function | Parameters | Usage | | ---------- | ---------- | ----- | | refresh | | Manually trigger pull + release | | show | | Show the loading indicator | | hide | | Hide the loading indicator | | getList | | Get the list the widget is bound to | getControl | | Get the refresh control
setTitle().
Ti.UI.createRefreshControl()for iOS (e.g. to set title or tintColor) and
createSwipeRefresh()for Android.
topoption for compatibility with
Ti.UI.Window.extendEdgeson iOS7
initinto
setOptionsand
attach
removeto
dettach
triggerto
refreshto not interfere with BackBone
show/
hidethe view, set the
dateand
triggerthe widget manually.
loadparameter to
loaderin line with upcomming widgets.
Copyright 2013-2015 Fokke Zandbergen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.