Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#7-custom_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwon12 authored Jan 10, 2025
2 parents 4fef5ff + 18fc38c commit ef25124
Show file tree
Hide file tree
Showing 6 changed files with 495 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ android {

dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity.compose)
}

123 changes: 123 additions & 0 deletions core/designsystem/src/main/java/com/yapp/designsystem/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.yapp.designsystem.theme

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

internal val LightColorScheme = YappColorScheme(
primaryNormal = Color(0xFFFA6027),

labelNormal = Color(0xFF171719),
labelStrong = Color(0xFF000000),
labelNeutral = Color(0xE02E2F33),
labelAlternative = Color(0x9C37383C),
labelAssistive = Color(0x4737383C),
labelDisable = Color(0x2937383C),

backgroundNormalNormal = Color(0xFFFFFFFF),
backgroundNormalAlternative = Color(0xFFF7F7F8),
backgroundElevatedNormal = Color(0xFFFFFFFF),
backgroundElevatedAlternative = Color(0xFFF7F7F8),

interactionInactive = Color(0xFF989BA2),
interactionDisable = Color(0xFFF4F4F5),

lineNormalNormal = Color(0x3870737C),
lineNormalNeutral = Color(0x2970737C),
lineNormalAlternative = Color(0x1470737C),
lineNormalStrong = Color(0x70737C85),
lineSolidNormal = Color(0xFFE1E2E4),
lineSolidNeutral = Color(0xFFEAEBEC),
lineSolidAlternative = Color(0xFFF4F4F5),
lineSolidStrong = Color(0xFFAEB0B6),

fillNormal = Color(0x1470737C),
fillStrong = Color(0x2970737C),
fillAlternative = Color(0x0D70737C),

statusPositive = Color(0xFF00BF40),
statusCautionary = Color(0xFFFF9200),
statusNegative = Color(0xFFFF4242),

staticWhite = Color(0xFFFFFFFF),
staticBlack = Color(0xFF000000),

materialDimmer = Color(0x85171719)
)

@Immutable
data class YappColorScheme(
val primaryNormal: Color,

val labelNormal: Color,
val labelStrong: Color,
val labelNeutral: Color,
val labelAlternative: Color,
val labelAssistive: Color,
val labelDisable: Color,

val backgroundNormalNormal: Color,
val backgroundNormalAlternative: Color,
val backgroundElevatedNormal: Color,
val backgroundElevatedAlternative: Color,

val interactionInactive: Color,
val interactionDisable: Color,

val lineNormalNormal: Color,
val lineNormalNeutral: Color,
val lineNormalAlternative: Color,
val lineNormalStrong: Color,
val lineSolidNormal: Color,
val lineSolidNeutral: Color,
val lineSolidAlternative: Color,
val lineSolidStrong: Color,

val fillNormal: Color,
val fillStrong: Color,
val fillAlternative: Color,

val statusPositive: Color,
val statusCautionary: Color,
val statusNegative: Color,

val staticWhite: Color,
val staticBlack: Color,

val materialDimmer: Color
)

val LocalLightColorScheme = staticCompositionLocalOf {
YappColorScheme(
primaryNormal = Color.Unspecified,
labelNormal = Color.Unspecified,
labelStrong = Color.Unspecified,
labelNeutral = Color.Unspecified,
labelAlternative = Color.Unspecified,
labelAssistive = Color.Unspecified,
labelDisable = Color.Unspecified,
backgroundNormalNormal = Color.Unspecified,
backgroundNormalAlternative = Color.Unspecified,
backgroundElevatedNormal = Color.Unspecified,
backgroundElevatedAlternative = Color.Unspecified,
interactionInactive = Color.Unspecified,
interactionDisable = Color.Unspecified,
lineNormalNormal = Color.Unspecified,
lineNormalNeutral = Color.Unspecified,
lineNormalAlternative = Color.Unspecified,
lineNormalStrong = Color.Unspecified,
lineSolidNormal = Color.Unspecified,
lineSolidNeutral = Color.Unspecified,
lineSolidAlternative = Color.Unspecified,
lineSolidStrong = Color.Unspecified,
fillNormal = Color.Unspecified,
fillStrong = Color.Unspecified,
fillAlternative = Color.Unspecified,
statusPositive = Color.Unspecified,
statusCautionary = Color.Unspecified,
statusNegative = Color.Unspecified,
staticWhite = Color.Unspecified,
staticBlack = Color.Unspecified,
materialDimmer = Color.Unspecified,
)
}
139 changes: 139 additions & 0 deletions core/designsystem/src/main/java/com/yapp/designsystem/theme/Preview.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package com.yapp.designsystem.theme

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.tooling.preview.Preview

@Composable
private fun ColorPreview(color: Color, name: String) {
Column {
BasicText(
text = name,
style = TextStyle(color = YappTheme.lightColorScheme.staticBlack, fontSize = 14.sp)
)
Spacer(Modifier.height(4.dp))
Box(
modifier = Modifier
.fillMaxWidth()
.height(40.dp)
.background(color)
.border(width = 1.dp, color = YappTheme.lightColorScheme.lineSolidNormal)
)
Spacer(Modifier.height(12.dp))
}
}

@Composable
private fun TypographyPreview(textStyle: TextStyle, name: String) {
BasicText(
text = name,
modifier = Modifier.padding(8.dp),
style = textStyle
)
}

@Preview(showBackground = true, widthDp = 800)
@Composable
private fun YappColorPreview() {
YappTheme {
val colors = YappTheme.lightColorScheme.let {
listOf(
"Primary Normal" to it.primaryNormal,
"Label Normal" to it.labelNormal,
"Label Strong" to it.labelStrong,
"Label Neutral" to it.labelNeutral,
"Label Alternative" to it.labelAlternative,
"Label Assistive" to it.labelAssistive,
"Label Disable" to it.labelDisable,
"Background Normal Normal" to it.backgroundNormalNormal,
"Background Normal Alternative" to it.backgroundNormalAlternative,
"Background Elevated Normal" to it.backgroundElevatedNormal,
"Background Elevated Alternative" to it.backgroundElevatedAlternative,
"Interaction Inactive" to it.interactionInactive,
"Interaction Disable" to it.interactionDisable,
"Line Normal Normal" to it.lineNormalNormal,
"Line Normal Neutral" to it.lineNormalNeutral,
"Line Normal Alternative" to it.lineNormalAlternative,
"Line Normal Strong" to it.lineNormalStrong,
"Line Solid Normal" to it.lineSolidNormal,
"Line Solid Neutral" to it.lineSolidNeutral,
"Line Solid Alternative" to it.lineSolidAlternative,
"Line Solid Strong" to it.lineSolidStrong,
"Fill Normal" to it.fillNormal,
"Fill Strong" to it.fillStrong,
"Fill Alternative" to it.fillAlternative,
"Status Positive" to it.statusPositive,
"Status Cautionary" to it.statusCautionary,
"Status Negative" to it.statusNegative,
"Static White" to it.staticWhite,
"Static Black" to it.staticBlack,
"Material Dimmer" to it.materialDimmer
)
}

LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
items(colors) { (name, color) ->
ColorPreview(color = color, name = name)
}
}
}
}

@Preview(showBackground = true)
@Composable
private fun YappTypographyPreview() {
YappTheme {
Column(
modifier = Modifier
.padding(16.dp)
.verticalScroll(rememberScrollState())
) {
val typos = YappTheme.typography.let {
listOf(
"Display 1" to it.display1,
"Display 2" to it.display2,
"Title 1" to it.title1,
"Title 2" to it.title2,
"Title 3" to it.title3,
"Heading 1" to it.heading1,
"Heading 2" to it.heading2,
"Headline 1" to it.headline1,
"Headline 2" to it.headline2,
"Body 1 Normal" to it.body1Normal,
"Body 1 Reading" to it.body1Reading,
"Body 2 Normal" to it.body2Normal,
"Body 2 Reading" to it.body2Reading,
"Label 1 Normal" to it.label1Normal,
"Label 1 Reading" to it.label1Reading,
"Label 2" to it.label2,
"Caption 1" to it.caption1,
"Caption 2" to it.caption2
)
}

typos.forEach { (name, textStyle) ->
TypographyPreview(
name = name,
textStyle = textStyle,
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.yapp.designsystem.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable

@Composable
fun YappTheme(
content: @Composable () -> Unit,
) {
CompositionLocalProvider(
LocalTypography provides Typography,
LocalLightColorScheme provides LightColorScheme,
) {
MaterialTheme(
colorScheme = lightColorScheme(
background = YappTheme.lightColorScheme.backgroundNormalNormal,
),
content = content,
)
}
}

object YappTheme {
val typography: YappTypography
@Composable
@ReadOnlyComposable
get() = LocalTypography.current

val lightColorScheme: YappColorScheme
@Composable
@ReadOnlyComposable
get() = LocalLightColorScheme.current
}
Loading

0 comments on commit ef25124

Please sign in to comment.