Skip to content

Commit cc7a3d3

Browse files
authored
[Feat] Compose ์„ธํŒ… (#270)
* feat: compose gradle ์„ธํŒ… * feat: compose gradle ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ ๋ฐ lib์œผ๋กœ ์ด๋™ * [feat] compose color ์„ธํŒ… * [feat] compose color, theme, typo, style ์„ธํŒ… * [feat] compose material3 gradle ์ถ”๊ฐ€ * [feat] compose kotlinCompilerExtensionVersion ์ถ”๊ฐ€ * feat: ํŒจํ‚ค์ง€๋ช… ์ˆ˜์ • * feat: ํ•จ์ˆ˜๋ช… ์ˆ˜์ • * [feat] compose ComposeExample ํ™•์ธ
1 parent 9fc615f commit cc7a3d3

File tree

6 files changed

+298
-0
lines changed

6 files changed

+298
-0
lines changed

โ€Žapp/build.gradle.kts

+23
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ android {
3232
buildConfig = true
3333
viewBinding = true
3434
dataBinding = true
35+
compose = true
3536
}
3637

3738
buildTypes {
@@ -78,6 +79,10 @@ android {
7879
jvmTarget = "17"
7980
}
8081

82+
composeOptions {
83+
kotlinCompilerExtensionVersion = "1.4.4"
84+
}
85+
8186
splits {
8287
abi {
8388
isEnable = true
@@ -155,6 +160,24 @@ dependencies {
155160

156161
// OSS
157162
implementation(libs.oss.licenses)
163+
164+
// Compose
165+
implementation(libs.androidx.activity.compose)
166+
implementation(libs.androidx.animation)
167+
implementation(libs.androidx.ui.tooling)
168+
implementation(libs.androidx.lifecycle.viewmodel.compose)
169+
implementation(libs.androidx.lifecycle.runtime.ktx.v252)
170+
implementation(libs.compose.bom)
171+
implementation(libs.androidx.ui)
172+
implementation(libs.androidx.ui.graphics)
173+
implementation(libs.androidx.ui.tooling.preview)
174+
implementation(libs.androidx.material3)
175+
androidTestImplementation(libs.androidx.ui.test.junit4)
176+
implementation(libs.compose.theme.adapter)
177+
implementation(libs.accompanist.appcompat.theme)
178+
androidTestImplementation(libs.compose.bom)
179+
debugImplementation(libs.androidx.ui.test.manifest)
180+
158181
}
159182

160183
kapt {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.eatssu.android.presentation
2+
3+
import androidx.compose.material3.Text
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.ui.tooling.preview.Preview
6+
import com.eatssu.android.presentation.compose.ui.theme.EatssuTheme
7+
import com.eatssu.android.presentation.compose.ui.theme.Primary
8+
import com.google.firebase.annotations.concurrent.Background
9+
10+
@Composable
11+
fun ComposeExample() {
12+
Text(
13+
text = "Hello, Eatssu!",
14+
style = EatssuTheme.typography.body1,
15+
color = Primary
16+
)
17+
}
18+
19+
@Preview(showBackground = true)
20+
@Composable
21+
fun ComposeExamplePreview() {
22+
EatssuTheme {
23+
ComposeExample()
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.eatssu.android.presentation.compose.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
// Gray Scale
6+
val White = Color(0xFFFFFFFF)
7+
val Black = Color(0xFF000000)
8+
val Gray100 = Color(0xFFFAFAFB)
9+
val Gray200 = Color(0xFFF0F0F0)
10+
val Gray300 = Color(0xFFDEDEDE)
11+
val Gray400 = Color(0xFFA8A8A8)
12+
val Gray500 = Color(0xFF9D9D9D)
13+
val Gray600 = Color(0xFF565656)
14+
val Gray700 = Color(0xFF1F1F1F)
15+
16+
// Brand
17+
val Primary = Color(0xFF66D4C2)
18+
val Secondary = Color(0xFFEEFBF8)
19+
val Star = Color(0xFFFFC700)
20+
val Error = Color(0xFFFF3F3F)
21+
22+
// Special
23+
val KakaoLogin = Color(0xFFFEE500)
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.eatssu.android.presentation.compose.ui.theme
2+
3+
import android.app.Activity
4+
import androidx.compose.material3.MaterialTheme
5+
import androidx.compose.material3.Typography
6+
import androidx.compose.material3.lightColorScheme
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.CompositionLocalProvider
9+
import androidx.compose.runtime.SideEffect
10+
import androidx.compose.runtime.remember
11+
import androidx.compose.runtime.staticCompositionLocalOf
12+
import androidx.compose.ui.graphics.toArgb
13+
import androidx.compose.ui.platform.LocalView
14+
import androidx.core.view.WindowCompat
15+
16+
// Color ์„ค์ •
17+
private val LightColorScheme = lightColorScheme(
18+
primary = Primary,
19+
onPrimary = White,
20+
secondary = Secondary,
21+
onSecondary = Black,
22+
background = White,
23+
surface = White,
24+
onSurface = Black,
25+
error = Error
26+
)
27+
28+
// Typography ์„ค์ •
29+
private val LocalEatssuTypography = staticCompositionLocalOf<EatssuTypography> {
30+
error("No EatssuTypography provided")
31+
}
32+
33+
object EatssuTheme {
34+
val typography: EatssuTypography
35+
@Composable get() = LocalEatssuTypography.current
36+
}
37+
38+
@Composable
39+
fun ProvideEatssuTypography(typography: EatssuTypography, content: @Composable () -> Unit) {
40+
val provideTypography = remember { typography.copy() }
41+
CompositionLocalProvider(
42+
LocalEatssuTypography provides provideTypography,
43+
content = content
44+
)
45+
}
46+
47+
@Composable
48+
fun EatssuTheme(
49+
content: @Composable () -> Unit,
50+
) {
51+
val colorScheme = LightColorScheme
52+
val typography = eatssuTypography()
53+
54+
// set status bar & navigation bar color
55+
val view = LocalView.current
56+
if (!view.isInEditMode) {
57+
SideEffect {
58+
val window = (view.context as Activity).window
59+
window.statusBarColor = White.toArgb()
60+
window.navigationBarColor = White.toArgb()
61+
62+
WindowCompat.getInsetsController(window, view)
63+
.isAppearanceLightStatusBars = true
64+
WindowCompat.getInsetsController(window, view)
65+
.isAppearanceLightNavigationBars = true
66+
}
67+
}
68+
69+
ProvideEatssuTypography(typography) {
70+
MaterialTheme(
71+
colorScheme = colorScheme,
72+
typography = Typography(
73+
displayLarge = typography.headingPrimary,
74+
displayMedium = typography.headingSecondary,
75+
headlineLarge = typography.subtitle1,
76+
headlineMedium = typography.subtitle2,
77+
bodyLarge = typography.body1,
78+
bodyMedium = typography.body2,
79+
bodySmall = typography.body3,
80+
labelLarge = typography.caption1,
81+
labelMedium = typography.caption2,
82+
labelSmall = typography.button1
83+
),
84+
content = content
85+
)
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.eatssu.android.presentation.compose.ui.theme
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.Stable
5+
import androidx.compose.ui.text.TextStyle
6+
import androidx.compose.ui.text.font.Font
7+
import androidx.compose.ui.text.font.FontFamily
8+
import androidx.compose.ui.text.font.FontWeight
9+
import androidx.compose.ui.text.style.LineHeightStyle
10+
import androidx.compose.ui.unit.TextUnit
11+
import androidx.compose.ui.unit.sp
12+
import com.eatssu.android.R
13+
14+
// ํฐํŠธ ํŒจ๋ฐ€๋ฆฌ ์„ค์ •
15+
val pretendardBold = FontFamily(Font(R.font.pretendard_bold, FontWeight.Bold))
16+
val pretendardMedium = FontFamily(Font(R.font.pretendard_medium, FontWeight.Medium))
17+
val pretendardSemiBold = FontFamily(Font(R.font.pretendard_semibold, FontWeight.SemiBold))
18+
val pretendardRegular = FontFamily(Font(R.font.pretendard_regular, FontWeight.Normal))
19+
20+
@Stable
21+
class EatssuTypography internal constructor(
22+
val button1: TextStyle,
23+
val button2: TextStyle,
24+
val headingPrimary: TextStyle,
25+
val headingSecondary: TextStyle,
26+
val subtitle1: TextStyle,
27+
val subtitle2: TextStyle,
28+
val body1: TextStyle,
29+
val body2: TextStyle,
30+
val body3: TextStyle,
31+
val caption1: TextStyle,
32+
val caption2: TextStyle,
33+
) {
34+
fun copy(): EatssuTypography = EatssuTypography(
35+
button1, button2, headingPrimary, headingSecondary, subtitle1, subtitle2, body1, body2, body3, caption1, caption2
36+
)
37+
}
38+
39+
fun EatssuTextStyle(
40+
fontFamily: FontFamily,
41+
fontWeight: FontWeight = FontWeight.Normal,
42+
fontSize: TextUnit,
43+
lineHeight: TextUnit,
44+
): TextStyle = TextStyle(
45+
fontFamily = fontFamily,
46+
fontWeight = fontWeight,
47+
fontSize = fontSize,
48+
lineHeight = lineHeight,
49+
lineHeightStyle = LineHeightStyle(
50+
alignment = LineHeightStyle.Alignment.Center,
51+
trim = LineHeightStyle.Trim.None
52+
)
53+
)
54+
55+
@Composable
56+
fun eatssuTypography(): EatssuTypography {
57+
return EatssuTypography(
58+
button1 = EatssuTextStyle(
59+
fontFamily = pretendardBold,
60+
fontSize = 18.sp,
61+
lineHeight = 24.sp
62+
),
63+
button2 = EatssuTextStyle(
64+
fontFamily = pretendardBold,
65+
fontSize = 14.sp,
66+
lineHeight = 20.sp
67+
),
68+
headingPrimary = EatssuTextStyle(
69+
fontFamily = pretendardBold,
70+
fontSize = 20.sp,
71+
lineHeight = 30.sp
72+
),
73+
headingSecondary = EatssuTextStyle(
74+
fontFamily = pretendardBold,
75+
fontSize = 18.sp,
76+
lineHeight = 28.sp
77+
),
78+
subtitle1 = EatssuTextStyle(
79+
fontFamily = pretendardSemiBold,
80+
fontSize = 16.sp,
81+
lineHeight = 24.sp
82+
),
83+
subtitle2 = EatssuTextStyle(
84+
fontFamily = pretendardSemiBold,
85+
fontSize = 16.sp,
86+
lineHeight = 22.sp
87+
),
88+
body1 = EatssuTextStyle(
89+
fontFamily = pretendardRegular,
90+
fontSize = 16.sp,
91+
lineHeight = 24.sp
92+
),
93+
body2 = EatssuTextStyle(
94+
fontFamily = pretendardRegular,
95+
fontSize = 14.sp,
96+
lineHeight = 20.sp
97+
),
98+
body3 = EatssuTextStyle(
99+
fontFamily = pretendardRegular,
100+
fontSize = 14.sp,
101+
lineHeight = 18.sp
102+
),
103+
caption1 = EatssuTextStyle(
104+
fontFamily = pretendardBold,
105+
fontSize = 12.sp,
106+
lineHeight = 16.sp
107+
),
108+
caption2 = EatssuTextStyle(
109+
fontFamily = pretendardMedium,
110+
fontSize = 12.sp,
111+
lineHeight = 16.sp
112+
)
113+
)
114+
}

โ€Žgradle/libs.versions.toml

+25
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
[versions]
2+
accompanistAppcompatTheme = "0.16.0"
3+
activityCompose = "1.9.2"
24
android = "8.6.1"
35
androidx-core = "1.7.0"
46
androidx-appcompat = "1.6.1"
7+
animation = "1.7.8"
8+
composeBomVersion = "2025.03.00"
9+
composeThemeAdapter = "1.2.1"
10+
lifecycleRuntimeKtx = "2.5.2"
11+
lifecycleViewmodelCompose = "2.8.7"
512
material = "1.8.0"
613
constraintlayout = "2.1.4"
14+
materialVersion = "1.7.8"
715
threetenabp = "1.4.4"
816
material-calendarview = "1.4.3"
917
recyclerview = "1.3.2"
@@ -35,10 +43,27 @@ google-services = "4.4.2"
3543
kotlin-android = "1.8.10"
3644
ossLicenses = "17.1.0"
3745
ossLicensesPlugin = "0.10.4"
46+
uiTestJunit4 = "1.7.8"
47+
uiTooling = "1.7.8"
48+
compose-material3 = "1.3.1"
3849

3950
[libraries]
51+
accompanist-appcompat-theme = { module = "com.google.accompanist:accompanist-appcompat-theme", version.ref = "accompanistAppcompatTheme" }
52+
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
53+
androidx-animation = { module = "androidx.compose.animation:animation", version.ref = "animation" }
4054
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" }
4155
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
56+
androidx-lifecycle-runtime-ktx-v252 = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
57+
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
58+
androidx-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
59+
androidx-ui = { module = "androidx.compose.ui:ui" }
60+
androidx-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
61+
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "uiTestJunit4" }
62+
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
63+
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "uiTooling" }
64+
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
65+
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBomVersion" }
66+
compose-theme-adapter = { module = "com.google.android.material:compose-theme-adapter", version.ref = "composeThemeAdapter" }
4267
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
4368
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
4469
threetenabp = { group = "com.jakewharton.threetenabp", name = "threetenabp", version.ref = "threetenabp" }

0 commit comments

Comments
ย (0)