-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Team-B1ND/feature/1.0.4
Release 1.0.4
- Loading branch information
Showing
19 changed files
with
653 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dodam-design-system/src/commonMain/composeResources/drawable/ic_person.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M8.002,6.9C8.002,5.839 8.424,4.822 9.174,4.072C9.924,3.321 10.941,3 12.002,3C13.063,3 14.08,3.321 14.83,4.072C15.581,4.822 16.002,5.839 16.002,6.9C16.002,7.961 15.581,8.978 14.83,9.728C14.08,10.479 13.063,10.9 12.002,10.9C10.941,10.9 9.924,10.479 9.174,9.728C8.424,8.978 8.002,7.961 8.002,6.9ZM8.002,12.25C6.002,12.5 5.404,13.027 4.467,13.965C3.529,14.902 3.002,16.174 3.002,17.5C3.002,18.296 2.939,19.437 3.502,20C4.065,20.563 5.206,20.5 6.002,20.5H18.002C18.798,20.5 19.94,20.563 20.502,20C21.065,19.437 21.002,18.296 21.002,17.5C21.002,16.174 20.475,14.902 19.538,13.965C18.6,13.027 18.002,12.5 16.002,12.25C14.002,12 13.576,12 12.002,12C10.428,12 10.002,12 8.002,12.25Z" | ||
android:fillColor="#000000" | ||
android:fillType="evenOdd"/> | ||
</vector> |
138 changes: 138 additions & 0 deletions
138
dodam-design-system/src/commonMain/kotlin/com/b1nd/dodam/designsystem/component/Avatar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.b1nd.dodam.designsystem.component | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.graphics.DefaultAlpha | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import coil3.compose.AsyncImage | ||
import coil3.request.ImageRequest | ||
import com.b1nd.dodam.designsystem.DodamTheme | ||
import com.b1nd.dodam.designsystem.foundation.DodamIcons | ||
|
||
|
||
@Composable | ||
fun DodamAvatar( | ||
modifier: Modifier = Modifier, | ||
avatarSize: AvatarSize, | ||
model: Any? = null, | ||
contentDescription: String? = null, | ||
colorFilter: ColorFilter? = null, | ||
alpha: Float = DefaultAlpha, | ||
contentScale: ContentScale = ContentScale.Fit, | ||
) { | ||
|
||
val avatarConfig = avatarSize.getAvatarConfig() | ||
|
||
when (model) { | ||
is String, is ImageRequest -> { | ||
DodamAsyncAvatar( | ||
modifier = modifier | ||
.size(avatarConfig.backgroundSize), | ||
model = model, | ||
contentDescription = contentDescription, | ||
colorFilter = colorFilter, | ||
alpha = alpha, | ||
contentScale = contentScale | ||
) | ||
} | ||
else -> { | ||
Box( | ||
modifier = modifier | ||
.size(avatarConfig.backgroundSize) | ||
.background( | ||
color = DodamTheme.colors.fillNormal, | ||
shape = CircleShape | ||
) | ||
) { | ||
Image( | ||
modifier = Modifier | ||
.size(avatarConfig.iconSize) | ||
.align(Alignment.Center), | ||
imageVector = DodamIcons.Person.value, | ||
contentDescription = contentDescription, | ||
alpha = alpha, | ||
colorFilter = colorFilter?: ColorFilter.tint(DodamTheme.colors.fillAlternative), | ||
contentScale = contentScale | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun DodamAsyncAvatar( | ||
modifier: Modifier = Modifier, | ||
model: Any, | ||
contentDescription: String?, | ||
colorFilter: ColorFilter?, | ||
alpha: Float, | ||
contentScale: ContentScale | ||
) { | ||
AsyncImage( | ||
modifier = modifier, | ||
model = model, | ||
contentDescription = contentDescription, | ||
colorFilter = colorFilter, | ||
alpha = alpha, | ||
contentScale = contentScale | ||
) | ||
} | ||
|
||
@Stable | ||
enum class AvatarSize { | ||
ExtraSmall, | ||
Small, | ||
Medium, | ||
Large, | ||
ExtraLarge, | ||
XXL, | ||
} | ||
|
||
@Immutable | ||
data class AvatarConfig( | ||
val backgroundSize: Dp, | ||
val iconSize: Dp | ||
) | ||
|
||
|
||
|
||
@Composable | ||
private fun AvatarSize.getAvatarConfig() = | ||
when (this) { | ||
AvatarSize.ExtraSmall -> AvatarConfig(AvatarDefaults.ExtraSmallBackgroundSize, AvatarDefaults.ExtraSmallIconSize) | ||
AvatarSize.Small -> AvatarConfig(AvatarDefaults.SmallBackgroundSize, AvatarDefaults.SmallIconSize) | ||
AvatarSize.Medium -> AvatarConfig(AvatarDefaults.MediumBackgroundSize, AvatarDefaults.MediumIconSize) | ||
AvatarSize.Large -> AvatarConfig(AvatarDefaults.LargeBackgroundSize, AvatarDefaults.LargeIconSize) | ||
AvatarSize.ExtraLarge -> AvatarConfig(AvatarDefaults.ExtraLargeBackgroundSize, AvatarDefaults.ExtraLargeIconSize) | ||
AvatarSize.XXL -> AvatarConfig(AvatarDefaults.XXLBackgroundSize, AvatarDefaults.XXLIconSize) | ||
} | ||
|
||
private object AvatarDefaults { | ||
val ExtraSmallBackgroundSize = 16.dp | ||
val SmallBackgroundSize = 24.dp | ||
val MediumBackgroundSize = 32.dp | ||
val LargeBackgroundSize = 36.dp | ||
val ExtraLargeBackgroundSize = 64.dp | ||
val XXLBackgroundSize = 128.dp | ||
|
||
val ExtraSmallIconSize = 10.dp | ||
val SmallIconSize = 15.dp | ||
val MediumIconSize = 20.dp | ||
val LargeIconSize = 22.5.dp | ||
val ExtraLargeIconSize = 40.dp | ||
val XXLIconSize = 80.dp | ||
} |
46 changes: 46 additions & 0 deletions
46
dodam-design-system/src/commonMain/kotlin/com/b1nd/dodam/designsystem/component/Badge.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.b1nd.dodam.designsystem.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.b1nd.dodam.designsystem.DodamTheme | ||
|
||
@Composable | ||
fun DodamBadge( | ||
modifier: Modifier = Modifier, | ||
count: String? = null, | ||
) { | ||
if (count == null) { | ||
Box( | ||
modifier = modifier | ||
.size(8.dp) | ||
.background( | ||
color = DodamTheme.colors.statusNegative, | ||
shape = CircleShape | ||
) | ||
) | ||
} else { | ||
Box( | ||
modifier = modifier | ||
.background( | ||
color = DodamTheme.colors.statusNegative, | ||
shape = CircleShape | ||
), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Text( | ||
modifier = Modifier.padding(horizontal = 6.dp), | ||
text = count, | ||
style = DodamTheme.typography.labelMedium(), | ||
color = DodamTheme.colors.staticWhite | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.