Skip to content

Commit

Permalink
feat: Add Border Stroke Parameter in Avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
8954sood committed Nov 13, 2024
1 parent da0fa59 commit 3634484
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/b1nd/dodam/designsystem/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.b1nd.dodam.designsystem
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -47,6 +48,11 @@ class MainActivity : ComponentActivity() {
imageVector = DodamIcons.Chart.value,
contentDescription = null
)
DodamAvatar(
model = null,
avatarSize = AvatarSize.ExtraLarge,
borderStroke = BorderStroke(1.dp, DodamTheme.colors.lineAlternative)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.b1nd.dodam.designsystem.component

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
Expand All @@ -20,6 +22,7 @@ import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import com.b1nd.dodam.designsystem.DodamTheme
import com.b1nd.dodam.designsystem.foundation.DodamIcons
import com.b1nd.dodam.designsystem.internal.`if`


@Composable
Expand All @@ -30,6 +33,7 @@ fun DodamAvatar(
contentDescription: String? = null,
colorFilter: ColorFilter? = null,
alpha: Float = DefaultAlpha,
borderStroke: BorderStroke? = null,
contentScale: ContentScale = ContentScale.Fit,
) {

Expand All @@ -40,7 +44,13 @@ fun DodamAvatar(
DodamAsyncAvatar(
modifier = modifier
.size(avatarConfig.backgroundSize)
.clip(CircleShape),
.clip(CircleShape)
.`if`(borderStroke != null) {
border(
border = borderStroke!!,
shape = CircleShape
)
},
model = model,
contentDescription = contentDescription,
colorFilter = colorFilter,
Expand All @@ -56,6 +66,13 @@ fun DodamAvatar(
color = DodamTheme.colors.fillNormal,
shape = CircleShape
)
.`if`(borderStroke != null) {
border(
border = borderStroke!!,
shape = CircleShape
)
}

) {
Image(
modifier = Modifier
Expand All @@ -79,15 +96,15 @@ private fun DodamAsyncAvatar(
contentDescription: String?,
colorFilter: ColorFilter?,
alpha: Float,
contentScale: ContentScale
contentScale: ContentScale,
) {
AsyncImage(
modifier = modifier,
model = model,
contentDescription = contentDescription,
colorFilter = colorFilter,
alpha = alpha,
contentScale = contentScale
contentScale = contentScale,
)
}

Expand Down

0 comments on commit 3634484

Please sign in to comment.