Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init design system #9

Merged
merged 19 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/designsystem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
10 changes: 10 additions & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
Copy link
Collaborator

@ham2174 ham2174 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Suppress("DSL_SCOPE_VIOLATION") 요구문은 찾아보니까 그래들 8.2이상이면 필요 없다고 합니다~! 링크
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이거 빼는걸 깜빡했네유 반영하겠습니다!

plugins {
alias(libs.plugins.funch.feature)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias(libs.plugins.funch.feature) 요거 플러그인은 피처 모듈에서만 사용되는거 아닌가요..?
build-logic에서 CommonConfigs.kt 파일에서 KotlinSerializationPlugin, AndroidHiltPlugin를 사용하고 있는데 디자인 시스템에서 모듈에서 사용이 되는지 궁금합니다!!

plugins {
    id("com.android.library")
    alias(libs.plugins.funch.kotlin)
    alias(libs.plugins.funch.compose)
}

요렇게 작성하는건 어떤가용??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하겠습니다!

alias(libs.plugins.funch.compose)
}

android {
namespace = "com.moya.funch.designsystem"
}

61 changes: 61 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.moya.funch.theme

import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color

internal val Coral500 = Color(0xFFF86E6F)
internal val Lemon500 = Color(0xFFFFE83B)
internal val Lemon600 = Color(0xFFE1CA13)
internal val Lemon900 = Color(0xFF90720A)
internal val yellow500 = Color(0xFFE1B012)
internal val yellow600 = Color(0xFFFFD240)
internal val White = Color(0xFFFFFFFF)
internal val Gray900 = Color(0xFF151515)
internal val Gray800 = Color(0xFF242627)
internal val Gray700 = Color(0xFF2C2C2C)
internal val Gray600 = Color(0xFF363636)
internal val Gray500 = Color(0xFF404040)
internal val Gray400 = Color(0xFF6D6D6D)
internal val Gray300 = Color(0xFF9B9B9B)

@Stable
class FunchColorSchema(
background: Color,
error: Color,
white: Color,
) {
var background by mutableStateOf(background)
private set
var error by mutableStateOf(error)
private set
var white by mutableStateOf(white)
private set

fun copy(): FunchColorSchema = FunchColorSchema(
background = background,
error = error,
white = white,
)

fun update(other: FunchColorSchema) {
background = other.background
error = other.error
white = other.white
}
}

fun funchDarkColorSchema(
background: Color = Gray900,
white: Color = White,
error: Color = Coral500,

): FunchColorSchema {
return FunchColorSchema(
white = white,
background = background,
error = error,
)
}
46 changes: 46 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.moya.funch.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf

private val LocalFunchColors = staticCompositionLocalOf<FunchColorSchema> {
error("No FunchColors provided")
}
private val LocalFunchTypography = staticCompositionLocalOf<FunchTypography> {
error("No FunchTypography provided")
}

object FunchTheme {
val colors: FunchColorSchema @Composable get() = LocalFunchColors.current
val typography: FunchTypography @Composable get() = LocalFunchTypography.current
}

@Composable
fun ProvidePophoryColorAndTypography(
colors: FunchColorSchema,
typography: FunchTypography,
content: @Composable () -> Unit,
) {
val provideColors = remember { colors.copy() }
provideColors.update(colors)
val provideTypography = remember { typography.copy() }
provideTypography.update(typography)
CompositionLocalProvider(
LocalFunchColors provides provideColors, LocalFunchTypography provides provideTypography, content = content
)
}

@Composable
fun FunchTheme(
content: @Composable () -> Unit,
) {
// this version provides only dark theme
val colors = funchDarkColorSchema()
val typography = funchTypography()
ProvidePophoryColorAndTypography(colors, typography) {
MaterialTheme(content = content)
}
}
128 changes: 128 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package com.moya.funch.theme

import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.moya.funch.designsystem.R

private val spoqaHanSansNeo = FontFamily(
Font(
R.font.spoqa_han_sans_neo_bold,
FontWeight.Bold,
FontStyle.Normal
),
Font(
R.font.spoqa_han_sans_neo_medium,
FontWeight.Medium,
FontStyle.Normal
),
Font(
R.font.spoqa_han_sans_neo_regular,
FontWeight.Normal,
FontStyle.Normal
)

)

@Stable
class FunchTypography internal constructor(
t1: TextStyle,
t2: TextStyle,
sbt1: TextStyle,
sbt2: TextStyle,
b: TextStyle,
caption: TextStyle,
) {
var t1: TextStyle by mutableStateOf(t1)
private set
var t2: TextStyle by mutableStateOf(t2)
private set
var sbt1: TextStyle by mutableStateOf(sbt1)
private set
var sbt2: TextStyle by mutableStateOf(sbt2)
private set
var b: TextStyle by mutableStateOf(b)
private set
var caption: TextStyle by mutableStateOf(caption)
private set

fun copy(
t1: TextStyle = this.t1,
t2: TextStyle = this.t2,
sbt1: TextStyle = this.sbt1,
sbt2: TextStyle = this.sbt2,
b: TextStyle = this.b,
caption: TextStyle = this.caption,
): FunchTypography = FunchTypography(
t1 = t1,
t2 = t2,
sbt1 = sbt1,
sbt2 = sbt2,
b = b,
caption = caption,
)

fun update(other: FunchTypography) {
t1 = other.t1
t2 = other.t2
sbt1 = other.sbt1
sbt2 = other.sbt2
b = other.b
caption = other.caption
}
}

fun funchTypography(): FunchTypography {
return FunchTypography(
t1 = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Bold,
fontSize = 22.sp,
letterSpacing = (-0.02).em,
lineHeight = 28.6.sp
),
t2 = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
letterSpacing = (-0.02).em,
lineHeight = 26.sp
),
sbt1 = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Medium,
fontSize = 18.sp,
letterSpacing = (-0.02).em,
lineHeight = 23.4.sp
),
sbt2 = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
letterSpacing = (-0.02).sp,
lineHeight = 20.8.sp
),
b = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = (-0.03).em,
lineHeight = 21.sp
),
caption = TextStyle(
fontFamily = spoqaHanSansNeo,
fontWeight = FontWeight.Normal,
fontSize = 12.sp,
letterSpacing = (-0.03).em,
lineHeight = 18.sp
)
)
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rootProject.name = "Funch-AOS"
include(":app")

// core
//include(":core:designsystem")
include(":core:designsystem")
//include(":core:network")

// feature
Expand Down