Skip to content

Commit

Permalink
Merge branch 'main' into sr-branch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
soulcramer authored Jan 28, 2025
2 parents 5edbe88 + 9edd07a commit 0226ac9
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 50 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
accompanist = "0.36.0"
android-gradlePlugin = "8.7.3"
androidx-activity = "1.9.3"
androidx-activity = "1.10.0"
androidx-appCompat = "1.7.0"
androidx-compose-bom = "2024.12.01"
androidx-compose-bom = "2025.01.00"
androidx-graphics = "1.0.1"
androidx-lifecycle = "2.8.7"
androidx-navigation = "2.8.5"
Expand Down
2 changes: 1 addition & 1 deletion spark-icons/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ androidx.compose.ui:ui-unit:1.7.6
androidx.compose.ui:ui-util-android:1.7.6
androidx.compose.ui:ui-util:1.7.6
androidx.compose.ui:ui:1.7.6
androidx.compose:compose-bom:2024.12.01
androidx.compose:compose-bom:2025.01.00
androidx.concurrent:concurrent-futures:1.1.0
androidx.core:core-ktx:1.12.0
androidx.core:core:1.12.0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions spark/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
androidx.activity:activity-compose:1.9.3
androidx.activity:activity-ktx:1.9.3
androidx.activity:activity:1.9.3
androidx.activity:activity-compose:1.10.0
androidx.activity:activity-ktx:1.10.0
androidx.activity:activity:1.10.0
androidx.annotation:annotation-experimental:1.4.1
androidx.annotation:annotation-jvm:1.8.1
androidx.annotation:annotation:1.8.1
Expand Down Expand Up @@ -49,7 +49,7 @@ androidx.compose.ui:ui-unit:1.7.6
androidx.compose.ui:ui-util-android:1.7.6
androidx.compose.ui:ui-util:1.7.6
androidx.compose.ui:ui:1.7.6
androidx.compose:compose-bom:2024.12.01
androidx.compose:compose-bom:2025.01.00
androidx.concurrent:concurrent-futures:1.1.0
androidx.constraintlayout:constraintlayout-compose-android:1.1.0
androidx.constraintlayout:constraintlayout-compose:1.1.0
Expand Down
13 changes: 2 additions & 11 deletions spark/src/main/kotlin/com/adevinta/spark/tokens/WindowSizeClass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
*/
package com.adevinta.spark.tokens

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import androidx.activity.compose.LocalActivity
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.toComposeRect
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.unit.DpSize
Expand All @@ -54,16 +51,10 @@ internal fun calculateWindowSizeClass(): WindowSizeClass {
val config = LocalConfiguration.current
return WindowSizeClass.calculateFromSize(DpSize(config.screenWidthDp.dp, config.screenHeightDp.dp))
}
val activity = LocalContext.current.findActivity()
val activity = requireNotNull(LocalActivity.current) { "Could not find activity in Context chain." }
LocalConfiguration.current
val density = LocalDensity.current
val metrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(activity)
val size = with(density) { metrics.bounds.toComposeRect().size.toDpSize() }
return WindowSizeClass.calculateFromSize(size)
}

private tailrec fun Context.findActivity(): Activity = when (this) {
is Activity -> this
is ContextWrapper -> this.baseContext.findActivity()
else -> error("Could not find activity in Context chain.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import androidx.compose.ui.Modifier
* @param builder the modifier(s) to apply when [predicate] is true
*/
public inline fun Modifier.ifTrue(predicate: Boolean, builder: Modifier.() -> Modifier): Modifier =
then(if (predicate) this.builder() else Modifier)
then(if (predicate) this.builder() else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [predicate]
Expand All @@ -51,7 +51,7 @@ public inline fun Modifier.ifTrue(predicate: Boolean, builder: Modifier.() -> Mo
* @param builder the modifier(s) to apply when [predicate] is false
*/
public inline fun Modifier.ifFalse(predicate: Boolean, builder: Modifier.() -> Modifier): Modifier =
then(if (!predicate) this.builder() else Modifier)
then(if (!predicate) this.builder() else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [value] nullability
Expand All @@ -66,7 +66,7 @@ public inline fun Modifier.ifFalse(predicate: Boolean, builder: Modifier.() -> M
* @param builder the modifier(s) to apply when [value] is not null
*/
public inline fun <T : Any> Modifier.ifNotNull(value: T?, builder: Modifier.(T) -> Modifier): Modifier =
then(if (value != null) this.builder(value) else Modifier)
then(if (value != null) this.builder(value) else this)

/**
* Modifier to make it easy to conditionally add a modifier based on [value] nullability
Expand All @@ -81,4 +81,4 @@ public inline fun <T : Any> Modifier.ifNotNull(value: T?, builder: Modifier.(T)
* @param builder the modifier(s) to apply when [value] is null
*/
public inline fun <T : Any> Modifier.ifNull(value: T?, builder: Modifier.() -> Modifier): Modifier =
then(if (value == null) this.builder() else Modifier)
then(if (value == null) this.builder() else this)

0 comments on commit 0226ac9

Please sign in to comment.