Skip to content

Commit

Permalink
fix: team logo
Browse files Browse the repository at this point in the history
  • Loading branch information
croumy committed Oct 16, 2023
1 parent 9870db7 commit 5e9e0c3
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 9 deletions.
26 changes: 26 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/markdown-navigator-enh.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
package com.croumy.nbawatch.presentation.ui.components

import Team
import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.croumy.nbawatch.presentation.theme.Dimensions

@Composable
fun TeamLogo(team: Team, size: Dp = Dimensions.sIcon) {
val context = LocalContext.current
val picture = remember { mutableStateOf<Int?>(null) }

LaunchedEffect(team.teamTricode) {
val identifier = context.resources.getIdentifier(
team.teamTricode.lowercase(),
"drawable",
context.packageName
)

picture.value = if(identifier != 0) identifier else null
}

Image(
painter = painterResource(
id = context.resources.getIdentifier(
team.teamTricode.lowercase(),
id = picture.value ?: context.resources.getIdentifier(
"placeholder",
"drawable",
context.packageName
context.packageName,
)
),
contentDescription = "",
modifier = Modifier.size(size)
modifier = Modifier.size(size).padding(if(picture.value == null) Dimensions.xxsPadding else 0.dp)
)
}
Binary file added app/src/main/res/drawable/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e9e0c3

Please sign in to comment.