Repository navigation
Conversation
Introduce a new KMP module `salt-adaptive-window` under package `com.moriafly.salt.adaptive.window` that lets code determine the device screen form factor and the available window size class at runtime. Public API: - `DeviceFormFactor` (Phone, Tablet, Foldable, Desktop, Car, Unknown) - `WindowSizeClass` (Compact, Medium, Expanded) at the Material 3 breakpoints <600dp / 600-840dp / >=840dp - `SaltAdaptiveWindow(formFactor, sizeClass)` - `LocalSaltAdaptiveWindow` for ambient access from deeply nested code - `currentSaltAdaptiveWindow()` as the platform `expect`/`actual` source Why a separate module rather than reusing material3-adaptive: Google's `androidx.compose.material3.adaptive` is Android-only and deliberately has no device-type concept, but this library also targets desktop JVM and iOS, where "desktop" is a real distinct form factor. `DeviceFormFactor` is therefore documented as an interaction signal only (touch vs pointer), and layout breakpoints must be driven by `sizeClass`, because a tablet in split-screen can still have a Compact window. `LocalSaltAdaptiveWindow` defaults to `error(...)` instead of a silent fallback, matching `LocalSaltWindowInfo` in ui2: reading it without a provider is a wiring mistake and should fail loudly rather than report a wrong form factor. The provider wiring is intentionally not part of this change. Naming follows the current Google convention of a `current` prefix for a @composable that recomputes on every recomposition rather than caching, so no `remember` is claimed that does not happen. Platform detection: - Android: `PackageManager.FEATURE_AUTOMOTIVE` for car and `FEATURE_SENSOR_HINGE_ANGLE` for foldable, both behind SDK_INT guards (minSdk 23), plus the platform's own sw600dp tablet qualifier. The foldable check is documented as a heuristic, since without a Jetpack WindowManager dependency the hinge angle sensor is the only signal the platform exposes. - Desktop: constant `Desktop` form factor, size class from `LocalWindowInfo` so it tracks window resizes. - iOS: `UIDevice.userInterfaceIdiom` mapped to Phone/Tablet/Car, size class read from the window rather than the screen so it stays correct under iPad Split View and Stage Manager. Validation: `compileAndroidMain`, `compileKotlinDesktop`, `compileKotlinIosArm64` and `compileKotlinIosSimulatorArm64` all pass.
Moriafly
marked this pull request as draft
September 23, 2026 13:16
GaodaGG
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a new KMP module
salt-adaptive-windowunder packagecom.moriafly.salt.adaptive.windowthat lets code determine the device screen form factor and the available window size class at runtime.Public API:
DeviceFormFactor(Phone, Tablet, Foldable, Desktop, Car, Unknown)WindowSizeClass(Compact, Medium, Expanded) at the Material 3 breakpoints <600dp / 600-840dp / >=840dpSaltAdaptiveWindow(formFactor, sizeClass)LocalSaltAdaptiveWindowfor ambient access from deeply nested codecurrentSaltAdaptiveWindow()as the platformexpect/actualsourceWhy a separate module rather than reusing material3-adaptive: Google's
androidx.compose.material3.adaptiveis Android-only and deliberately has no device-type concept, but this library also targets desktop JVM and iOS, where "desktop" is a real distinct form factor.DeviceFormFactoris therefore documented as an interaction signal only (touch vs pointer), and layout breakpoints must be driven bysizeClass, because a tablet in split-screen can still have a Compact window.LocalSaltAdaptiveWindowdefaults toerror(...)instead of a silent fallback, matchingLocalSaltWindowInfoin ui2: reading it without a provider is a wiring mistake and should fail loudly rather than report a wrong form factor. The provider wiring is intentionally not part of this change.Naming follows the current Google convention of a
currentprefix for a @composable that recomputes on every recomposition rather than caching, so norememberis claimed that does not happen.Platform detection:
PackageManager.FEATURE_AUTOMOTIVEfor car andFEATURE_SENSOR_HINGE_ANGLEfor foldable, both behind SDK_INT guards (minSdk 23), plus the platform's own sw600dp tablet qualifier. The foldable check is documented as a heuristic, since without a Jetpack WindowManager dependency the hinge angle sensor is the only signal the platform exposes.Desktopform factor, size class fromLocalWindowInfoso it tracks window resizes.UIDevice.userInterfaceIdiommapped to Phone/Tablet/Car, size class read from the window rather than the screen so it stays correct under iPad Split View and Stage Manager.Validation:
compileAndroidMain,compileKotlinDesktop,compileKotlinIosArm64andcompileKotlinIosSimulatorArm64all pass.