From dd7b5f2bc2892922265bc48851378c72f242b037 Mon Sep 17 00:00:00 2001 From: reveler-hub Date: Thu, 20 Aug 2026 05:12:51 +1200 Subject: [PATCH] Only crossfade the weather screen on an actual location switch AnimatedContent wrapping the whole screen was keyed on the full Weather object, so every plain data refresh (a new Weather instance every time, e.g. a changed lastUpdatedInMilli) triggered the same full-screen fade-out/fade-in as switching to a different location - producing a visible stutter/flash on every successful refresh, even when nothing on screen actually needed to change. Keyed the transition on the location id instead via AnimatedContent's contentKey parameter: a same-location refresh now just recomposes the changed values in place with no animation, while switching locations still gets the intentional crossfade. --- .../weather_master_app/feature/main/MainScreenScaffold.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/main/MainScreenScaffold.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/main/MainScreenScaffold.kt index fe3d60b37..6b83c5244 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/main/MainScreenScaffold.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/main/MainScreenScaffold.kt @@ -134,6 +134,12 @@ fun MainScreenScaffold( ) { AnimatedContent( targetState = weather, + // Keyed on the location, not the whole Weather object: a plain data + // refresh produces a new Weather instance (different lastUpdatedInMilli + // etc.) even when nothing visually changed, which made every refresh + // full-screen crossfade instead of just recomposing the changed values - + // only an actual location switch should get the transition. + contentKey = { it?.location?.id }, transitionSpec = { fadeIn() togetherWith fadeOut() }