Skip to content

Commit d11477b

Browse files
committed
setup compose ui: Color, Theme and Type(#1)
1 parent ed5d446 commit d11477b

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.example.cfseeker.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
// Material3 Light Theme Colors
6+
val md_theme_light_primary = Color(0xFF6750A4)
7+
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
8+
val md_theme_light_primaryContainer = Color(0xFFEADDFF)
9+
val md_theme_light_onPrimaryContainer = Color(0xFF21005D)
10+
11+
val md_theme_light_secondary = Color(0xFF625B71)
12+
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
13+
val md_theme_light_secondaryContainer = Color(0xFFE8DEF8)
14+
val md_theme_light_onSecondaryContainer = Color(0xFF1D192B)
15+
16+
val md_theme_light_error = Color(0xFFB3261E)
17+
val md_theme_light_onError = Color(0xFFFFFFFF)
18+
val md_theme_light_errorContainer = Color(0xFFF9DEDC)
19+
val md_theme_light_onErrorContainer = Color(0xFF410E0B)
20+
21+
val md_theme_light_background = Color(0xFFFFFBFE)
22+
val md_theme_light_onBackground = Color(0xFF1C1B1F)
23+
val md_theme_light_surface = Color(0xFFFFFBFE)
24+
val md_theme_light_onSurface = Color(0xFF1C1B1F)
25+
val md_theme_light_surfaceVariant = Color(0xFFE7E0EC)
26+
val md_theme_light_onSurfaceVariant = Color(0xFF49454F)
27+
28+
// Material3 Dark Theme Colors
29+
val md_theme_dark_primary = Color(0xFFD0BCFF)
30+
val md_theme_dark_onPrimary = Color(0xFF381E72)
31+
val md_theme_dark_primaryContainer = Color(0xFF4F378B)
32+
val md_theme_dark_onPrimaryContainer = Color(0xFFEADDFF)
33+
34+
val md_theme_dark_secondary = Color(0xFFCCC2DC)
35+
val md_theme_dark_onSecondary = Color(0xFF332D41)
36+
val md_theme_dark_secondaryContainer = Color(0xFF4A4458)
37+
val md_theme_dark_onSecondaryContainer = Color(0xFFE8DEF8)
38+
39+
val md_theme_dark_error = Color(0xFFF2B8B5)
40+
val md_theme_dark_onError = Color(0xFF601410)
41+
val md_theme_dark_errorContainer = Color(0xFF8C1D18)
42+
val md_theme_dark_onErrorContainer = Color(0xFFF9DEDC)
43+
44+
val md_theme_dark_background = Color(0xFF1C1B1F)
45+
val md_theme_dark_onBackground = Color(0xFFE6E1E5)
46+
val md_theme_dark_surface = Color(0xFF1C1B1F)
47+
val md_theme_dark_onSurface = Color(0xFFE6E1E5)
48+
val md_theme_dark_surfaceVariant = Color(0xFF49454F)
49+
val md_theme_dark_onSurfaceVariant = Color(0xFFCAC4D0)
50+
51+
// Custom colors for rating changes
52+
val RatingPositive = Color(0xFF4CAF50) // Green for positive rating change
53+
val RatingNegative = Color(0xFFF44336) // Red for negative rating change
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.example.cfseeker.ui.theme
2+
3+
import android.app.Activity
4+
import androidx.compose.foundation.isSystemInDarkTheme
5+
import androidx.compose.material3.MaterialTheme
6+
import androidx.compose.material3.darkColorScheme
7+
import androidx.compose.material3.lightColorScheme
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.runtime.SideEffect
10+
import androidx.compose.ui.graphics.toArgb
11+
import androidx.compose.ui.platform.LocalView
12+
import androidx.core.view.WindowCompat
13+
14+
private val LightColorScheme = lightColorScheme(
15+
primary = md_theme_light_primary,
16+
onPrimary = md_theme_light_onPrimary,
17+
primaryContainer = md_theme_light_primaryContainer,
18+
onPrimaryContainer = md_theme_light_onPrimaryContainer,
19+
secondary = md_theme_light_secondary,
20+
onSecondary = md_theme_light_onSecondary,
21+
secondaryContainer = md_theme_light_secondaryContainer,
22+
onSecondaryContainer = md_theme_light_onSecondaryContainer,
23+
error = md_theme_light_error,
24+
onError = md_theme_light_onError,
25+
errorContainer = md_theme_light_errorContainer,
26+
onErrorContainer = md_theme_light_onErrorContainer,
27+
background = md_theme_light_background,
28+
onBackground = md_theme_light_onBackground,
29+
surface = md_theme_light_surface,
30+
onSurface = md_theme_light_onSurface,
31+
surfaceVariant = md_theme_light_surfaceVariant,
32+
onSurfaceVariant = md_theme_light_onSurfaceVariant,
33+
)
34+
35+
private val DarkColorScheme = darkColorScheme(
36+
primary = md_theme_dark_primary,
37+
onPrimary = md_theme_dark_onPrimary,
38+
primaryContainer = md_theme_dark_primaryContainer,
39+
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
40+
secondary = md_theme_dark_secondary,
41+
onSecondary = md_theme_dark_onSecondary,
42+
secondaryContainer = md_theme_dark_secondaryContainer,
43+
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
44+
error = md_theme_dark_error,
45+
onError = md_theme_dark_onError,
46+
errorContainer = md_theme_dark_errorContainer,
47+
onErrorContainer = md_theme_dark_onErrorContainer,
48+
background = md_theme_dark_background,
49+
onBackground = md_theme_dark_onBackground,
50+
surface = md_theme_dark_surface,
51+
onSurface = md_theme_dark_onSurface,
52+
surfaceVariant = md_theme_dark_surfaceVariant,
53+
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
54+
)
55+
56+
@Composable
57+
fun CFSeekerTheme(
58+
darkTheme: Boolean = isSystemInDarkTheme(),
59+
content: @Composable () -> Unit
60+
) {
61+
val colorScheme = when {
62+
darkTheme -> DarkColorScheme
63+
else -> LightColorScheme
64+
}
65+
66+
val view = LocalView.current
67+
if (!view.isInEditMode) {
68+
SideEffect {
69+
val window = (view.context as Activity).window
70+
window.statusBarColor = colorScheme.primary.toArgb()
71+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
72+
}
73+
}
74+
75+
MaterialTheme(
76+
colorScheme = colorScheme,
77+
typography = Typography,
78+
content = content
79+
)
80+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.example.cfseeker.ui.theme
2+
3+
import androidx.compose.material3.Typography
4+
import androidx.compose.ui.text.TextStyle
5+
import androidx.compose.ui.text.font.FontFamily
6+
import androidx.compose.ui.text.font.FontWeight
7+
import androidx.compose.ui.unit.sp
8+
9+
val Typography = Typography(
10+
titleMedium = TextStyle(
11+
fontFamily = FontFamily.Default,
12+
fontWeight = FontWeight.Bold,
13+
fontSize = 16.sp,
14+
lineHeight = 24.sp,
15+
letterSpacing = 0.15.sp
16+
),
17+
18+
titleSmall = TextStyle(
19+
fontFamily = FontFamily.Default,
20+
fontWeight = FontWeight.Bold,
21+
fontSize = 16.sp,
22+
lineHeight = 20.sp,
23+
letterSpacing = 0.1.sp
24+
),
25+
26+
bodyLarge = TextStyle(
27+
fontFamily = FontFamily.Default,
28+
fontWeight = FontWeight.Normal,
29+
fontSize = 14.sp,
30+
lineHeight = 20.sp,
31+
letterSpacing = 0.25.sp
32+
),
33+
34+
bodySmall = TextStyle(
35+
fontFamily = FontFamily.Default,
36+
fontWeight = FontWeight.Normal,
37+
fontSize = 12.sp,
38+
lineHeight = 16.sp,
39+
letterSpacing = 0.4.sp
40+
)
41+
)

0 commit comments

Comments
 (0)