diff --git a/CHANGELOG.md b/CHANGELOG.md index 889df70f702..20c32f9194d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.23.1 + +* `Versions`: + * `Compose`: `1.7.0` -> `1.7.1` + * `Exposed`: `0.55.0` -> `0.56.0` + * `Xerial SQLite`: `3.46.1.3` -> `3.47.0.0` + * `Android CoreKTX`: `1.13.1` -> `1.15.0` + * `Android Fragment`: `1.8.4` -> `1.8.5` +* `Coroutines`: + * `Compose`: + * Add `StyleSheetsAggregator` + ## 0.23.0 **THIS UPDATE MAY CONTAINS SOME BREAKING CHANGES (INCLUDING BREAKING CHANGES IN BYTECODE LAYER) RELATED TO UPDATE OF diff --git a/coroutines/compose/src/jsMain/kotlin/dev/inmo/micro_utils/coroutines/compose/StyleSheetsAggregator.kt b/coroutines/compose/src/jsMain/kotlin/dev/inmo/micro_utils/coroutines/compose/StyleSheetsAggregator.kt new file mode 100644 index 00000000000..9cc62b81acd --- /dev/null +++ b/coroutines/compose/src/jsMain/kotlin/dev/inmo/micro_utils/coroutines/compose/StyleSheetsAggregator.kt @@ -0,0 +1,66 @@ +package dev.inmo.micro_utils.coroutines.compose + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.remember +import dev.inmo.micro_utils.coroutines.SpecialMutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.debounce +import org.jetbrains.compose.web.css.CSSRulesHolder +import org.jetbrains.compose.web.css.Style +import org.jetbrains.compose.web.css.StyleSheet + +/** + * Aggregator of Compose CSS StyleSheet. Allowing to add [StyleSheet] in it and draw it in one place without requiring + * to add `Style(stylesheet)` on every compose function call + */ +object StyleSheetsAggregator { + private val _stylesFlow = SpecialMutableStateFlow>(emptySet()) + val stylesFlow: StateFlow> = _stylesFlow.asStateFlow() + + @Composable + fun draw() { + _stylesFlow.debounce(13L).collectAsState(emptySet()).value.forEach { + Style(it) + } + } + + /** + * Adding [styleSheet] into the [Set] of included stylesheets. If you called [enableStyleSheetsAggregator], + * new styles will be enabled in the document + */ + fun addStyleSheet(styleSheet: CSSRulesHolder) { + _stylesFlow.value += styleSheet + } + + /** + * Removed [styleSheet] into the [Set] of included stylesheets + */ + fun removeStyleSheet(styleSheet: CSSRulesHolder) { + _stylesFlow.value -= styleSheet + } +} + +/** + * Drawing [StyleSheetsAggregator] in place. You may pass [Set] of [CSSRulesHolder]/[StyleSheet]s as preset of styles + */ +@Composable +fun enableStyleSheetsAggregator( + stylesPreset: Set = emptySet(), +) { + remember { + stylesPreset.forEach { + StyleSheetsAggregator.addStyleSheet(it) + } + } + StyleSheetsAggregator.draw() +} + +/** + * Will include [this] [CSSRulesHolder]/[StyleSheet] in the [StyleSheetsAggregator] using its + * [StyleSheetsAggregator.addStyleSheet] + */ +fun CSSRulesHolder.includeInStyleSheetsAggregator() { + StyleSheetsAggregator.addStyleSheet(this) +} diff --git a/gradle.properties b/gradle.properties index 8cad02a585c..23056a9a04b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.23.0 -android_code_version=276 +version=0.23.1 +android_code_version=277 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 88f7d79de3a..f22244b2a45 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,11 +6,11 @@ kt-coroutines = "1.9.0" kslog = "1.3.6" -jb-compose = "1.7.0" -jb-exposed = "0.55.0" +jb-compose = "1.7.1" +jb-exposed = "0.56.0" jb-dokka = "1.9.20" -sqlite = "3.46.1.3" +sqlite = "3.47.0.0" korlibs = "5.4.0" uuid = "0.8.4" @@ -23,7 +23,7 @@ koin = "4.0.0" okio = "3.9.1" -ksp = "2.0.21-1.0.26" +ksp = "2.0.21-1.0.28" kotlin-poet = "1.18.1" versions = "0.51.0" @@ -31,10 +31,10 @@ versions = "0.51.0" android-gradle = "8.2.2" dexcount = "4.0.0" -android-coreKtx = "1.13.1" +android-coreKtx = "1.15.0" android-recyclerView = "1.3.2" android-appCompat = "1.7.0" -android-fragment = "1.8.4" +android-fragment = "1.8.5" android-espresso = "3.6.1" android-test = "1.2.1" android-compose-material3 = "1.3.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1e2fbf0d458..81aa1c0448a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists