Here is the code:
–
– main.lua
–
– Your code here
local composer = require “composer”
local scene = composer.newScene()
local widget = require “widget”
local height1 = display.contentHeight/6
local scrollView = widget.newScrollView
{
backgroundColor = {0.215, 0.67, 0.27},
left = 0,
top = 0,
width = display.contentWidth,
height = display.viewableContentHeight + 200,
topPadding = 30,
bottomPadding = 0,
horizontalScrollDisabled = false,
verticalScrollDisabled = false,
scrollHeight = display.contentHeight
}
scrollView.x = display.contentWidth/2
scrollView.y = display.contentHeight/2
–add new contact
local add = widget.newButton
{
left = 5,
top = 20,
width = 60,
height = 60,
id = “plus”,
label = “+”,
labelColor = {default = {1,1,1}, over = {1,1,1}},
fontSize = 140
}
add.x = display.contentWidth - add.width/2 - 10
add.y = add.height/4
function scene:create (event)
local homescreenGroup = self.view
–array for contacts
local contacts = {}
local numContacts = 1
local x = display.contentWidth/2
local y = -20
scrollView:insert(add)
–scrollView:insert(contacts)
homescreenGroup:insert(scrollView)
local function loadContacts()
y = y + display.contentHeight/6 + 30
contacts[numContacts] = display.newRect(x, y, display.contentWidth/1.5, display.contentHeight/6)
composer.gotoScene(“form”)
end
local function createContact()
numContacts = numContacts + 1
loadContacts()
end
add:addEventListener(“tap”, createContact)
end
function scene:hide(event)
end
function scene:show(event)
end
scene:addEventListener(“create”, scene)
scene:addEventListener(“show”, scene)
scene:addEventListener(“hide”, scene)
return scene