Using the Pull To Refresh Control

The pull to refresh control is created with the idea of providing a pull to refresh functionality

it is very simple and easy to use. here is the demo app to show you how easy it is to use


local _W = display.contentWidth
local _H = display.contentHeight

local pull = require("pull")

local group = display.newGroup()
local back = display.newImage("backdrop.jpg",true)

display.setStatusBar(display.DarkStatusBar)

--Create the PullToRefresh Container
local p1 = pull.new()


--Creat the UI for the app
local container = display.newGroup()
local scrollable = display.newRect(container,0,20,_W,_H*3)
scrollable:setFillColor(250,250,250,200)

local rect = display.newRect(container,10,30,100,100)
rect:setFillColor(0,255,255)

local logo = display.newImage(container,"logo.png",100,200)

local moveAbout = function ( e )
local phase=e.phase
if "began"==phase then
display.currentStage:setFocus(rect)
elseif "moved" == phase then
--
elseif "ended" == phase or "cancelled" == phase then
display.currentStage:setFocus(nil)
end
return true
end

rect:addEventListener("touch",moveAbout)

--All the UI and code is created

--Set the container object to sit inside of the PullToRefresh
p1.setContainer(container)

--Customise the message it shows when pulled down or when pulling down
p1.pullMessage("Pull it down to reval its secrets...")
p1.releaseMessage("Pop it to really reval its secrets...")

--The callback function that is called
local function testing ()
print ("Refreshed")
native.showAlert("Refresh","This is a call back function when refreshed",{"OK"})
end

--Set the callback function
p1.setCallBack(testing)

Comments

  1. Hi,

    I know this is nearly a year old but was wondering where you get the pull.lua from ?

    I was searching on Google for a "Pull to refresh" type interface and came across this post.

    Dave

    ReplyDelete
  2. Hi Dave, that pull.lua is the code that I have written. Here's a link to the video if you want to see it in action. http://iphone.oz-apps.com/pull-to-refresh-custom-control

    ReplyDelete
  3. Looks good.

    Are these things you develop for yourselves or do you share the code anywhere ?

    Dave

    ReplyDelete
  4. Hi Dave,
    My full time profile is Mobile Development and Consultancy, I did post a couple of code snips, but components like these are the widgets that I can offer to other developers on a commercial basis, i.e. you they can buy them for use in their own apps.

    While some develop mobile apps for fun and hobby, this is my main business, so cannot offer it for free. However, I am rewriting these for adapting to the multiple resolutions (this was written for iPhone3 type devices only). The other components too will be available in a bit.

    Before you ask me the next question, these are available in the range of $10-$15 and the source code is obfuscated, so if you are after wanting to study the code, this format might not be the suitable for you and you might be unable to further extend this/these yourself.

    ReplyDelete
    Replies
    1. Hi, I saw the video. It looks like a good example. The question is how can I buy this?. Is there a link to buy from? or send you a message?. Just if you tell me how, I will appreciate that.

      Thanks

      Delete
    2. Hi,
      You could have provided a name or some way to contact you. Anyways, you can send me a message, pay via paypal and on receipt of the funds, I can send you the file(s).

      cheers,

      Delete

Post a Comment

Popular Posts