Skip to content

Commit

Permalink
Merge pull request #15 from Team-B1ND/feature/1.0.4
Browse files Browse the repository at this point in the history
Release 1.0.4
  • Loading branch information
8954sood authored Sep 5, 2024
2 parents 6a57267 + f731292 commit ee60944
Show file tree
Hide file tree
Showing 19 changed files with 653 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![version](https://img.shields.io/badge/version-1.0.3-blue)
![version](https://img.shields.io/badge/version-1.0.4-blue)

## How to use?
in your project
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/com/b1nd/dodam/designsystem/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ package com.b1nd.dodam.designsystem
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.ExperimentalMaterial3Api
import com.b1nd.dodam.designsystem.component.AvatarSize
import com.b1nd.dodam.designsystem.component.DodamAvatar

@ExperimentalMaterial3Api
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {

DodamTheme {
Column {
DodamAvatar(
model = "https://dodam.kr.object.ncloudstorage.com/dodam/6634113f-951b-430c-81c9-957de0e8abddalimo.png",
avatarSize = AvatarSize.Large
)
}
}
}
}
}
16 changes: 15 additions & 1 deletion dodam-design-system/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ kotlin {
androidMain.dependencies {
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.coil.network.okhttp)
}

commonMain.dependencies {
Expand All @@ -50,6 +51,19 @@ kotlin {
implementation(libs.compose.components.resources)
implementation(libs.compose.animation)
implementation(libs.compose.components.ui.tooling.preview)

implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.io.core)
implementation(libs.kotlinx.io.bytestring)

implementation(libs.coil)
implementation(libs.coil.compose)
implementation(libs.coil.network.ktor)
implementation(libs.ktor.client.core)
}

iosMain.dependencies {
implementation(libs.ktor.client.darwin)
}
}

Expand All @@ -66,7 +80,7 @@ mavenPublishing {
coordinates(
groupId = "com.b1nd.dodam",
artifactId = "dodam-design-system",
version = "1.0.3"
version = "1.0.4"
)

pom {
Expand Down
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>
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
}
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
)
}
}
}
Loading

0 comments on commit ee60944

Please sign in to comment.