Skip to content

Commit

Permalink
Merge pull request #1231 from joreilly/add-logo-url-dark
Browse files Browse the repository at this point in the history
Add Partner.logoUrl(dark: Boolean)
  • Loading branch information
martinbonnin authored Apr 3, 2024
2 parents a36bc8e + 6233bbc commit ac311fa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,17 @@ class DataStore {
return mapOf(
"name" to this.name,
"url" to this.url,
"logoUrl" to this.logoUrl
"logoUrl" to this.logoUrl,
"logoUrlDark" to this.logoUrlDark,
)
}

private fun Map<String, Any?>.toPartner(): DPartner {
return DPartner(
name = get("name").asString,
url = get("url").asString,
logoUrl = get("logoUrl").asString
logoUrl = get("logoUrl").asString,
logoUrlDark = get("logoUrlDark")?.asString,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ data class DPartnerGroup(
data class DPartner(
val name: String,
val logoUrl: String,
val logoUrlDark: String? = null,
val url: String,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class DataStoreDataSource(private val conf: String, private val uid: String? = n
return Partner(
name = name,
logoUrl = logoUrl,
logoUrlDark = logoUrlDark,
url = url
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,20 @@ data class PartnerGroup(
data class Partner(
val name: String,
val logoUrl: String,
val logoUrlDark: String?,
val url: String,
)
) {
/**
* @param dark returns the logo for use on a dark background or fallbacks to the light mode if none exist
*/
fun logoUrl(dark: Boolean? = false): String {
return if (dark == true) {
logoUrlDark ?: logoUrl
} else {
logoUrl
}
}
}

/**
* @property floorPlanUrl the url to an image containing the floor plan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ object Sessionize {
DPartner(
name = "zimperium",
logoUrl = "https://androidmakers.droidcon.com/wp-content/uploads/sites/5/2024/02/ZIMPERIUM_logo__3_-ai-1024x155.png",
logoUrlDark = "https://github.com/joreilly/Confetti/assets/3974977/5bf38c6c-5ebb-4225-a006-988f8a17d150",
url = "https://www.zimperium.com/"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private fun JsonPartner.toDPartner(): DPartner {
return DPartner(
name = name,
logoUrl = photoUrl,
logoUrlDark = null,
url = url
)
}

0 comments on commit ac311fa

Please sign in to comment.