From 8a27f3a3e11859827b0c51a7afd093aa5b6414bc Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 14 May 2024 03:08:37 +0900 Subject: [PATCH 1/5] [init] #5 compose setting --- app/build.gradle.kts | 7 ++ .../main/java/org/sopt/kream/theme/Color.kt | 11 +++ .../main/java/org/sopt/kream/theme/Theme.kt | 70 +++++++++++++++++++ .../main/java/org/sopt/kream/theme/Type.kt | 34 +++++++++ gradle/libs.versions.toml | 20 +++++- 5 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/sopt/kream/theme/Color.kt create mode 100644 app/src/main/java/org/sopt/kream/theme/Theme.kt create mode 100644 app/src/main/java/org/sopt/kream/theme/Type.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7c05323..fb2f6f0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,6 +48,7 @@ android { buildFeatures { viewBinding = true buildConfig = true + compose = true } } @@ -55,6 +56,12 @@ dependencies { implementation(libs.bundles.androidx) + implementation(libs.bundles.compose) + + // Compose + debugImplementation(libs.compose.ui.tooling) + debugImplementation(libs.compose.ui.test.manifest) + // Test testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) diff --git a/app/src/main/java/org/sopt/kream/theme/Color.kt b/app/src/main/java/org/sopt/kream/theme/Color.kt new file mode 100644 index 0000000..b2ad018 --- /dev/null +++ b/app/src/main/java/org/sopt/kream/theme/Color.kt @@ -0,0 +1,11 @@ +package org.sopt.kream.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/app/src/main/java/org/sopt/kream/theme/Theme.kt b/app/src/main/java/org/sopt/kream/theme/Theme.kt new file mode 100644 index 0000000..4a2d0a6 --- /dev/null +++ b/app/src/main/java/org/sopt/kream/theme/Theme.kt @@ -0,0 +1,70 @@ +package org.sopt.kream.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun NOWSOPTAndroidTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/kream/theme/Type.kt b/app/src/main/java/org/sopt/kream/theme/Type.kt new file mode 100644 index 0000000..9fc1462 --- /dev/null +++ b/app/src/main/java/org/sopt/kream/theme/Type.kt @@ -0,0 +1,34 @@ +package org.sopt.kream.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index de38caf..feea844 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,6 +12,7 @@ activity = "1.9.0" constraintlayout = "2.1.4" fragment = "1.7.0" navigation = "2.7.7" +material3Android = "1.2.1" # Test junit = "4.13.2" @@ -33,14 +34,26 @@ retrofitKotlinSerializationConverter = "1.0.0" kotlin-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinSerializationJson" } kotlin-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } -# AdnroidX +# Compose +compose-ui = { group = "androidx.compose.ui", name = "ui" } +compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +compose-meterial3 = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" } +compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } + +# AndroidX androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-fragment = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" } -androidx-navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation"} -androidx-navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation"} +androidx-navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation" } +androidx-navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation" } + +# Compose Androidx +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" } + # Test junit = { group = "junit", name = "junit", version.ref = "junit" } @@ -78,4 +91,5 @@ androidx = [ ] okhttp = ["okhttp", "okhttp-logging-interceptor"] retrofit = ["retrofit", "retrofit-kotlin-serialization-converter"] +compose = ["androidx-activity-compose", "compose-ui", "compose-ui-graphics", "compose-ui-tooling-preview", "compose-meterial3"] From ee34b190f2361d4ee48b8860a71949a73a4f6ef7 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 14 May 2024 03:09:04 +0900 Subject: [PATCH 2/5] [chore] #5 ktlintFormat --- .../main/java/org/sopt/kream/theme/Color.kt | 2 +- .../main/java/org/sopt/kream/theme/Theme.kt | 48 ++++++++++--------- .../main/java/org/sopt/kream/theme/Type.kt | 22 +++++---- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/org/sopt/kream/theme/Color.kt b/app/src/main/java/org/sopt/kream/theme/Color.kt index b2ad018..0c82203 100644 --- a/app/src/main/java/org/sopt/kream/theme/Color.kt +++ b/app/src/main/java/org/sopt/kream/theme/Color.kt @@ -8,4 +8,4 @@ val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) -val Pink40 = Color(0xFF7D5260) \ No newline at end of file +val Pink40 = Color(0xFF7D5260) diff --git a/app/src/main/java/org/sopt/kream/theme/Theme.kt b/app/src/main/java/org/sopt/kream/theme/Theme.kt index 4a2d0a6..d356bf5 100644 --- a/app/src/main/java/org/sopt/kream/theme/Theme.kt +++ b/app/src/main/java/org/sopt/kream/theme/Theme.kt @@ -15,17 +15,18 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat -private val DarkColorScheme = darkColorScheme( - primary = Purple80, - secondary = PurpleGrey80, - tertiary = Pink80 -) - -private val LightColorScheme = lightColorScheme( - primary = Purple40, - secondary = PurpleGrey40, - tertiary = Pink40 +private val DarkColorScheme = + darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80, + ) +private val LightColorScheme = + lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40, /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), @@ -34,25 +35,26 @@ private val LightColorScheme = lightColorScheme( onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), - */ -) + */ + ) @Composable fun NOWSOPTAndroidTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { - val colorScheme = when { - dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { - val context = LocalContext.current - if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) - } + val colorScheme = + when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } - darkTheme -> DarkColorScheme - else -> LightColorScheme - } + darkTheme -> DarkColorScheme + else -> LightColorScheme + } val view = LocalView.current if (!view.isInEditMode) { SideEffect { @@ -65,6 +67,6 @@ fun NOWSOPTAndroidTheme( MaterialTheme( colorScheme = colorScheme, typography = Typography, - content = content + content = content, ) -} \ No newline at end of file +} diff --git a/app/src/main/java/org/sopt/kream/theme/Type.kt b/app/src/main/java/org/sopt/kream/theme/Type.kt index 9fc1462..405a984 100644 --- a/app/src/main/java/org/sopt/kream/theme/Type.kt +++ b/app/src/main/java/org/sopt/kream/theme/Type.kt @@ -7,14 +7,16 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp // Set of Material typography styles to start with -val Typography = Typography( - bodyLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ) +val Typography = + Typography( + bodyLarge = + TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp, + ), /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, @@ -30,5 +32,5 @@ val Typography = Typography( lineHeight = 16.sp, letterSpacing = 0.5.sp ) - */ -) \ No newline at end of file + */ + ) From 041dcdaaba85d8b53b3fbb82f772ad9bc3be20e7 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 14 May 2024 03:11:20 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[chore]=20#5=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/org/sopt/kream/theme/Theme.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/sopt/kream/theme/Theme.kt b/app/src/main/java/org/sopt/kream/theme/Theme.kt index d356bf5..64b687c 100644 --- a/app/src/main/java/org/sopt/kream/theme/Theme.kt +++ b/app/src/main/java/org/sopt/kream/theme/Theme.kt @@ -39,7 +39,7 @@ private val LightColorScheme = ) @Composable -fun NOWSOPTAndroidTheme( +fun kreamAndroidTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, From 850cc171d17389bfff2f83bacf9a68be9533dccb Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 14 May 2024 03:33:55 +0900 Subject: [PATCH 4/5] [feat] #5 compose-bom --- app/build.gradle.kts | 3 +++ gradle/libs.versions.toml | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fb2f6f0..826eddf 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -50,6 +50,9 @@ android { buildConfig = true compose = true } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.13" + } } dependencies { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index feea844..df915a5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,13 @@ [versions] # Kotlin agp = "8.3.2" -kotlin = "1.9.20" +kotlin = "1.9.23" kotlinSerializationJson = "1.5.1" kotlinxCoroutines = "1.7.3" +# Compose +composeBom = "2024.05.00" + # AndroidX appcompat = "1.6.1" coreKtx = "1.13.1" @@ -41,6 +44,7 @@ compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling compose-meterial3 = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" } compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } # AndroidX androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -50,11 +54,8 @@ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "const androidx-fragment = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" } androidx-navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation" } androidx-navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation" } - -# Compose Androidx androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" } - # Test junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } @@ -91,5 +92,5 @@ androidx = [ ] okhttp = ["okhttp", "okhttp-logging-interceptor"] retrofit = ["retrofit", "retrofit-kotlin-serialization-converter"] -compose = ["androidx-activity-compose", "compose-ui", "compose-ui-graphics", "compose-ui-tooling-preview", "compose-meterial3"] +compose = ["androidx-activity-compose", "compose-ui", "compose-ui-graphics", "compose-ui-tooling-preview", "compose-meterial3", "compose-bom"] From 16613ce223aa717465713c0cb0893703e232de2b Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 14 May 2024 03:36:06 +0900 Subject: [PATCH 5/5] [docs] #5 update pull_request_template.md --- .github/pull_request_template.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9ac5b4d..d21578a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,6 @@ +## Related issue 🛠 +- closed #이슈넘버 + ## Work Description ✏️ - 작업 내용