Skip to content

Commit

Permalink
feat: プロフィール画像が設定されていない場合のデフォルトアイコンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Mar 10, 2024
1 parent 59bd6dc commit 0eff07d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package club.nito.core.designsystem.icon

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Visibility
import androidx.compose.material.icons.filled.VisibilityOff
import androidx.compose.ui.graphics.vector.ImageVector

public object NitoIcons {
public val AccountCircle: ImageVector = Icons.Filled.AccountCircle
public val Visibility: ImageVector = Icons.Filled.Visibility
public val VisibilityOff: ImageVector = Icons.Filled.VisibilityOff
}
26 changes: 18 additions & 8 deletions core/ui/src/commonMain/kotlin/club/nito/core/ui/ProfileImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package club.nito.core.ui

import androidx.compose.foundation.Image
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import club.nito.core.designsystem.icon.NitoIcons
import club.nito.core.model.UserProfile
import com.seiko.imageloader.rememberImagePainter

Expand All @@ -14,12 +16,20 @@ public fun ProfileImage(
profile: UserProfile,
modifier: Modifier = Modifier,
) {
Image(
painter = rememberImagePainter(
url = profile.avatarUrl,
),
contentDescription = profile.displayName,
contentScale = ContentScale.Crop,
modifier = modifier.clip(CircleShape),
)
if (profile.avatarUrl.isNotBlank()) {
Image(
painter = rememberImagePainter(
url = profile.avatarUrl,
),
contentDescription = profile.displayName,
contentScale = ContentScale.Crop,
modifier = modifier.clip(CircleShape),
)
} else {
Icon(
imageVector = NitoIcons.AccountCircle,
contentDescription = profile.displayName,
modifier = modifier,
)
}
}

0 comments on commit 0eff07d

Please sign in to comment.