Merge pull request #513 from InsanusMokrassar/0.23.1

0.23.1
This commit is contained in:
InsanusMokrassar 2024-11-25 15:31:41 +06:00 committed by GitHub
commit 24347b422c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 87 additions and 9 deletions

View File

@ -1,5 +1,17 @@
# Changelog # 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 ## 0.23.0
**THIS UPDATE MAY CONTAINS SOME BREAKING CHANGES (INCLUDING BREAKING CHANGES IN BYTECODE LAYER) RELATED TO UPDATE OF **THIS UPDATE MAY CONTAINS SOME BREAKING CHANGES (INCLUDING BREAKING CHANGES IN BYTECODE LAYER) RELATED TO UPDATE OF

View File

@ -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<Set<CSSRulesHolder>>(emptySet())
val stylesFlow: StateFlow<Set<CSSRulesHolder>> = _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<CSSRulesHolder> = 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)
}

View File

@ -15,5 +15,5 @@ crypto_js_version=4.1.1
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.23.0 version=0.23.1
android_code_version=276 android_code_version=277

View File

@ -6,11 +6,11 @@ kt-coroutines = "1.9.0"
kslog = "1.3.6" kslog = "1.3.6"
jb-compose = "1.7.0" jb-compose = "1.7.1"
jb-exposed = "0.55.0" jb-exposed = "0.56.0"
jb-dokka = "1.9.20" jb-dokka = "1.9.20"
sqlite = "3.46.1.3" sqlite = "3.47.0.0"
korlibs = "5.4.0" korlibs = "5.4.0"
uuid = "0.8.4" uuid = "0.8.4"
@ -23,7 +23,7 @@ koin = "4.0.0"
okio = "3.9.1" okio = "3.9.1"
ksp = "2.0.21-1.0.26" ksp = "2.0.21-1.0.28"
kotlin-poet = "1.18.1" kotlin-poet = "1.18.1"
versions = "0.51.0" versions = "0.51.0"
@ -31,10 +31,10 @@ versions = "0.51.0"
android-gradle = "8.2.2" android-gradle = "8.2.2"
dexcount = "4.0.0" dexcount = "4.0.0"
android-coreKtx = "1.13.1" android-coreKtx = "1.15.0"
android-recyclerView = "1.3.2" android-recyclerView = "1.3.2"
android-appCompat = "1.7.0" android-appCompat = "1.7.0"
android-fragment = "1.8.4" android-fragment = "1.8.5"
android-espresso = "3.6.1" android-espresso = "3.6.1"
android-test = "1.2.1" android-test = "1.2.1"
android-compose-material3 = "1.3.0" android-compose-material3 = "1.3.0"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists