Skip to content

Commit

Permalink
Merge pull request #453 from android/mlykotom/fix-perf-codelab-constr…
Browse files Browse the repository at this point in the history
…aints

Fix performance codelab end state
  • Loading branch information
mlykotom authored May 14, 2024
2 parents 92c0744 + bb8cdbc commit b9f3d65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion PerformanceCodelab/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ composeCompiler {
// This settings enables strong-skipping mode for all module in this project.
// As an effect, Compose can skip a composable even if it's unstable by comparing it's instance equality (===).
// TODO Codelab task: Enable Strong Skipping Mode
enableStrongSkippingMode = false
enableStrongSkippingMode = true

// TODO Codelab task: Enable Stability Configuration file
stabilityConfigurationFile = project.rootDir.resolve("stability_config.conf")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ fun MyShape(size: () -> Dp, modifier: Modifier = Modifier) = trace("MyShape") {
val sizePx = size()
.roundToPx()
.coerceAtLeast(0)
val constraints = Constraints(
minWidth = sizePx,
maxWidth = sizePx,
minHeight = sizePx,
maxHeight = sizePx

val constraints = Constraints.fixed(
width = sizePx,
height = sizePx,
)

val placeable = measurable.measure(constraints)
layout(sizePx, sizePx) {
placeable.place(0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.compose.performance.stability

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.neverEqualPolicy
Expand All @@ -32,6 +33,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn

// TODO Codelab task: make this class Stable
@Immutable
data class StabilityItem(
val id: Int,
val type: StabilityItemType,
Expand Down
2 changes: 2 additions & 0 deletions PerformanceCodelab/stability_config.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// TODO Codelab task: Make a java.time.LocalDate class stable.

java.time.LocalDate

0 comments on commit b9f3d65

Please sign in to comment.