diff --git a/.gitignore b/.gitignore index de568aa..865f545 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ *~ .DS_STORE +# KOTLIN +.kotlin + # GRADLE .gradle build/ diff --git a/build.gradle.kts b/build.gradle.kts index 7078dc1..1f725d6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "net.kodein.themes" - version = "2.0.0" + version = "2.1.0" } subprojects { diff --git a/compose/build.gradle.kts b/compose/build.gradle.kts index d99f3ee..bde8292 100644 --- a/compose/build.gradle.kts +++ b/compose/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.compose) + alias(libs.plugins.kotlin.plugin.compose) `maven-publish` } diff --git a/compose/compose-m2/build.gradle.kts b/compose/compose-m2/build.gradle.kts index d37b935..c1ca0c5 100644 --- a/compose/compose-m2/build.gradle.kts +++ b/compose/compose-m2/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.compose) + alias(libs.plugins.kotlin.plugin.compose) `maven-publish` } diff --git a/compose/compose-m2/src/commonMain/kotlin/net/kodein/theme/compose/m2/Link.kt b/compose/compose-m2/src/commonMain/kotlin/net/kodein/theme/compose/m2/Link.kt index b817140..0953738 100644 --- a/compose/compose-m2/src/commonMain/kotlin/net/kodein/theme/compose/m2/Link.kt +++ b/compose/compose-m2/src/commonMain/kotlin/net/kodein/theme/compose/m2/Link.kt @@ -24,9 +24,7 @@ public fun Link( Box( modifier = modifier .pointerHoverIcon(PointerIcon.Hand) - .clickable { - uriHandler.openUri(uri) - } + .clickable { uriHandler.openUri(uri) } ) { ProvideTextStyle(TextStyle(color = MaterialTheme.colors.primary)) { content() diff --git a/compose/src/commonMain/kotlin/net/kodein/theme/compose/FontResource.kt b/compose/src/commonMain/kotlin/net/kodein/theme/compose/FontResource.kt new file mode 100644 index 0000000..223e68d --- /dev/null +++ b/compose/src/commonMain/kotlin/net/kodein/theme/compose/FontResource.kt @@ -0,0 +1,22 @@ +package net.kodein.theme.compose + +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.InternalResourceApi +import org.jetbrains.compose.resources.ResourceItem + + +@OptIn(InternalResourceApi::class) +internal fun FontResource(file: String): FontResource { + val id = file.split('/').last().removeSuffix(".ttf").replace('-', '_') + return FontResource( + id = "font:$id", + items = setOf( + ResourceItem( + qualifiers = emptySet(), + path = file, + offset = -1, + size = -1 + ) + ) + ) +} \ No newline at end of file diff --git a/compose/src/commonMain/kotlin/net/kodein/theme/compose/JetBrainsMono.kt b/compose/src/commonMain/kotlin/net/kodein/theme/compose/JetBrainsMono.kt index bfa0f66..32c6a09 100644 --- a/compose/src/commonMain/kotlin/net/kodein/theme/compose/JetBrainsMono.kt +++ b/compose/src/commonMain/kotlin/net/kodein/theme/compose/JetBrainsMono.kt @@ -4,12 +4,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight -import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.Font -import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.* -@OptIn(ExperimentalResourceApi::class) private object JetBrainsMonoResources { val Thin: FontResource by lazy { FontResource("font/JetBrainsMono-Thin.ttf") } val ThinItalic: FontResource by lazy { FontResource("font/JetBrainsMono-ThinItalic.ttf") } diff --git a/compose/src/commonMain/kotlin/net/kodein/theme/compose/KodeinLogo.kt b/compose/src/commonMain/kotlin/net/kodein/theme/compose/KodeinLogo.kt deleted file mode 100644 index 7ee3cd2..0000000 --- a/compose/src/commonMain/kotlin/net/kodein/theme/compose/KodeinLogo.kt +++ /dev/null @@ -1,31 +0,0 @@ -package net.kodein.theme.compose - -import androidx.compose.foundation.Image -import androidx.compose.foundation.clickable -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.vector.rememberVectorPainter -import androidx.compose.ui.input.pointer.PointerIcon -import androidx.compose.ui.input.pointer.pointerHoverIcon -import androidx.compose.ui.platform.LocalUriHandler -import net.kodein.theme.KodeinColors -import net.kodein.theme.compose.Color -import net.kodein.theme.compose.KodeinVectorImages -import net.kodein.theme.compose.img.KodeinFull - - -@Composable -public fun KodeinLogo(modifier: Modifier) { - val uriHandler = LocalUriHandler.current - Image( - painter = rememberVectorPainter(KodeinVectorImages.Logo.KodeinFull), - contentDescription = "Kodein Koders", - colorFilter = ColorFilter.tint(Color(KodeinColors.orange)), - modifier = modifier - .pointerHoverIcon(PointerIcon.Hand) - .clickable { - uriHandler.openUri("https://kodein.net") - } - ) -} \ No newline at end of file diff --git a/cup/build.gradle.kts b/cup/build.gradle.kts index 59c32cf..5b37290 100644 --- a/cup/build.gradle.kts +++ b/cup/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.compose) + alias(libs.plugins.kotlin.plugin.compose) `maven-publish` } diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinCupMaterialTheme.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinCupMaterialTheme.kt index bc773e4..f644e6e 100644 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinCupMaterialTheme.kt +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinCupMaterialTheme.kt @@ -2,7 +2,7 @@ package net.kodein.theme.cup import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable -import net.kodein.cup.ui.cupScaleDown +import net.kodein.cup.widgets.material.cupScaleDown import net.kodein.theme.compose.m2.KodeinMaterialColors import net.kodein.theme.compose.m2.kodeinMaterialShapes import net.kodein.theme.compose.m2.kodeinMaterialTypography diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinLogo.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinLogo.kt deleted file mode 100644 index f98f21c..0000000 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinLogo.kt +++ /dev/null @@ -1,66 +0,0 @@ -package net.kodein.theme.cup - -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.material.ProvideTextStyle -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.vector.rememberVectorPainter -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import net.kodein.theme.KodeinColors -import net.kodein.theme.compose.Color -import net.kodein.theme.compose.KodeinVectorImages -import net.kodein.theme.compose.img.KodeinMonogram - -@Composable -public fun KodeinLogo( - division: String, - color: Color = Color(KodeinColors.orange), - subtext: @Composable () -> Unit -) { - Row( - verticalAlignment = Alignment.CenterVertically - ) { - Image( - painter = rememberVectorPainter(KodeinVectorImages.Logo.KodeinMonogram), - contentDescription = null, - colorFilter = ColorFilter.tint(color), - modifier = Modifier.height(112.dp).padding(end = 12.dp) - ) - Column { - Text( - text = kStyled { "KODEIN${+l}$division${-l}" }, - color = color, - fontWeight = FontWeight.Bold, - fontSize = 56.sp, - lineHeight = 56.sp, - modifier = Modifier - .height(46.dp) - ) - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(start = 2.dp) - ) { - ProvideTextStyle( - TextStyle( - color = color, - fontSize = 22.sp - ) - ) { - Text("painless ") - subtext() - } - } - } - } -} \ No newline at end of file diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinPresentation.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinPresentation.kt index a74f286..760eb18 100644 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinPresentation.kt +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinPresentation.kt @@ -57,7 +57,8 @@ private fun BoxScope.ProgressBar(presentationState: PresentationState) { @Composable public fun KodeinPresentation( - slides: SlideGroup + slides: SlideGroup, + decoration: @Composable BoxScope.(@Composable BoxScope.() -> Unit) -> Unit = { it() }, ) { remember { // https://github.com/kosi-libs/Emoji.kt?tab=readme-ov-file#initializing-the-emoji-service @@ -94,17 +95,19 @@ public fun KodeinPresentation( .fillMaxSize() .background(overBackground) ) { - Box( - modifier = Modifier - .padding(8.dp) - ) { - CompositionLocalProvider( - LocalContentColor provides MaterialTheme.colors.onBackground, + decoration { + Box( + modifier = Modifier + .padding(8.dp) ) { - slidesContent() + CompositionLocalProvider( + LocalContentColor provides MaterialTheme.colors.onBackground, + ) { + slidesContent() + } } + ProgressBar(presentationState) } - ProgressBar(presentationState) } } } diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinSourceCode.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinSourceCode.kt index 1944cfd..72fb308 100644 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinSourceCode.kt +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinSourceCode.kt @@ -1,15 +1,20 @@ package net.kodein.theme.cup import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Text 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.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import net.kodein.cup.sa.SourceCode +import net.kodein.theme.KodeinColors +import net.kodein.theme.compose.Color import net.kodein.theme.compose.JetBrainsMono import net.kodein.theme.compose.JetBrainsMonoNL @@ -18,16 +23,28 @@ import net.kodein.theme.compose.JetBrainsMonoNL public fun KodeinSourceCode( sourceCode: SourceCode, step: Int = 0, + modifier: Modifier = Modifier, + file: String? = null, + fontSize: TextUnit = TextUnit.Unspecified, style: TextStyle = TextStyle(), - modifier: Modifier = Modifier ) { - SourceCode( - sourceCode = sourceCode, - step = step, - style = TextStyle(fontFamily = JetBrainsMono, fontSize = 12.sp) + style, - theme = KodeinSourceCodeTheme, - modifier = modifier - .background(Color.DarkGray, RoundedCornerShape(4.dp)) - .padding(8.dp) - ) + val mergedStyle = TextStyle(fontFamily = JetBrainsMono, fontSize = 12.sp) + style + TextStyle(fontSize = fontSize) + Column { + if (file != null) { + Text( + text = file, + color = Color(KodeinColors.purple_light), + style = mergedStyle + ) + } + SourceCode( + sourceCode = sourceCode, + step = step, + style = mergedStyle, + theme = KodeinSourceCodeTheme, + modifier = modifier + .background(Color.DarkGray, RoundedCornerShape(4.dp)) + .padding(8.dp) + ) + } } diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinStyleSheet.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinStyleSheet.kt index 5612f30..a6e69df 100644 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinStyleSheet.kt +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/KodeinStyleSheet.kt @@ -1,19 +1,36 @@ package net.kodein.theme.cup +import androidx.compose.runtime.Composable import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import net.kodein.cup.ui.SpanStyleSheet import net.kodein.cup.ui.styled +import net.kodein.theme.compose.JetBrainsMono -public object KodeinStyleSheet : SpanStyleSheet() { +public abstract class KodeinStyleSheet : SpanStyleSheet() { /** Light */ public val l: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Light)) /** Normal */ public val n: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Normal)) /** Medium */ public val m: Marker by registerMarker(SpanStyle(fontWeight = FontWeight.Medium)) + + public companion object : KodeinStyleSheet() +} + +public class ComposeKodeinStyleSheet( + private val jetBrainsMono: FontFamily +) : KodeinStyleSheet() { + /** Source Code */ + public val sc: Marker by registerMarker(SpanStyle(fontFamily = jetBrainsMono)) } -public fun kStyled(build: KodeinStyleSheet.() -> String): AnnotatedString = styled(KodeinStyleSheet, build) +public fun kStyled(build: KodeinStyleSheet.() -> String): AnnotatedString = + styled(KodeinStyleSheet, build) + +@Composable +public fun kcStyled(build: ComposeKodeinStyleSheet.() -> String): AnnotatedString = + styled(ComposeKodeinStyleSheet(JetBrainsMono), build) diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/slides/kodeinActivities.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/slides/kodeinActivities.kt index f101701..f320965 100644 --- a/cup/src/commonMain/kotlin/net/kodein/theme/cup/slides/kodeinActivities.kt +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/slides/kodeinActivities.kt @@ -1,26 +1,10 @@ package net.kodein.theme.cup.slides -import androidx.compose.animation.AnimatedVisibility -import androidx.compose.animation.EnterExitState -import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.animation.* import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.tween -import androidx.compose.animation.expandHorizontally -import androidx.compose.animation.expandVertically -import androidx.compose.animation.fadeIn -import androidx.compose.animation.fadeOut -import androidx.compose.animation.shrinkHorizontally -import androidx.compose.animation.shrinkVertically import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.InlineTextContent import androidx.compose.material.ProvideTextStyle @@ -42,19 +26,15 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp +import net.kodein.cup.* import net.kodein.theme.KodeinColors import net.kodein.theme.compose.Color import net.kodein.theme.compose.KodeinVectorImages import net.kodein.theme.compose.LCTPicon +import net.kodein.theme.cup.ui.KodeinLogo import net.kodein.theme.cup.KodeinPresentationBackground import net.kodein.theme.cup.img.KotlinMonogram import net.kodein.theme.cup.kStyled -import net.kodein.theme.cup.KodeinLogo -import net.kodein.cup.SLIDE_SIZE_16_9 -import net.kodein.cup.Slide -import net.kodein.cup.Slides -import net.kodein.cup.TransitionSet -import net.kodein.cup.copyWithInsideTransitions @Composable @@ -108,7 +88,7 @@ private fun KotlinDivision( private val kodeinKoders by Slide( stepCount = 3 ) { step -> - KodeinLogo("Koders") { Text("mobile technology") } + KodeinLogo("Koders") { Text("painless mobile technology") } AnimatedVisibility( visible = step >= 1, enter = fadeIn(tween(750)) + expandVertically(tween(750)), @@ -149,10 +129,11 @@ private val kodeinOpenSource by Slide( ) { step -> KodeinLogo( division = "OpenSource", - color = Color.White + color = Color.White, + url = "https://kodein.org" ) { Text( - text = kStyled { "${IC("kotlin")} multiplatform" }, + text = kStyled { "painless ${IC("kotlin")} multiplatform" }, inlineContent = mapOf( "kotlin" to InlineTextContent(Placeholder(0.8.em, 0.8.em, PlaceholderVerticalAlign.Center)) { Image( diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/KodeinLogo.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/KodeinLogo.kt new file mode 100644 index 0000000..4f0b3f3 --- /dev/null +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/KodeinLogo.kt @@ -0,0 +1,82 @@ +package net.kodein.theme.cup.ui + +import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.material.ProvideTextStyle +import androidx.compose.material.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.input.pointer.PointerIcon +import androidx.compose.ui.input.pointer.pointerHoverIcon +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import net.kodein.theme.KodeinColors +import net.kodein.theme.compose.Color +import net.kodein.theme.compose.KodeinVectorImages +import net.kodein.theme.compose.img.KodeinMonogram +import net.kodein.theme.cup.kStyled + +@Composable +public fun KodeinLogo( + division: String, + modifier: Modifier = Modifier, + color: Color = Color(KodeinColors.orange), + url: String = "https://kodein.net", + subtext: @Composable () -> Unit +) { + val uriHandler = LocalUriHandler.current + val density = LocalDensity.current + var height: Dp by remember { mutableStateOf(0.dp) } + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = modifier + .height(112.dp) + .pointerHoverIcon(PointerIcon.Hand) + .clickable { uriHandler.openUri(url) } + .onSizeChanged { height = with(density) { it.height.toDp() } } + ) { + if (height == 0.dp) return@Row + Image( + painter = rememberVectorPainter(KodeinVectorImages.Logo.KodeinMonogram), + contentDescription = null, + colorFilter = ColorFilter.tint(color), + modifier = Modifier.fillMaxHeight().padding(end = height * 0.1f) + ) + Column { + val mainFontSize = with(density) { (height * 0.5f).toSp() } + Text( + text = kStyled { "KODEIN${+l}$division${-l}" }, + color = color, + fontWeight = FontWeight.Bold, + fontSize = mainFontSize, + lineHeight = mainFontSize, + modifier = Modifier.height(height * 0.41f) + ) + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(start = height * 0.02f) + ) { + val subFontSize = with(density) { (height * 0.2f).toSp() } + ProvideTextStyle( + TextStyle( + color = color, + fontSize = subFontSize, + lineHeight = subFontSize + ) + ) { + subtext() + } + } + } + } +} \ No newline at end of file diff --git a/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/Visibility.kt b/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/Visibility.kt new file mode 100644 index 0000000..1ee68b4 --- /dev/null +++ b/cup/src/commonMain/kotlin/net/kodein/theme/cup/ui/Visibility.kt @@ -0,0 +1,90 @@ +package net.kodein.theme.cup.ui + +import androidx.compose.animation.* +import androidx.compose.animation.core.Easing +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.tween +import androidx.compose.foundation.layout.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier + + +public val defaultKodeinAnimationDuration: Int = 600 + +public class AnimatedVisibilityColumnScope( + columnScope: ColumnScope, + animatedVisibilityScope: AnimatedVisibilityScope +) : ColumnScope by columnScope, AnimatedVisibilityScope by animatedVisibilityScope + +@Composable +public fun ColumnScope.KodeinAnimatedVisibility( + visible: Boolean, + modifier: Modifier = Modifier, + durationMillis: Int = defaultKodeinAnimationDuration, + easing: Easing = FastOutSlowInEasing, + verticalArrangement: Arrangement.Vertical = Arrangement.Center, + horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally, + content: @Composable AnimatedVisibilityColumnScope.() -> Unit +) { + AnimatedVisibility( + visible = visible, + enter = fadeIn(tween(durationMillis, easing = easing)) + expandVertically(tween(durationMillis, easing = easing)), + exit = fadeOut(tween(durationMillis, easing = easing)) + shrinkVertically(tween(durationMillis, easing = easing)), + modifier = modifier, + ) anim@ { + Column( + verticalArrangement = verticalArrangement, + horizontalAlignment = horizontalAlignment, + ) column@ { + AnimatedVisibilityColumnScope(this@column, this@anim).content() + } + } +} + +public class AnimatedVisibilityRowScope( + rowScope: RowScope, + animatedVisibilityScope: AnimatedVisibilityScope +) : RowScope by rowScope, AnimatedVisibilityScope by animatedVisibilityScope + +@Composable +public fun RowScope.KodeinAnimatedVisibility( + visible: Boolean, + modifier: Modifier = Modifier, + durationMillis: Int = defaultKodeinAnimationDuration, + easing: Easing = FastOutSlowInEasing, + horizontalArrangement: Arrangement.Horizontal = Arrangement.Center, + verticalAlignment: Alignment.Vertical = Alignment.CenterVertically, + content: @Composable AnimatedVisibilityRowScope.() -> Unit +) { + AnimatedVisibility( + visible = visible, + enter = fadeIn(tween(durationMillis, easing = easing)) + expandHorizontally(tween(durationMillis, easing = easing)), + exit = fadeOut(tween(durationMillis, easing = easing)) + shrinkHorizontally(tween(durationMillis, easing = easing)), + modifier = modifier, + ) anim@ { + Row( + horizontalArrangement = horizontalArrangement, + verticalAlignment = verticalAlignment, + ) row@ { + AnimatedVisibilityRowScope(this@row, this@anim).content() + } + } +} + +@Composable +public fun KodeinFadeAnimatedVisibility( + visible: Boolean, + modifier: Modifier = Modifier, + durationMillis: Int = defaultKodeinAnimationDuration, + easing: Easing = FastOutSlowInEasing, + content: @Composable AnimatedVisibilityScope.() -> Unit +) { + AnimatedVisibility( + visible = visible, + enter = fadeIn(tween(durationMillis, easing = easing)), + exit = fadeOut(tween(durationMillis, easing = easing)), + modifier = modifier, + content = content + ) +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f3a74c5..3f45583 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,17 +1,19 @@ [versions] -compose = "1.6.2" -cup = "1.0.0-Beta-01" +compose = "1.6.10-rc01" +cup = "1.0.0-Beta-03" emoji = "1.3.0" -kotlin = "1.9.23" +kotlin = "2.0.0-RC3" resourceFiles = "1.0.0" [plugins] kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlin-plugin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } compose = { id = "org.jetbrains.compose", version.ref = "compose" } resourceFiles = { id = "net.kodein.gradle.resources.resource-files", version.ref = "resourceFiles" } [libraries] cup = { module = "net.kodein.cup:cup", version.ref = "cup" } +cup-widgets-material = { module = "net.kodein.cup:cup-widgets-material", version.ref = "cup" } cup-sourceCode = { module = "net.kodein.cup:cup-source-code", version.ref = "cup" } cup-plugin-laser = { module = "net.kodein.cup:cup-laser", version.ref = "cup" } cup-plugin-speakerWindow = { module = "net.kodein.cup:cup-speaker-window", version.ref = "cup" } @@ -20,6 +22,7 @@ emoji-compose = { module = "org.kodein.emoji:emoji-compose-m2", version.ref = "e [bundles] cup = [ "cup", + "cup-widgets-material", "cup-sourceCode", "cup-plugin-laser", "cup-plugin-speakerWindow"