Two panes, either side of the fold
FoldAwareTwoPane puts the list on one side of a separating fold and the detail on the other. Flat, the phone shows the list only.
compose multiplatform · android foldables · iphone duo
Crease reads the hinge and the fold on Android foldables and on iPhone Duo. Your Compose layouts split at the fold, stand up in tabletop and keep buttons out of the crease, from one shared codebase.
implementation("io.github.jantursky:crease:1.3.0")
The two sample apps with every control: posture, hinge angle, fold width, the camera cutout and an overlay of what Crease reports.
compatibility
commonMainexamples
Each example runs in a small simulated foldable. Change the posture and the hinge angle, then open the source: it is the file that runs above it.
FoldAwareTwoPane puts the list on one side of a separating fold and the detail on the other. Flat, the phone shows the list only.
TabletopLayout shows the video above a horizontal fold and the controls below it. In any other posture the two stack.
Without a fold, TwoPaneFallback.Stacked puts the chart above its numbers. Fold the device and they move side by side.
Modifier.avoidFold() keeps a dialog on the larger side of the fold, so no button sits in the crease.
rememberHinge() gives the angle and the status, and rememberFoldState() the posture derived from them.
rememberPostureTransition() gives the posture before and after the latest change, and rememberFoldStateFlow().postures() counts the changes. Fold the device and tilt it: the angle alone changes nothing.
The angle is a plain number, so anything can follow it. This lamp dims as the hinge closes and goes out when the device shuts.
FoldState as values: bounds in window pixels, orientation, whether the fold separates and occludes, and the camera cutouts. Try the fold width and the cutout.