Skip to content

Commit e7fb99f

Browse files
committed
Fix Horizontal layout
1 parent cbb7794 commit e7fb99f

File tree

2 files changed

+11
-4
lines changed
  • core/util/src/main/java/com/android/developers/androidify/util
  • feature/creation/src/main/java/com/android/developers/androidify/creation

2 files changed

+11
-4
lines changed

core/util/src/main/java/com/android/developers/androidify/util/LayoutUtils.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ fun areBothWindowDimensionsAtLeastMedium(): Boolean {
5050
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
5151
}
5252

53+
/***
54+
* This function is useful to understand if the window is too small to show the vertically stacked
55+
* photo empty state. It should align items horizontally only if the window is horizontal and
56+
* if the amount of vertical space is smaller than medium
57+
*/
5358
@Composable
54-
fun isHorizontalWindow(): Boolean {
59+
fun shouldShowHorizontalPhotoPrompt(): Boolean {
5560
val sizeClass = calculateWindowSizeClass()
56-
return sizeClass.minWidthDp >= sizeClass.minHeightDp
61+
val isHorizontalWindow = sizeClass.minWidthDp >= sizeClass.minHeightDp
62+
val isHeightSmallerThanMedium = !sizeClass.isHeightAtLeastBreakpoint(WindowSizeClass.HEIGHT_DP_MEDIUM_LOWER_BOUND)
63+
return isHorizontalWindow && isHeightSmallerThanMedium
5764
}
5865

5966
/***

feature/creation/src/main/java/com/android/developers/androidify/creation/PhotoPrompt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import com.android.developers.androidify.theme.components.SecondaryOutlinedButto
9898
import com.android.developers.androidify.theme.sharedBoundsRevealWithShapeMorph
9999
import com.android.developers.androidify.theme.sharedBoundsWithDefaults
100100
import com.android.developers.androidify.util.dashedRoundedRectBorder
101-
import com.android.developers.androidify.util.isHorizontalWindow
101+
import com.android.developers.androidify.util.shouldShowHorizontalPhotoPrompt
102102
import com.android.developers.androidify.creation.R as CreationR
103103

104104
@Composable
@@ -171,7 +171,7 @@ private fun UploadEmptyState(
171171
onChooseImagePress: () -> Unit,
172172
modifier: Modifier = Modifier,
173173
) {
174-
if (isHorizontalWindow()) {
174+
if (shouldShowHorizontalPhotoPrompt()) {
175175
HorizontallyAlignedUploadEmptyState(
176176
onCameraPressed = onCameraPressed,
177177
onChooseImagePress = onChooseImagePress,

0 commit comments

Comments
 (0)