Skip to content

Commit 43491bb

Browse files
committed
2.1.0: Kotlin 2
1 parent 8113030 commit 43491bb

File tree

18 files changed

+276
-157
lines changed

18 files changed

+276
-157
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*~
88
.DS_STORE
99

10+
# KOTLIN
11+
.kotlin
12+
1013
# GRADLE
1114
.gradle
1215
build/

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55

66
allprojects {
77
group = "net.kodein.themes"
8-
version = "2.0.0"
8+
version = "2.1.0"
99
}
1010

1111
subprojects {

compose/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
33
plugins {
44
alias(libs.plugins.kotlin.multiplatform)
55
alias(libs.plugins.compose)
6+
alias(libs.plugins.kotlin.plugin.compose)
67
`maven-publish`
78
}
89

compose/compose-m2/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
33
plugins {
44
alias(libs.plugins.kotlin.multiplatform)
55
alias(libs.plugins.compose)
6+
alias(libs.plugins.kotlin.plugin.compose)
67
`maven-publish`
78
}
89

compose/compose-m2/src/commonMain/kotlin/net/kodein/theme/compose/m2/Link.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public fun Link(
2424
Box(
2525
modifier = modifier
2626
.pointerHoverIcon(PointerIcon.Hand)
27-
.clickable {
28-
uriHandler.openUri(uri)
29-
}
27+
.clickable { uriHandler.openUri(uri) }
3028
) {
3129
ProvideTextStyle(TextStyle(color = MaterialTheme.colors.primary)) {
3230
content()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.kodein.theme.compose
2+
3+
import org.jetbrains.compose.resources.FontResource
4+
import org.jetbrains.compose.resources.InternalResourceApi
5+
import org.jetbrains.compose.resources.ResourceItem
6+
7+
8+
@OptIn(InternalResourceApi::class)
9+
internal fun FontResource(file: String): FontResource {
10+
val id = file.split('/').last().removeSuffix(".ttf").replace('-', '_')
11+
return FontResource(
12+
id = "font:$id",
13+
items = setOf(
14+
ResourceItem(
15+
qualifiers = emptySet(),
16+
path = file,
17+
offset = -1,
18+
size = -1
19+
)
20+
)
21+
)
22+
}

compose/src/commonMain/kotlin/net/kodein/theme/compose/JetBrainsMono.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import androidx.compose.runtime.Composable
44
import androidx.compose.ui.text.font.FontFamily
55
import androidx.compose.ui.text.font.FontStyle
66
import androidx.compose.ui.text.font.FontWeight
7-
import org.jetbrains.compose.resources.ExperimentalResourceApi
8-
import org.jetbrains.compose.resources.Font
9-
import org.jetbrains.compose.resources.FontResource
7+
import org.jetbrains.compose.resources.*
108

119

12-
@OptIn(ExperimentalResourceApi::class)
1310
private object JetBrainsMonoResources {
1411
val Thin: FontResource by lazy { FontResource("font/JetBrainsMono-Thin.ttf") }
1512
val ThinItalic: FontResource by lazy { FontResource("font/JetBrainsMono-ThinItalic.ttf") }

compose/src/commonMain/kotlin/net/kodein/theme/compose/KodeinLogo.kt

Lines changed: 0 additions & 31 deletions
This file was deleted.

cup/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
33
plugins {
44
alias(libs.plugins.kotlin.multiplatform)
55
alias(libs.plugins.compose)
6+
alias(libs.plugins.kotlin.plugin.compose)
67
`maven-publish`
78
}
89

cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinCupMaterialTheme.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package net.kodein.theme.cup
22

33
import androidx.compose.material.MaterialTheme
44
import androidx.compose.runtime.Composable
5-
import net.kodein.cup.ui.cupScaleDown
5+
import net.kodein.cup.widgets.material.cupScaleDown
66
import net.kodein.theme.compose.m2.KodeinMaterialColors
77
import net.kodein.theme.compose.m2.kodeinMaterialShapes
88
import net.kodein.theme.compose.m2.kodeinMaterialTypography

cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinLogo.kt

Lines changed: 0 additions & 66 deletions
This file was deleted.

cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinPresentation.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ private fun BoxScope.ProgressBar(presentationState: PresentationState) {
5757

5858
@Composable
5959
public fun KodeinPresentation(
60-
slides: SlideGroup
60+
slides: SlideGroup,
61+
decoration: @Composable BoxScope.(@Composable BoxScope.() -> Unit) -> Unit = { it() },
6162
) {
6263
remember {
6364
// https://github.com/kosi-libs/Emoji.kt?tab=readme-ov-file#initializing-the-emoji-service
@@ -94,17 +95,19 @@ public fun KodeinPresentation(
9495
.fillMaxSize()
9596
.background(overBackground)
9697
) {
97-
Box(
98-
modifier = Modifier
99-
.padding(8.dp)
100-
) {
101-
CompositionLocalProvider(
102-
LocalContentColor provides MaterialTheme.colors.onBackground,
98+
decoration {
99+
Box(
100+
modifier = Modifier
101+
.padding(8.dp)
103102
) {
104-
slidesContent()
103+
CompositionLocalProvider(
104+
LocalContentColor provides MaterialTheme.colors.onBackground,
105+
) {
106+
slidesContent()
107+
}
105108
}
109+
ProgressBar(presentationState)
106110
}
107-
ProgressBar(presentationState)
108111
}
109112
}
110113
}
Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
package net.kodein.theme.cup
22

33
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.layout.Column
45
import androidx.compose.foundation.layout.padding
56
import androidx.compose.foundation.shape.RoundedCornerShape
7+
import androidx.compose.material.Text
68
import androidx.compose.runtime.Composable
79
import androidx.compose.ui.Modifier
810
import androidx.compose.ui.graphics.Color
911
import androidx.compose.ui.text.TextStyle
12+
import androidx.compose.ui.unit.TextUnit
1013
import androidx.compose.ui.unit.dp
1114
import androidx.compose.ui.unit.sp
1215
import net.kodein.cup.sa.SourceCode
16+
import net.kodein.theme.KodeinColors
17+
import net.kodein.theme.compose.Color
1318
import net.kodein.theme.compose.JetBrainsMono
1419
import net.kodein.theme.compose.JetBrainsMonoNL
1520

@@ -18,16 +23,28 @@ import net.kodein.theme.compose.JetBrainsMonoNL
1823
public fun KodeinSourceCode(
1924
sourceCode: SourceCode,
2025
step: Int = 0,
26+
modifier: Modifier = Modifier,
27+
file: String? = null,
28+
fontSize: TextUnit = TextUnit.Unspecified,
2129
style: TextStyle = TextStyle(),
22-
modifier: Modifier = Modifier
2330
) {
24-
SourceCode(
25-
sourceCode = sourceCode,
26-
step = step,
27-
style = TextStyle(fontFamily = JetBrainsMono, fontSize = 12.sp) + style,
28-
theme = KodeinSourceCodeTheme,
29-
modifier = modifier
30-
.background(Color.DarkGray, RoundedCornerShape(4.dp))
31-
.padding(8.dp)
32-
)
31+
val mergedStyle = TextStyle(fontFamily = JetBrainsMono, fontSize = 12.sp) + style + TextStyle(fontSize = fontSize)
32+
Column {
33+
if (file != null) {
34+
Text(
35+
text = file,
36+
color = Color(KodeinColors.purple_light),
37+
style = mergedStyle
38+
)
39+
}
40+
SourceCode(
41+
sourceCode = sourceCode,
42+
step = step,
43+
style = mergedStyle,
44+
theme = KodeinSourceCodeTheme,
45+
modifier = modifier
46+
.background(Color.DarkGray, RoundedCornerShape(4.dp))
47+
.padding(8.dp)
48+
)
49+
}
3350
}
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
package net.kodein.theme.cup
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.text.AnnotatedString
45
import androidx.compose.ui.text.SpanStyle
6+
import androidx.compose.ui.text.font.FontFamily
57
import androidx.compose.ui.text.font.FontWeight
68
import net.kodein.cup.ui.SpanStyleSheet
79
import net.kodein.cup.ui.styled
10+
import net.kodein.theme.compose.JetBrainsMono
811

912

10-
public object KodeinStyleSheet : SpanStyleSheet() {
13+
public abstract class KodeinStyleSheet : SpanStyleSheet() {
1114
/** Light */
1215
public val l: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Light))
1316
/** Normal */
1417
public val n: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Normal))
1518
/** Medium */
1619
public val m: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Medium))
20+
21+
public companion object : KodeinStyleSheet()
22+
}
23+
24+
public class ComposeKodeinStyleSheet(
25+
private val jetBrainsMono: FontFamily
26+
) : KodeinStyleSheet() {
27+
/** Source Code */
28+
public val sc: Marker by registerMarker(SpanStyle(fontFamily = jetBrainsMono))
1729
}
1830

19-
public fun kStyled(build: KodeinStyleSheet.() -> String): AnnotatedString = styled(KodeinStyleSheet, build)
31+
public fun kStyled(build: KodeinStyleSheet.() -> String): AnnotatedString =
32+
styled(KodeinStyleSheet, build)
33+
34+
@Composable
35+
public fun kcStyled(build: ComposeKodeinStyleSheet.() -> String): AnnotatedString =
36+
styled(ComposeKodeinStyleSheet(JetBrainsMono), build)

0 commit comments

Comments
 (0)