Skip to content

Commit

Permalink
kotlinized
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Apr 1, 2023
1 parent 86751e7 commit 46d29e9
Show file tree
Hide file tree
Showing 53 changed files with 3,255 additions and 3,649 deletions.
32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 2 additions & 22 deletions dynamic_theme/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("maven-publish")
}

android {
Expand All @@ -26,6 +25,7 @@ android {
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Expand All @@ -38,13 +38,6 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = "1.4.2"
}

publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
Expand All @@ -53,18 +46,5 @@ dependencies {
implementation("androidx.compose.material3:material3")
implementation("androidx.palette:palette:1.0.0")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.30.0")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "com.github.t8rin"
artifactId = "dynamictheme"
version = "1.0"

afterEvaluate {
from(components["release"])
}
}
}
}
2 changes: 0 additions & 2 deletions dynamic_theme/jitpack.yml

This file was deleted.

38 changes: 18 additions & 20 deletions dynamic_theme/src/main/java/com/t8rin/dynamic/theme/DynamicTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.t8rin.dynamic.theme.hct.Hct
import com.t8rin.dynamic.theme.palettes.TonalPalette
import com.t8rin.dynamic.theme.scheme.Scheme
import kotlin.math.min

/**
* DynamicTheme allows you to dynamically change the color scheme of the content hierarchy.
Expand All @@ -47,9 +46,7 @@ import kotlin.math.min
fun DynamicTheme(
state: DynamicThemeState,
typography: Typography = Typography(),
density: Density = LocalDensity.current.run {
Density(this.density, min(fontScale, 1f))
},
density: Density = LocalDensity.current,
defaultColorTuple: ColorTuple,
dynamicColor: Boolean = true,
amoledMode: Boolean = false,
Expand Down Expand Up @@ -433,6 +430,7 @@ private fun Scheme.toDarkThemeColorScheme(
TonalPalette.fromHueAndChroma(hue, chroma / 3.0)
}
}

val a3 = colorTuple.tertiary?.toArgb().let {
if (it != null) {
TonalPalette.fromInt(it)
Expand All @@ -447,14 +445,14 @@ private fun Scheme.toDarkThemeColorScheme(
primaryContainer = Color(primaryContainer),
onPrimaryContainer = Color(onPrimaryContainer),
inversePrimary = Color(inversePrimary),
secondary = Color(a2?.tone(80) ?: secondary),
onSecondary = Color(a2?.tone(20) ?: onSecondary),
secondaryContainer = Color(a2?.tone(30) ?: secondaryContainer),
onSecondaryContainer = Color(a2?.tone(90) ?: onSecondaryContainer),
tertiary = Color(a3?.tone(80) ?: tertiary),
onTertiary = Color(a3?.tone(20) ?: onTertiary),
tertiaryContainer = Color(a3?.tone(30) ?: tertiaryContainer),
onTertiaryContainer = Color(a3?.tone(90) ?: onTertiaryContainer),
secondary = Color(a2.tone(80)),
onSecondary = Color(a2.tone(20)),
secondaryContainer = Color(a2.tone(30)),
onSecondaryContainer = Color(a2.tone(90)),
tertiary = Color(a3.tone(80)),
onTertiary = Color(a3.tone(20)),
tertiaryContainer = Color(a3.tone(30)),
onTertiaryContainer = Color(a3.tone(90)),
background = Color(background),
onBackground = Color(onBackground),
surface = Color(surface),
Expand Down Expand Up @@ -502,14 +500,14 @@ private fun Scheme.toLightThemeColorScheme(
primaryContainer = Color(primaryContainer),
onPrimaryContainer = Color(onPrimaryContainer),
inversePrimary = Color(inversePrimary),
secondary = Color(a2?.tone(40) ?: secondary),
onSecondary = Color(a2?.tone(100) ?: onSecondary),
secondaryContainer = Color(a2?.tone(90) ?: secondaryContainer),
onSecondaryContainer = Color(a2?.tone(10) ?: onSecondaryContainer),
tertiary = Color(a3?.tone(40) ?: tertiary),
onTertiary = Color(a3?.tone(100) ?: onTertiary),
tertiaryContainer = Color(a3?.tone(90) ?: tertiaryContainer),
onTertiaryContainer = Color(a3?.tone(10) ?: onTertiaryContainer),
secondary = Color(a2.tone(40)),
onSecondary = Color(a2.tone(100)),
secondaryContainer = Color(a2.tone(90)),
onSecondaryContainer = Color(a2.tone(10)),
tertiary = Color(a3.tone(40)),
onTertiary = Color(a3.tone(100)),
tertiaryContainer = Color(a3.tone(90)),
onTertiaryContainer = Color(a3.tone(10)),
background = Color(background),
onBackground = Color(onBackground),
surface = Color(surface),
Expand Down
Loading

0 comments on commit 46d29e9

Please sign in to comment.