Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ fun areBothWindowDimensionsAtLeastMedium(): Boolean {
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
}

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

/***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import com.android.developers.androidify.theme.components.SecondaryOutlinedButto
import com.android.developers.androidify.theme.sharedBoundsRevealWithShapeMorph
import com.android.developers.androidify.theme.sharedBoundsWithDefaults
import com.android.developers.androidify.util.dashedRoundedRectBorder
import com.android.developers.androidify.util.isHorizontalWindow
import com.android.developers.androidify.util.shouldShowHorizontalPhotoPrompt
import com.android.developers.androidify.creation.R as CreationR

@Composable
Expand Down Expand Up @@ -171,7 +171,7 @@ private fun UploadEmptyState(
onChooseImagePress: () -> Unit,
modifier: Modifier = Modifier,
) {
if (isHorizontalWindow()) {
if (shouldShowHorizontalPhotoPrompt()) {
HorizontallyAlignedUploadEmptyState(
onCameraPressed = onCameraPressed,
onChooseImagePress = onChooseImagePress,
Expand Down