@@ -84,6 +84,7 @@ import androidx.compose.ui.unit.dp
8484import androidx.compose.ui.unit.sp
8585import androidx.graphics.shapes.RoundedPolygon
8686import androidx.graphics.shapes.rectangle
87+ import androidx.window.core.layout.WindowSizeClass
8788import coil3.compose.AsyncImage
8889import coil3.request.ImageRequest
8990import coil3.request.crossfade
@@ -97,8 +98,8 @@ import com.android.developers.androidify.theme.components.ScaleIndicationNodeFac
9798import com.android.developers.androidify.theme.components.SecondaryOutlinedButton
9899import com.android.developers.androidify.theme.sharedBoundsRevealWithShapeMorph
99100import com.android.developers.androidify.theme.sharedBoundsWithDefaults
101+ import com.android.developers.androidify.util.calculateWindowSizeClass
100102import com.android.developers.androidify.util.dashedRoundedRectBorder
101- import com.android.developers.androidify.util.isHorizontalWindow
102103import com.android.developers.androidify.creation.R as CreationR
103104
104105@Composable
@@ -171,7 +172,7 @@ private fun UploadEmptyState(
171172 onChooseImagePress : () -> Unit ,
172173 modifier : Modifier = Modifier ,
173174) {
174- if (isHorizontalWindow ()) {
175+ if (shouldShowHorizontalPhotoPrompt ()) {
175176 HorizontallyAlignedUploadEmptyState (
176177 onCameraPressed = onCameraPressed,
177178 onChooseImagePress = onChooseImagePress,
@@ -186,6 +187,19 @@ private fun UploadEmptyState(
186187 }
187188}
188189
190+ /* **
191+ * This function is useful to understand if the window is too small to show the vertically stacked
192+ * photo empty state. It should align items horizontally only if the window is horizontal and
193+ * if the amount of vertical space is smaller than medium
194+ */
195+ @Composable
196+ fun shouldShowHorizontalPhotoPrompt (): Boolean {
197+ val sizeClass = calculateWindowSizeClass()
198+ val isHorizontalWindow = sizeClass.minWidthDp >= sizeClass.minHeightDp
199+ val isHeightSmallerThanMedium = ! sizeClass.isHeightAtLeastBreakpoint(WindowSizeClass .HEIGHT_DP_MEDIUM_LOWER_BOUND )
200+ return isHorizontalWindow && isHeightSmallerThanMedium
201+ }
202+
189203@Composable
190204private fun VerticallyAlignedUploadEmptyState (
191205 onCameraPressed : () -> Unit ,
0 commit comments