Skip to content

Instantly share code, notes, and snippets.

View DmytroShuba's full-sized avatar
🏠
Working from home

Dmytro DmytroShuba

🏠
Working from home
View GitHub Profile
@DmytroShuba
DmytroShuba / CustomTheme-LazyColumn.kt
Created November 10, 2021 15:36
CreateCustomTheme - LazyColumn
LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.background(AppTheme.colors.background)
) {
item {
TopAppBar(
title = {
Text(
@DmytroShuba
DmytroShuba / CustomTheme-DemoScreen.kt
Created November 10, 2021 15:35
CreateCustomTheme - DemoScreen
@Composable
fun DemoScreen(items: List<PhotographItem>) {
LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.background(AppTheme.colors.background)
) {
item {
TopAppBar(
@DmytroShuba
DmytroShuba / CustomTheme-setContent.kt
Created November 10, 2021 15:35
CreateCustomTheme - setContent
setContent {
AppTheme {
DemoScreen(items = photographItems)
}
}
@DmytroShuba
DmytroShuba / CustomTheme-AppThemeComposable.kt
Created November 10, 2021 15:34
CreateCustomTheme - AppTheme Composable
@Composable
fun AppTheme(
colors: AppColors = AppTheme.colors,
typography: AppTypography = AppTheme.typography,
dimensions: AppDimensions = AppTheme.dimensions,
content: @Composable () -> Unit
) {
// creating a new object for colors to not mutate the initial colors set when updating the values
val rememberedColors = remember { colors.copy() }.apply { updateColorsFrom(colors) }
CompositionLocalProvider(
@DmytroShuba
DmytroShuba / CustomTheme-Apptheme.kt
Created November 10, 2021 15:34
CreateCustomTheme - AppTheme
@Composable
fun AppTheme(
colors: AppColors = AppTheme.colors,
typography: AppTypography = AppTheme.typography,
dimensions: AppDimensions = AppTheme.dimensions,
content: @Composable () -> Unit
) {
...
}
@DmytroShuba
DmytroShuba / customTheme-AppDimensions.kt
Last active November 11, 2021 06:32
CreateCustomTheme - AppDimensions
data class AppDimensions(
val paddingSmall: Dp = 4.dp,
val paddingMedium: Dp = 8.dp,
val paddingLarge: Dp = 24.dp
)
internal val LocalDimensions = staticCompositionLocalOf { AppDimensions() }
@DmytroShuba
DmytroShuba / customTheme-typography.kt
Created November 10, 2021 15:14
CreateCustomTheme - Typography
private val rubik = FontFamily(
Font(R.font.rubik_regular, FontWeight.Normal)
)
private val openSans = FontFamily(
Font(R.font.open_sans_regular, FontWeight.Normal)
)
data class AppTypography(
val h1: TextStyle = TextStyle(
fontFamily = rubik,
@DmytroShuba
DmytroShuba / darkColors.kt
Created November 10, 2021 15:13
CreateCustomTheme - darkColors()
fun darkColors(
primary: Color = colorDarkPrimary,
textPrimary: Color = colorDarkTextPrimary,
textSecondary: Color = colorDarkTextSecondary,
background: Color = colorDarkBackground,
error: Color = colorDarkError
): AppColors = AppColors(
primary = primary,
textPrimary = textPrimary,
textSecondary = textSecondary,
@DmytroShuba
DmytroShuba / lightColors.kt
Created November 10, 2021 15:13
CreateCustomTheme - lightColors
fun lightColors(
primary: Color = colorLightPrimary,
textPrimary: Color = colorLightTextPrimary,
textSecondary: Color = colorLightTextSecondary,
background: Color = colorLightBackground,
error: Color = colorLightError
): AppColors = AppColors(
primary = primary,
textPrimary = textPrimary,
textSecondary = textSecondary,
@DmytroShuba
DmytroShuba / settingColors.kt
Created November 10, 2021 15:12
CreateCustomTheme - Setting colors
private val colorLightPrimary = Color(0xFFFFB400)
private val colorLightTextPrimary = Color(0xFF000000)
private val colorLightTextSecondary = Color(0xFF6C727A)
private val colorLightBackground = Color(0xFFFFFFFF)
private val colorLightError = Color(0xFFD62222)