Skip to content

Commit

Permalink
added more icons settings + optional button.bg
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdugne committed Apr 27, 2019
1 parent 6e5dfb5 commit 7fba195
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
38 changes: 23 additions & 15 deletions cherry/components/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ function Button:icon(options)
end
--------------------------------------------------------------------------------

function Button:text(options)
-- if options.bg = false --> only text button
-- if options.bg is not defined --> default bg is rectangle
function Button:create(options)
options = options or {}
options =
_.defaults(
Expand All @@ -131,6 +133,7 @@ function Button:text(options)
image = 'cherry/assets/images/gui/buttons/rectangle.png',
xScale = 1,
yScale = 1
-- color = if defined, colorize bg
}
),
text = _.defaults(
Expand All @@ -157,20 +160,25 @@ function Button:text(options)
button.anchorX = options.anchorX
button.anchorY = options.anchorY

if (options.bg.color) then
local bg =
display.newRoundedRect(
button,
0,
0,
options.bg.width,
options.bg.height,
options.bg.cornerRadius
)
bg:setFillColor(colorize(options.bg.color))
else
local bg = display.newImage(button, options.bg.image)
bg:scale(options.bg.xScale, options.bg.yScale)
local bg
if (options.bg) then
if (options.bg.width) then
bg =
display.newRoundedRect(
button,
0,
0,
options.bg.width,
options.bg.height,
options.bg.cornerRadius
)
else
bg = display.newImage(button, options.bg.image)
bg:scale(options.bg.xScale, options.bg.yScale)
end
if (options.bg.color) then
bg:setFillColor(colorize(options.bg.color))
end
end

Text:create(
Expand Down
2 changes: 1 addition & 1 deletion cherry/components/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Options:drawLeaderboardButton(view)
y = LEADERBOARD_BUTTON_Y,
scale = .7,
action = function()
Router:open(Router.LEADERBOARD)
Router:open(App.screens.LEADERBOARD)
end
}
)
Expand Down
4 changes: 4 additions & 0 deletions prepare-icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ convert "$iosBase" -resize '120x120' -unsharp 1x4 "$xcassetsPath/Icon-60@2x.p
convert "$iosBase" -resize '180x180' -unsharp 1x4 "$xcassetsPath/Icon-60@3x.png"
convert "$iosBase" -resize '76x76' -unsharp 1x4 "$xcassetsPath/Icon-76.png"
convert "$iosBase" -resize '152x152' -unsharp 1x4 "$xcassetsPath/Icon-76@2x.png"
convert "$iosBase" -resize '120x120' -unsharp 1x4 "$xcassetsPath/Icon-120.png"
convert "$iosBase" -resize '152x152' -unsharp 1x4 "$xcassetsPath/Icon-152.png"
convert "$iosBase" -resize '167x167' -unsharp 1x4 "$xcassetsPath/Icon-167.png"
convert "$iosBase" -resize '1024x1024' -unsharp 1x4 "$xcassetsPath/Icon-1024.png"
echo "created iOS icons in $xcassetsPath/"

## -----------------------------------------------------------------------------
echo 'creating android icons...'
Expand All @@ -42,5 +45,6 @@ convert "$androidBase" -resize '72x72' -unsharp 1x4 "$androidPath/Icon-hdpi.
convert "$androidBase" -resize '96x96' -unsharp 1x4 "$androidPath/Icon-xhdpi.png"
convert "$androidBase" -resize '144x144' -unsharp 1x4 "$androidPath/Icon-xxhdpi.png"
convert "$androidBase" -resize '192x192' -unsharp 1x4 "$androidPath/Icon-xxxhdpi.png"
echo "created iOS icons in $androidPath/"

echo 'done!'

0 comments on commit 7fba195

Please sign in to comment.