INNER CODE UNIT · Ruby
write_theme_value
Automattic/pocket-casts-android · scripts/themes/generate_kotlin.rb:17
def write_theme_value(hex_val, opacity, token_name, file_path, theme_name)
if token_name.start_with?('filterU') || token_name.start_with?('filterI') || token_name.start_with?('filterT')
str = ''
# deal with special filter overlay colours
if ['filter', '$filter', '#filter'].include?(hex_val)
# the ones without any custom opacity are easy
if opacity == '100%' || opacity.nil? || opacity.empty?
str = " @ColorInt fun #{token_name}#{theme_name}(@ColorInt filterColor: Int): Int {
return filterColor
}\n\n"
else
# tokenize the filter colour to figure out what it should be
# example string: filter 15% on white
words = opacity.split
actual_opacity = words[1].gsub('%', '')
original_color = if words[3] == 'white'
'Color.WHITE'