From 256186700ba714bb9b3428503afedc31b3c8f2c0 Mon Sep 17 00:00:00 2001 From: Jihye Joo Date: Wed, 15 Jan 2025 14:26:03 +0900 Subject: [PATCH] =?UTF-8?q?setting:=20=EC=BB=B4=ED=8F=AC=EC=A6=88=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=20=EC=85=8B=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 25 ++++++++ .../com/hrhn/presentation/ui/theme/Color.kt | 11 ++++ .../com/hrhn/presentation/ui/theme/Theme.kt | 57 +++++++++++++++++++ .../com/hrhn/presentation/ui/theme/Type.kt | 34 +++++++++++ gradle/libs.versions.toml | 14 +++++ 5 files changed, 141 insertions(+) create mode 100644 app/src/main/java/com/hrhn/presentation/ui/theme/Color.kt create mode 100644 app/src/main/java/com/hrhn/presentation/ui/theme/Theme.kt create mode 100644 app/src/main/java/com/hrhn/presentation/ui/theme/Type.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d8a6142..e986c8f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,6 +20,9 @@ android { setProperty("archivesBaseName", "HRHN-v${versionName}(${versionCode})") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } } bundle { storeArchive { @@ -38,6 +41,7 @@ android { buildFeatures { dataBinding = true viewBinding = true + compose = true } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 @@ -46,6 +50,14 @@ android { kotlinOptions { jvmTarget = "17" } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.1" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } } dependencies { @@ -60,6 +72,19 @@ dependencies { implementation(libs.androidx.paging.runtime.ktx) implementation(libs.androidx.swiperefreshlayout) implementation(libs.hilt.android) + + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) + kapt(libs.hilt.android.compiler) implementation(libs.androidx.room.ktx) implementation(libs.androidx.room.runtime) diff --git a/app/src/main/java/com/hrhn/presentation/ui/theme/Color.kt b/app/src/main/java/com/hrhn/presentation/ui/theme/Color.kt new file mode 100644 index 0000000..a88f1f7 --- /dev/null +++ b/app/src/main/java/com/hrhn/presentation/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.hrhn.presentation.ui.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) diff --git a/app/src/main/java/com/hrhn/presentation/ui/theme/Theme.kt b/app/src/main/java/com/hrhn/presentation/ui/theme/Theme.kt new file mode 100644 index 0000000..781492d --- /dev/null +++ b/app/src/main/java/com/hrhn/presentation/ui/theme/Theme.kt @@ -0,0 +1,57 @@ +package com.hrhn.presentation.ui.theme + +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.ui.platform.LocalContext + +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 HRHNTheme( + 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 + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} diff --git a/app/src/main/java/com/hrhn/presentation/ui/theme/Type.kt b/app/src/main/java/com/hrhn/presentation/ui/theme/Type.kt new file mode 100644 index 0000000..127a1da --- /dev/null +++ b/app/src/main/java/com/hrhn/presentation/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.hrhn.presentation.ui.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 + ) + */ +) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index da57e00..ac88329 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,10 @@ preference-ktx = "1.2.1" room-ktx = "2.6.1" swiperefreshlayout = "1.1.0" +composeBom = "2024.10.01" +lifecycleRuntimeKtx = "2.8.4" +activityCompose = "1.9.1" + [libraries] androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } @@ -35,6 +39,16 @@ hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt- hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt-android" } junit = { module = "junit:junit", version.ref = "junit" } material = { module = "com.google.android.material:material", version.ref = "material" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } +androidx-material3 = { group = "androidx.compose.material3", name = "material3" } [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }