diff --git a/DefaultLayout.lua b/DefaultLayout.lua index a43e2b9..50984df 100644 --- a/DefaultLayout.lua +++ b/DefaultLayout.lua @@ -58,6 +58,7 @@ local headerCx = math.floor((display.bgCanvas.width - bigFont:getWidth(props.configState.config.branding.title)) / 2) local header -- TODO: Change header font size based on width + local headerHeight = 15 if theme.formatting.headerAlign == "center" and headerCx < currencyEndX and #categories == 1 then table.insert(elements, Rect { display=display, x=1, y=1, width=currencyEndX, height=bigFont.height+6, color=theme.colors.headerBgColor }) header = BigText { display=display, text=props.configState.config.branding.title, x=currencyEndX, y=1, align="left", bg=theme.colors.headerBgColor, color = theme.colors.headerColor, width=display.bgCanvas.width } @@ -67,6 +68,19 @@ else header = BigText { display=display, text=props.configState.config.branding.title, x=1, y=1, align=theme.formatting.headerAlign, bg=theme.colors.headerBgColor, color = theme.colors.headerColor, width=display.bgCanvas.width } end + if props.configState.config.branding.subtitle then + table.insert(elements, BasicText { + display = display, + text = props.configState.config.branding.subtitle, + x = 1, + y = 6, + align = theme.formatting.subtitleAlign, + bg = theme.colors.subtitleBgColor, + color = theme.colors.subtitleColor, + width = math.floor(display.bgCanvas.width / 2) + }) + headerHeight = headerHeight + 3 + end table.insert(elements, header) @@ -119,7 +133,7 @@ props.shopState.numCategories = #categories local catName = categories[selectedCategory].name local shopProducts = renderHelpers.getDisplayedProducts(categories[selectedCategory].products, props.configState.config.settings) - local productsHeight = display.bgCanvas.height - 17 - footerHeight + local productsHeight = display.bgCanvas.height - headerHeight - footerHeight - 2 local heightPerProduct = math.floor(productsHeight / #shopProducts) local layout if theme.formatting.layout == "auto" then @@ -190,6 +204,8 @@ break end end + local startY = headerHeight + 1 + local startTextY = math.ceil(headerHeight / 3) + 1 for i = 1, #shopProducts do local product = shopProducts[i] -- Display products in format: @@ -231,7 +247,7 @@ display=display, text=tostring(product.quantity), x=1, - y=16+((i-1)*15), + y=startY+((i-1)*15), align="center", bg=productBgColor, color=qtyColor, @@ -242,7 +258,7 @@ display=display, text=product.name, x=maxQtyWidth+1, - y=16+((i-1)*15), + y=startY+((i-1)*15), align=theme.formatting.productNameAlign, bg=productBgColor, color=productNameColor, @@ -253,7 +269,7 @@ display=display, text=tostring(productPrice) .. currencySymbol, x=display.bgCanvas.width-3-maxAddrWidth-maxPriceWidth, - y=16+((i-1)*15), + y=startY+((i-1)*15), align="right", bg=productBgColor, color=theme.colors.priceColor, @@ -264,7 +280,7 @@ display=display, text=productAddr, x=display.bgCanvas.width-3-maxAddrWidth, - y=16+((i-1)*15), + y=startY+((i-1)*15), align="right", bg=productBgColor, color=theme.colors.addressColor, @@ -275,7 +291,7 @@ display=display, text=kristpayHelperText, x=1, - y=1+(i*5), + y=startTextY+((i-1)*5), align="center", bg=productBgColor, color=productBgColor, @@ -287,7 +303,7 @@ display=display, text=tostring(product.quantity), x=1, - y=16+((i-1)*9), + y=startY+((i-1)*9), align="center", bg=productBgColor, color=qtyColor, @@ -298,7 +314,7 @@ display=display, text=product.name, x=maxQtyWidth+1, - y=16+((i-1)*9), + y=startY+((i-1)*9), align=theme.formatting.productNameAlign, bg=productBgColor, color=productNameColor, @@ -309,7 +325,7 @@ display=display, text=tostring(productPrice) .. currencySymbol, x=display.bgCanvas.width-3-maxAddrWidth-maxPriceWidth, - y=16+((i-1)*9), + y=startY+((i-1)*9), align="right", bg=productBgColor, color=theme.colors.priceColor, @@ -320,7 +336,7 @@ display=display, text=productAddr, x=display.bgCanvas.width-3-maxAddrWidth, - y=16+((i-1)*9), + y=startY+((i-1)*9), align="right", bg=productBgColor, color=theme.colors.addressColor, @@ -331,7 +347,7 @@ display=display, text=kristpayHelperText, x=1, - y=3+(i*3), + y=startTextY+((i-1)*3), align="center", bg=productBgColor, color=productBgColor, @@ -343,7 +359,7 @@ display=display, text=tostring(product.quantity), x=1, - y=6+((i-1)*1), + y=startTextY+((i-1)*1), align="center", bg=productBgColor, color=qtyColor, @@ -354,7 +370,7 @@ display=display, text=product.name, x=maxQtyWidth+1, - y=6+((i-1)*1), + y=startTextY+((i-1)*1), align=theme.formatting.productNameAlign, bg=productBgColor, color=productNameColor, @@ -365,7 +381,7 @@ display=display, text=tostring(productPrice) .. currencySymbol, x=(display.bgCanvas.width/2)-1-maxAddrWidth-maxPriceWidth, - y=6+((i-1)*1), + y=startTextY+((i-1)*1), align="right", bg=productBgColor, color=theme.colors.priceColor, @@ -376,7 +392,7 @@ display=display, text=productAddr, x=(display.bgCanvas.width/2)-1-maxAddrWidth, - y=6+((i-1)*1), + y=startTextY+((i-1)*1), align="right", bg=productBgColor, color=theme.colors.addressColor, diff --git a/config.lua b/config.lua index 3e630e7..2774451 100644 --- a/config.lua +++ b/config.lua @@ -1,6 +1,7 @@ return { branding = { - title = nil + title = nil, + subtitle = nil, }, settings = { hideUnavailableProducts = false, @@ -26,6 +27,7 @@ theme = { formatting = { headerAlign = "center", + subtitleAlign = "center", footerAlign = "center", footerSize = "auto", productNameAlign = "center", @@ -38,6 +40,8 @@ bgColor = colors.lightGray, headerBgColor = colors.red, headerColor = colors.white, + subtitleBgColor = colors.red, + subtitleColor = colors.white, footerBgColor = colors.red, footerColor = colors.white, productBgColors = { diff --git a/configDefaults.lua b/configDefaults.lua index 888c8ac..c69a4ac 100644 --- a/configDefaults.lua +++ b/configDefaults.lua @@ -26,6 +26,7 @@ theme = { formatting = { headerAlign = "center", + subtitleAlign = "center", footerAlign = "center", footerSize = "auto", productNameAlign = "center", @@ -38,6 +39,8 @@ bgColor = colors.lightGray, headerBgColor = colors.red, headerColor = colors.white, + subtitleBgColor = colors.red, + subtitleColor = colors.white, footerBgColor = colors.red, footerColor = colors.white, productBgColors = { diff --git a/core/schemas.lua b/core/schemas.lua index 98460ec..c0e6ad3 100644 --- a/core/schemas.lua +++ b/core/schemas.lua @@ -1,7 +1,8 @@ local configSchema = { branding = { - title = "string" + title = "string", + subtitle = "string?", }, settings = { hideUnavailableProducts = "boolean", @@ -26,6 +27,7 @@ theme = { formatting = { headerAlign = "enum<'left' | 'center' | 'right'>: alignment", + subtitleAlign = "enum<'left' | 'center' | 'right'>: alignment", footerAlign = "enum<'left' | 'center' | 'right'>: alignment", footerSize = "enum<'small' | 'medium' | 'large' | 'auto'>: size", productNameAlign = "enum<'left' | 'center' | 'right'>: alignment", @@ -36,6 +38,8 @@ bgColor = "color", headerBgColor = "color", headerColor = "color", + subtitleBgColor = "color", + subtitleColor = "color", footerBgColor = "color", footerColor = "color", productBgColors = { diff --git a/radon.lua b/radon.lua index e247ad4..6ce270c 100644 --- a/radon.lua +++ b/radon.lua @@ -1,4 +1,4 @@ -local version = "1.3.5" +local version = "1.3.6" local configHelpers = require "util.configHelpers" local schemas = require "core.schemas" local oldPullEvent = os.pullEvent @@ -203,7 +203,7 @@ maxScroll = 0, } -local mbsMode = false--fs.exists(".mbs") +--local mbsMode = settings.get("mbs.shell.enabled") local Terminal = Solyd.wrapComponent("Terminal", function(props) local canvas = useCanvas(terminal) @@ -212,18 +212,14 @@ local flatCanvas = {} local versionString = "Radon " .. version local terminalCatagories = { "logs", "config", "products" } - local msOffset = 0 - if mbsMode and multishell.getCount() > 1 then - msOffset = 1 - end - local bodyHeight = math.floor(terminal.bgCanvas.height / 3) - 1 - msOffset + local bodyHeight = math.floor(terminal.bgCanvas.height / 3) - 1 local bodyWidth = math.floor(terminal.bgCanvas.width / 2) table.insert(flatCanvas, Rect { key = "header", display = terminal, x = 1, - y = 1 + (msOffset*3), + y = 1, width = terminal.bgCanvas.width, height = 3, color = theme.colors.titleBgColor, @@ -234,7 +230,7 @@ align = "left", text = versionString, x = 1, - y = 1 + msOffset, + y = 1, color = theme.colors.titleTextColor, bg = theme.colors.titleBgColor, }) @@ -251,7 +247,7 @@ align = "center", text = " " .. terminalCatagories[i] .. " ", x = 2 + catagoriesX, - y = 1 + msOffset, + y = 1, color = theme.colors.catagoryTextColor, bg = bgColor, onClick = function() @@ -272,7 +268,7 @@ key = "config-editor", display = terminal, x = 1, - y = 2 + msOffset, + y = 2, width = bodyWidth, height = bodyHeight, config = props.configState.config, @@ -308,7 +304,7 @@ key = "products-editor", display = terminal, x = 1, - y = 2 + msOffset, + y = 2, width = bodyWidth, height = bodyHeight, config = props.shopState.products, @@ -335,7 +331,7 @@ key = "logs", display = terminal, x = 1, - y = 2 + msOffset, + y = 2, width = bodyWidth, height = bodyHeight, logs = props.logs,