Lua
Other Lua files
-
KwikshelfPlugin is updated via CoronaLab’s market system, Book01, Boo02, BookTOC projects are normal Kwik projects you can maintain with the latest Kwik
-
extlib folder in BookshelfEmbedded is maintained in GitHub and the latest files are available in GitHub
- https://github.com/kwiksher/Bookshelf
- BookshelfEmbedded/extlib
- https://github.com/kwiksher/Bookshelf
-
extlib/spinner.lua
if you want to change the spinner animation during downloading the contents, please edit spinner.lua in extlib folder
local M = {}
function M.new (host)
local obj = {}
local spinner
obj.host = host
--
function obj:show(host)
if not spinner then
spinner = display.newGroup()
local hostName = host or obj.host or ""
--Place a progress spinner on screen and tell the user the app is contating the store
local spinnerBackground = display.newRect(0,0,360,600)
spinnerBackground:setFillColor(1,1,1,0.75)
--Spinner consumes all taps so the user cannot tap the purchase button twice
spinnerBackground:addEventListener("tap", function() return true end)
local spinnerText = display.newText("Contacting " .. hostName .. "...", 0, -20, native.systemFont, 18)
spinnerText:setFillColor(0,0,0)
--Add a little spinning rectangle
local spinnerRect = display.newRect(0, 0,35,35)
spinnerRect:setFillColor(0.25,0.25,0.25)
transition.to(spinnerRect, { time=4000, rotation=360, iterations=999999, transition=easing.inOutQuad})
--Create a group and add all these objects to it
spinner:insert(spinnerBackground)
spinner:insert(spinnerText)
spinner:insert(spinnerRect)
spinner.x, spinner.y = _W/2, _H/2
end
end
--
function obj:remove()
print("remove")
if (spinner) then
spinner:removeSelf()
spinner=nil
end
end
return obj
end
return M
-
updateText
- startTime: the start time of a book download
- size: the size in progress
- bookSize:the total size of assets of a book
function obj:updateText() local percent = self.size/self.bookSize local sec = os.difftime( os.time(), self.startTime) local remain = math.floor(sec * (1.0/percent)) local time = os.date("*t", remain) self.spinnerText.text = math.floor(percent*100).." % (" ..self.size .."/" ..self.bookSize .." Mb) \n left " ..time.min..":"..time.sec end
extlib/maker.lua
If there are updates of zip files in http server, the master app shows the maker below to a button.
extlib/maker.lua
-
button: the download button in the dialog or the image object in the thumbnail of TOC page
-
group is a sceneGroup of composer
function M.new (button, group) --print(button, group) if button.updateMark == nil then local obj = display.newCircle(0,0,4) obj.x = button.x + button.width/2 obj.y = button.y - button.height/2 obj:setFillColor(1,0,0) group:insert(obj) button.updateMark = obj else button.updateMark.alpha = 1 end end
