• This repository has been archived on 10/Mar/2023
  • Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    JavaScript
  • Created about 12 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Widget to implement a table pull-to-refresh header in Titanium Alloy

Alloy Pull to Refresh Widget

gitTio NPM René Pot

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.TableView on 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.TableView and Ti.UI.ListView.

Also take a look at the Infinite Scroll widget.

Examples

Android

Android

iOS

iOS

Usage

  1. Download and install the distribution 0.4.1 or later of Ivan's fork of Ti.SwipeRefreshLayout.

  2. Install the widget via gitTio: gitTio

    gittio install nl.fokkezb.pullToRefresh

Or NPM: NPM

`npm i --save nl.fokkezb.pulltorefresh`
  1. Wrap the widget around your <ListView> or <TableView> in the view:

     <Alloy>
     	<Collection src="myCollection" />
     	<Window>
     		<Widget id="ptr" src="nl.fokkezb.pullToRefresh" onRelease="myRefresher">
     			<ListView>
     				<ListSection dataCollection="myCollection">
     					<ListItem title="{title}" />
     				</ListSection>
     			</ListView>
     		</Widget>
     	</Window>
     </Alloy>
    

    NOTE: The <Widget /> tag can't be the root element due to an Alloy limitation!

  2. Add your myRefresher function to the controller and call the e.hide() callback when you're done:

     function myRefresher(e) {
     	myCollection.fetch({
     		success: e.hide,
     		error: e.hide
     	});
     }
    
  3. Call the widget's refresh() to programmatically trigger the (initial) refresh:

     $.ptr.refresh();
    
  4. To pass arguments to Ti.UI.createRefreshControl and createSwipeRefresh() simply pass them to the widget as attributes of <Widget> or second arguments of createWidget().

Methods

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

Changelog

  • 3.0
    • Removes setTitle().
    • Passes all arguments/attributes on to Ti.UI.createRefreshControl() for iOS (e.g. to set title or tintColor) and createSwipeRefresh() for Android.
  • 2.2
  • 2.1
  • 2.0
    • Rewritten to use native API's.
  • 1.5
    • Workaround for regression in Alloy 1.3.0-cr
    • Closes #17 by checking source of events
    • New top option for compatibility with Ti.UI.Window.extendEdges on iOS7
    • Arrow now properly hidden on Android, using opacity
    • Default style updated to match Twitter on iOS7
  • 1.4
    • Now compatible with Android and other OS!
  • 1.3
    • From now on declared in the XML view instead of the controller!
    • Splitted init into setOptions and attach
    • Renamed remove to dettach
    • Renamed trigger to refresh to not interfere with BackBone
  • 1.2
    • Retina arrow images, including new (default) grey one
    • Removed text showing last update for more clear view
    • Easier styling
  • 1.1
    • Exposed new API functions to show/hide the view, set the date and trigger the widget manually.
    • Renamed load parameter to loader in line with upcomming widgets.
  • 1.0
    • Initial version

License

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.

More Repositories

1

XHR

Super awesome HTTP Client for Appcelerator Titanium :)
JavaScript
172
star
2

nl.fokkezb.infiniteScroll

Alloy widget for infinitive scrolling TableViews and ListViews
JavaScript
133
star
3

jQuery-html5-placeholder

yet another placeholder pluginâ„¢
JavaScript
123
star
4

titanium-modules

The extensive list of good Titanium Modules!
53
star
5

To.BounceView

A bouncing view widget for Titanium
JavaScript
49
star
6

To.ImageCache

A simple CommonJS module for Titanium to cache images a little less temporarily, and configurable
JavaScript
27
star
7

staballoy

Reactive UI framework for Titanium Alloy
JavaScript
18
star
8

ti.detect

A simple Titanium library which detects things for you
JavaScript
15
star
9

awesome-adventofcode

An Awesome List of AdventOfCode Participants
12
star
10

ti.chatwidget

A widget for adding chat to your Titanium app
JavaScript
9
star
11

adventofcode

JavaScript
8
star
12

KnockoutJS-i18n

A simple KnockoutJS i18n module
JavaScript
7
star
13

titanium_ios_drawer

A drawer sample app for iOS
JavaScript
4
star
14

jQuery.dataformValidate

Validate a form based on html5 data attributes.
JavaScript
4
star
15

no-profanity

A JavaScript package to filter and detect profanity
JavaScript
4
star
16

BikeShare

Open Source BikeShare app made in Titanium
JavaScript
3
star
17

ti.gamedevkit

A collection of libraries for gamedevelopment purposes
JavaScript
3
star
18

ti.dbutil

A Titanium utility library to help with transactional queries
JavaScript
3
star
19

authenticatedImageView

Simple code to demo extending imageviews in Titanium
JavaScript
3
star
20

alloy-livestream

The app made on livestream demonstrating alloy features
JavaScript
2
star
21

LivestreamListView

The app as demo'd during the Titanium Livestream Nov-15th 2018
JavaScript
1
star
22

to.cachedimageview

A module to get an imageview with configurable cache
JavaScript
1
star