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] Theme 기초 세팅 #18

Merged
merged 7 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package org.sopt.dateroad.presentation.type

import androidx.compose.ui.graphics.Color
import org.sopt.dateroad.ui.theme.Black
import org.sopt.dateroad.ui.theme.DeepPurple
import org.sopt.dateroad.ui.theme.Gray400
import org.sopt.dateroad.ui.theme.White
import org.sopt.dateroad.ui.theme.defaultDateRoadColors

enum class PointBoxType(
backgroundColor: Color,
titleTextColor: Color,
pointTextColor: Color
) {
POINT_HISTORY(
backgroundColor = DeepPurple,
titleTextColor = White,
pointTextColor = White
backgroundColor = defaultDateRoadColors.deepPurple,
titleTextColor = defaultDateRoadColors.white,
pointTextColor = defaultDateRoadColors.white
),
MY_PAGE(
backgroundColor = White,
titleTextColor = Gray400,
pointTextColor = Black
backgroundColor = defaultDateRoadColors.white,
titleTextColor = defaultDateRoadColors.gray400,
pointTextColor = defaultDateRoadColors.black
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -25,6 +23,7 @@ import org.sopt.dateroad.presentation.util.context.showToast
import org.sopt.dateroad.presentation.util.modifier.noRippleClickable
import org.sopt.dateroad.presentation.util.view.UiState
import org.sopt.dateroad.ui.theme.DATEROADTheme
import org.sopt.dateroad.ui.theme.DateRoadTheme

@Composable
fun DummyRoute(
Expand Down Expand Up @@ -82,8 +81,8 @@ fun DummyScreen(
) {
Text(
text = email,
fontSize = 30.sp,
fontWeight = Bold
color = DateRoadTheme.colors.deepPurple,
style = DateRoadTheme.typography.titleExtra24
)
}
}
Expand Down
55 changes: 55 additions & 0 deletions app/src/main/java/org/sopt/dateroad/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sopt.dateroad.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color

// Main
Expand All @@ -24,3 +26,56 @@ val White = Color(0xFFFFFFFF)

// Notif
val AlertRed = Color(0xFFFF0000)

@Immutable
data class DateRoadColors(
// Main
val deepPurple: Color,
val mediumPurple: Color,
val lightPurple: Color,
val lilac: Color,
val lightPink: Color,
val pink: Color,
val lime: Color,
val lightLime: Color,

// GrayScale
val black: Color,
val gray600: Color,
val gray500: Color,
val gray400: Color,
val gray300: Color,
val gray200: Color,
val gray100: Color,
val white: Color,

// Notif
val alertRed: Color
)

val defaultDateRoadColors = DateRoadColors(
// Main
deepPurple = DeepPurple,
mediumPurple = MediumPurple,
lightPurple = LightPurple,
lilac = Lilac,
lightPink = LightPink,
pink = Pink,
lime = Lime,
lightLime = LightLime,

// GrayScale
black = Black,
gray600 = Gray600,
gray500 = Gray500,
gray400 = Gray400,
gray300 = Gray300,
gray200 = Gray200,
gray100 = Gray100,
white = White,

// Notif
alertRed = AlertRed
)

val LocalDateRoadColors = staticCompositionLocalOf { defaultDateRoadColors }
84 changes: 43 additions & 41 deletions app/src/main/java/org/sopt/dateroad/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
package org.sopt.dateroad.ui.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import android.app.Activity
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
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
primary = Pink,
secondary = MediumPurple,
tertiary = Lilac
)
object DateRoadTheme {
val colors: DateRoadColors
@Composable
@ReadOnlyComposable
get() = LocalDateRoadColors.current

private val LightColorScheme = lightColorScheme(
primary = Pink,
secondary = MediumPurple,
tertiary = Lilac
val typography: DateRoadTypography
@Composable
@ReadOnlyComposable
get() = LocalDateRoadTypography.current
}

/* 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 ProvideDateRoadColorsAndTypography(
colors: DateRoadColors,
typography: DateRoadTypography,
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalDateRoadColors provides colors,
LocalDateRoadTypography provides typography,
content = content
)
}

@Composable
fun DATEROADTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
backgroundColor: Color = defaultDateRoadColors.white,
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)
ProvideDateRoadColorsAndTypography(colors = defaultDateRoadColors, typography = defaultDateRoadTypography) {
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.run {
statusBarColor = backgroundColor.toArgb()
WindowCompat.getInsetsController(this, view).isAppearanceLightStatusBars = true
}
}
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
MaterialTheme(
content = content
)
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
Loading
Loading