Skip to content

Commit

Permalink
Merge pull request #513 from InsanusMokrassar/0.23.1
Browse files Browse the repository at this point in the history
0.23.1
  • Loading branch information
InsanusMokrassar authored Nov 25, 2024
2 parents 1dca5ea + e5f4ae6 commit 24347b4
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,18 +23,18 @@ 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"

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"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 24347b4

Please sign in to comment.