Skip to content

Commit

Permalink
Make check for expressive variants more generic as there are more tha…
Browse files Browse the repository at this point in the history
…n just --active variants
  • Loading branch information
hakonschia committed Aug 17, 2024
1 parent 1aa3cc8 commit d27c3c7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 64 deletions.
13 changes: 8 additions & 5 deletions .github/scripts/generate-android-vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ function generateKotlinValues() {

// Probably a more efficient way to do this, but I don't think it really matters
const expressiveVariant = generatedDrawables.find((element) => {
const isActiveVariant = drawable.match("__active")

if (isActiveVariant) {
// Active expressive variants are named "horse_expressive__active", if "_expressive" was always the postfix we could just handle it like non-active ones
return element == rawNormalIconName.replace("__active", "") + "_expressive__active.xml"
// Icon variants such as "nrk-bell--active", "nrk-media-play-expressive--fail", or " nrk-media-volume-expressive--1"
// Variants end with "--variant", with "-expressive" being infront of the variant type. For those we need to insert "_expressive" into the name
// instead of just adding it at the end like
const indexOfVariantStart = drawable.indexOf("__")

if (indexOfVariantStart != -1) {
// From "nrk_media_playe__fail" to "nrk_media_playe_expressive__fail"
return element == rawNormalIconName.substring(0, indexOfVariantStart) + "_expressive" + rawNormalIconName.substring(indexOfVariantStart) + ".xml"
} else {
return element == rawNormalIconName + "_expressive.xml"
}
Expand Down
118 changes: 59 additions & 59 deletions android/icons/src/main/kotlin/no/nrk/core/icons/NrkIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ object NrkIcons {
expressive = R.drawable.nrk_broadcast_expressive
)

val NrkBulletSquare = NrkIcon(
normal = R.drawable.nrk_bullet_square,
expressive = R.drawable.nrk_bullet_square_expressive
)

val NrkBulletedList = NrkIcon(
normal = R.drawable.nrk_bulleted_list,
expressive = R.drawable.nrk_bulleted_list_expressive
)

val NrkBulletSquare = NrkIcon(
normal = R.drawable.nrk_bullet_square,
expressive = R.drawable.nrk_bullet_square_expressive
)

val NrkCalendar = NrkIcon(
normal = R.drawable.nrk_calendar,
expressive = R.drawable.nrk_calendar_expressive
Expand All @@ -153,16 +153,6 @@ object NrkIcons {
expressive = R.drawable.nrk_check_expressive
)

val NrkCheckActive = NrkIcon(
normal = R.drawable.nrk_check__active,
expressive = R.drawable.nrk_check_expressive__active
)

val NrkCheckRadioUnchecked = NrkIcon(
normal = R.drawable.nrk_check_radio__unchecked,
expressive = null
)

val NrkCheckbox = NrkIcon(
normal = R.drawable.nrk_checkbox,
expressive = R.drawable.nrk_checkbox_expressive
Expand All @@ -173,6 +163,16 @@ object NrkIcons {
expressive = R.drawable.nrk_checkbox_expressive__active
)

val NrkCheckRadioUnchecked = NrkIcon(
normal = R.drawable.nrk_check_radio__unchecked,
expressive = null
)

val NrkCheckActive = NrkIcon(
normal = R.drawable.nrk_check__active,
expressive = R.drawable.nrk_check_expressive__active
)

val NrkChevronDown = NrkIcon(
normal = R.drawable.nrk_chevron_down,
expressive = R.drawable.nrk_chevron_down_expressive
Expand Down Expand Up @@ -328,11 +328,6 @@ object NrkIcons {
expressive = R.drawable.nrk_geo_expressive
)

val NrkGeoActive = NrkIcon(
normal = R.drawable.nrk_geo__active,
expressive = R.drawable.nrk_geo_expressive__active
)

val NrkGeopoint = NrkIcon(
normal = R.drawable.nrk_geopoint,
expressive = R.drawable.nrk_geopoint_expressive
Expand All @@ -343,6 +338,11 @@ object NrkIcons {
expressive = R.drawable.nrk_geopoint_expressive__active
)

val NrkGeoActive = NrkIcon(
normal = R.drawable.nrk_geo__active,
expressive = R.drawable.nrk_geo_expressive__active
)

val NrkGlobe = NrkIcon(
normal = R.drawable.nrk_globe,
expressive = R.drawable.nrk_globe_expressive
Expand Down Expand Up @@ -575,17 +575,17 @@ object NrkIcons {

val NrkMediaChromecast1 = NrkIcon(
normal = R.drawable.nrk_media_chromecast__1,
expressive = null
expressive = R.drawable.nrk_media_chromecast_expressive__1
)

val NrkMediaChromecast2 = NrkIcon(
normal = R.drawable.nrk_media_chromecast__2,
expressive = null
expressive = R.drawable.nrk_media_chromecast_expressive__2
)

val NrkMediaChromecast3 = NrkIcon(
normal = R.drawable.nrk_media_chromecast__3,
expressive = null
expressive = R.drawable.nrk_media_chromecast_expressive__3
)

val NrkMediaChromecastActive = NrkIcon(
Expand All @@ -603,9 +603,14 @@ object NrkIcons {
expressive = null
)

val NrkMediaDirekteActive = NrkIcon(
normal = R.drawable.nrk_media_direkte__active,
expressive = null
val NrkMediaDirektetv = NrkIcon(
normal = R.drawable.nrk_media_direktetv,
expressive = R.drawable.nrk_media_direktetv_expressive
)

val NrkMediaDirektetvActive = NrkIcon(
normal = R.drawable.nrk_media_direktetv__active,
expressive = R.drawable.nrk_media_direktetv_expressive__active
)

val NrkMediaDirekteAnimatedActive = NrkIcon(
Expand All @@ -623,14 +628,9 @@ object NrkIcons {
expressive = null
)

val NrkMediaDirektetv = NrkIcon(
normal = R.drawable.nrk_media_direktetv,
expressive = R.drawable.nrk_media_direktetv_expressive
)

val NrkMediaDirektetvActive = NrkIcon(
normal = R.drawable.nrk_media_direktetv__active,
expressive = R.drawable.nrk_media_direktetv_expressive__active
val NrkMediaDirekteActive = NrkIcon(
normal = R.drawable.nrk_media_direkte__active,
expressive = null
)

val NrkMediaFfw = NrkIcon(
Expand Down Expand Up @@ -703,11 +703,6 @@ object NrkIcons {
expressive = R.drawable.nrk_media_play_expressive
)

val NrkMediaPlayFail = NrkIcon(
normal = R.drawable.nrk_media_play__fail,
expressive = null
)

val NrkMediaPlaylist = NrkIcon(
normal = R.drawable.nrk_media_playlist,
expressive = R.drawable.nrk_media_playlist_expressive
Expand All @@ -718,6 +713,11 @@ object NrkIcons {
expressive = R.drawable.nrk_media_playlist_add_expressive
)

val NrkMediaPlaylistAdded = NrkIcon(
normal = R.drawable.nrk_media_playlist_added,
expressive = R.drawable.nrk_media_playlist_added_expressive
)

val NrkMediaPlaylistAddLater = NrkIcon(
normal = R.drawable.nrk_media_playlist_add_later,
expressive = R.drawable.nrk_media_playlist_add_later_expressive
Expand All @@ -728,16 +728,16 @@ object NrkIcons {
expressive = R.drawable.nrk_media_playlist_add_next_expressive
)

val NrkMediaPlaylistAdded = NrkIcon(
normal = R.drawable.nrk_media_playlist_added,
expressive = R.drawable.nrk_media_playlist_added_expressive
)

val NrkMediaPlaylistRemove = NrkIcon(
normal = R.drawable.nrk_media_playlist_remove,
expressive = R.drawable.nrk_media_playlist_remove_expressive
)

val NrkMediaPlayFail = NrkIcon(
normal = R.drawable.nrk_media_play__fail,
expressive = R.drawable.nrk_media_play_expressive__fail
)

val NrkMediaPrevious = NrkIcon(
normal = R.drawable.nrk_media_previous,
expressive = R.drawable.nrk_media_previous_expressive
Expand All @@ -758,16 +758,16 @@ object NrkIcons {
expressive = R.drawable.nrk_media_quaver_expressive
)

val NrkMediaQuaverActive = NrkIcon(
normal = R.drawable.nrk_media_quaver__active,
expressive = R.drawable.nrk_media_quaver_expressive__active
)

val NrkMediaQuaverOff = NrkIcon(
normal = R.drawable.nrk_media_quaver_off,
expressive = R.drawable.nrk_media_quaver_off_expressive
)

val NrkMediaQuaverActive = NrkIcon(
normal = R.drawable.nrk_media_quaver__active,
expressive = R.drawable.nrk_media_quaver_expressive__active
)

val NrkMediaRwd = NrkIcon(
normal = R.drawable.nrk_media_rwd,
expressive = R.drawable.nrk_media_rwd_expressive
Expand Down Expand Up @@ -798,6 +798,11 @@ object NrkIcons {
expressive = null
)

val NrkMediaSpeed1x = NrkIcon(
normal = R.drawable.nrk_media_speed_1x,
expressive = null
)

val NrkMediaSpeed125x = NrkIcon(
normal = R.drawable.nrk_media_speed_1_25x,
expressive = null
Expand All @@ -808,11 +813,6 @@ object NrkIcons {
expressive = null
)

val NrkMediaSpeed1x = NrkIcon(
normal = R.drawable.nrk_media_speed_1x,
expressive = null
)

val NrkMediaSpeed2x = NrkIcon(
normal = R.drawable.nrk_media_speed_2x,
expressive = null
Expand All @@ -835,7 +835,7 @@ object NrkIcons {

val NrkMediaSubtitlesUnavailable = NrkIcon(
normal = R.drawable.nrk_media_subtitles__unavailable,
expressive = null
expressive = R.drawable.nrk_media_subtitles_expressive__unavailable
)

val NrkMediaTheater = NrkIcon(
Expand Down Expand Up @@ -870,22 +870,22 @@ object NrkIcons {

val NrkMediaVolume1 = NrkIcon(
normal = R.drawable.nrk_media_volume__1,
expressive = null
expressive = R.drawable.nrk_media_volume_expressive__1
)

val NrkMediaVolume2 = NrkIcon(
normal = R.drawable.nrk_media_volume__2,
expressive = null
expressive = R.drawable.nrk_media_volume_expressive__2
)

val NrkMediaVolume3 = NrkIcon(
normal = R.drawable.nrk_media_volume__3,
expressive = null
expressive = R.drawable.nrk_media_volume_expressive__3
)

val NrkMediaVolumeMuted = NrkIcon(
normal = R.drawable.nrk_media_volume__muted,
expressive = null
expressive = R.drawable.nrk_media_volume_expressive__muted
)

val NrkMening = NrkIcon(
Expand Down

0 comments on commit d27c3c7

Please sign in to comment.