Skip to content

Commit

Permalink
Merge pull request #6 from NOW-SOPT-APP4-KREAM/init-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jihyunniiii authored May 14, 2024
2 parents 91c96cb + 16613ce commit 17c8076
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Related issue 🛠
- closed #이슈넘버

## Work Description ✏️
- 작업 내용

Expand Down
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ android {
buildFeatures {
viewBinding = true
buildConfig = true
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.13"
}
}

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)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/org/sopt/kream/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -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)
72 changes: 72 additions & 0 deletions app/src/main/java/org/sopt/kream/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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 kreamAndroidTheme(
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,
)
}
36 changes: 36 additions & 0 deletions app/src/main/java/org/sopt/kream/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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
)
*/
)
23 changes: 19 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[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"
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"
Expand All @@ -33,14 +37,24 @@ 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" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }

# 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" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }

# Test
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand Down Expand Up @@ -78,4 +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-bom"]

0 comments on commit 17c8076

Please sign in to comment.