Skip to content

fix(mobile): photo grid reflows on foldable display fold/unfold#24529

Closed
mmolehant-tech wants to merge 1 commit intoimmich-app:mainfrom
mmolehant-tech:fix/foldable-grid-reflow
Closed

fix(mobile): photo grid reflows on foldable display fold/unfold#24529
mmolehant-tech wants to merge 1 commit intoimmich-app:mainfrom
mmolehant-tech:fix/foldable-grid-reflow

Conversation

@mmolehant-tech
Copy link

@mmolehant-tech mmolehant-tech commented Dec 11, 2025

Summary

  • Fixes photo grid not reflowing when switching between folded and unfolded displays on foldable devices
  • Adds ValueKey to ProviderScope in timeline widget to force widget rebuild when screen dimensions change significantly

Root Cause

The LayoutBuilder in timeline.widget.dart correctly rebuilds with new constraints when the screen size changes, but the child ProviderScope had no key. This caused Flutter to reuse the existing widget state instead of creating a new one with the updated dimensions.

Solution

Added a ValueKey based on rounded dimensions (divided by 50 to avoid rebuilds for tiny changes). When the key changes significantly (e.g., on fold/unfold), Flutter discards and recreates the widget subtree, properly propagating the new dimensions.

Test plan

  • Open app on foldable device in folded state
  • Unfold device - grid should immediately reflow to fill the screen
  • Fold device - grid should reflow back to smaller layout
  • Pinch-to-zoom still works after fold/unfold

Fixes #20466

Fixes immich-app#20466

The photo grid now properly reflows when switching between folded and
unfolded displays on foldable devices. Previously, the grid would remain
stuck in the layout from when the app was opened.

The fix adds a ValueKey to the ProviderScope based on significant
dimension changes (50+ pixels), which forces Flutter to recreate the
timeline widget tree when the screen size changes during fold/unfold.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@YarosMallorca
Copy link
Collaborator

YarosMallorca commented Dec 12, 2025

This works, but it essentially rebuilds the whole timeline, causing it to reset to the top.
I'll let @shenlong-tanwen decide if this is acceptable or not.

@bkchr
Copy link
Contributor

bkchr commented Jan 6, 2026

#25088 created a different version that keeps the current position in the view.

@shenlong-tanwen
Copy link
Member

As @YarosMallorca, This just causes the timeline to be reloaded and that is not something that we want. Closing this in favour of #24573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[beta] The app does not reflow layout when switching between folded and unfolded displays on foldable devices.

5 participants