Compare commits

...

3 Commits

Author SHA1 Message Date
teverse 96da67ed50 Ability to load networked apps 2020-06-28 12:36:39 +01:00
teverse 596e511886 Merge branch 'master' of https://github.com/teverse/teverse 2020-06-28 12:34:23 +01:00
teverse f7069e3547 Small improvement to app UI 2020-06-28 12:34:19 +01:00
2 changed files with 95 additions and 68 deletions

View File

@ -30,6 +30,16 @@ local function createApp(app)
active = false
})
if (app.iconUrl and app.iconUrl ~= "") then
local img = teverse.construct("guiImage", {
size = guiCoord(1, 0, 1, 0),
image = app.iconUrl,
parent = appGui,
active = false,
zIndex = -1
})
end
return appGui
end
@ -64,91 +74,29 @@ return {
local subtitle = teverse.construct("guiTextBox", {
parent = page,
size = guiCoord(1.0, -20, 0, 18),
position = guiCoord(0, 10, 0, 105),
position = guiCoord(0, 10, 0, 55),
backgroundAlpha = 0,
text = "Loading Apps",
textSize = 18,
textAlign = "middleLeft"
})
local myApps = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1.0, -20, 0, 38),
position = guiCoord(0, 10, 0, 62),
backgroundAlpha = 0
})
teverse.http:get("https://teverse.com/api/users/" .. teverse.networking.localClient.id .. "/apps", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
local apps = teverse.json:decode(body)
for i,app in pairs(apps) do
local appGui = teverse.construct("guiFrame", {
strokeRadius = 2,
dropShadowAlpha = 0.15,
strokeAlpha = 0.05,
parent = myApps,
position = guiCoord(0, (i-1)*140, 0, 0),
size = guiCoord(0, 130, 1, 0)
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 0, 16),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = app.name,
textSize = 18,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansSemiBold.ttf",
active = false
})
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 0, 14),
position = guiCoord(0, 10, 0, 21),
backgroundAlpha = 0,
text = app.approved and "Approved" or "Pending",
textSize = 14,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansBold.ttf",
active = false
})
appGui:on("mouseLeftUp", function()
if not loading.visible then
loading.text = "Loading App"
loading.visible = true
teverse.apps:loadRemote(app.id)
teverse.apps:waitFor("download")
loading.visible = false
end
end)
end
end
end)
local appsContainer = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1.0, -20, 1, -140),
position = guiCoord(0, 10, 0, 130),
size = guiCoord(1.0, -20, 1, -100),
position = guiCoord(0, 10, 0, 80),
backgroundAlpha = 0
})
if _DEVICE:sub(0, 6) == "iPhone" then
teverse.guiHelper
.gridConstraint(appsContainer, {
cellSize = guiCoord(0, page.absoluteSize.x - 20, 0, 50),
cellSize = guiCoord(0, page.absoluteSize.x - 20, 0, page.absoluteSize.x - 20),
cellMargin = guiCoord(0, 15, 0, 25)
})
else
teverse.guiHelper
.gridConstraint(appsContainer, {
cellSize = guiCoord(0, 160, 0, 50),
cellSize = guiCoord(0, 200, 0, 200),
cellMargin = guiCoord(0, 15, 0, 25)
})
end
@ -184,7 +132,11 @@ return {
if not loading.visible then
loading.text = "Loading App"
loading.visible = true
teverse.apps:loadRemote(app.id)
if not app.packageNetworked then
teverse.apps:loadRemote(app.id)
else
teverse.networking:initiate(app.id)
end
teverse.apps:waitFor("download")
loading.visible = false
end

View File

@ -1,3 +1,37 @@
local function createApp(app)
local appGui = teverse.construct("guiFrame", {
strokeRadius = 2,
dropShadowAlpha = 0.15,
strokeAlpha = 0.05
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 0, 22),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = app.name,
textSize = 22,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansBold.ttf",
active = false
})
if (app.iconUrl and app.iconUrl ~= "") then
local img = teverse.construct("guiImage", {
size = guiCoord(1, 0, 1, 0),
image = app.iconUrl,
parent = appGui,
active = false,
zIndex = -1
})
end
return appGui
end
return {
name = "Develop",
iconId = "layer-group",
@ -90,5 +124,46 @@ return {
active = false
})
end
local appsContainer = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1.0, -20, 1, -150),
position = guiCoord(0, 10, 0, 150),
backgroundAlpha = 0
})
teverse.guiHelper
.gridConstraint(appsContainer, {
cellSize = guiCoord(0, 200, 0, 200),
cellMargin = guiCoord(0, 15, 0, 25)
})
teverse.http:get("https://teverse.com/api/users/" .. teverse.networking.localClient.id .. "/apps", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
local apps = teverse.json:decode(body)
for _,app in pairs(apps) do
local appGui = createApp(app)
appGui.parent = appsContainer
appGui:on("mouseLeftUp", function()
if not loading.visible then
loading.text = "Loading App"
loading.visible = true
if not app.packageNetworked then
teverse.apps:loadRemote(app.id)
else
teverse.networking:initiate(app.id)
end
teverse.apps:waitFor("download")
loading.visible = false
end
end)
end
else
subtitle.text = "Server error."
end
end)
end
}