Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,12 +50,6 @@ fun areBothWindowDimensionsAtLeastMedium(): Boolean {
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
}

@Composable
fun isHorizontalWindow(): Boolean {
val sizeClass = calculateWindowSizeClass()
return sizeClass.minWidthDp >= sizeClass.minHeightDp
}

/***
* This function is useful to limit the number of buttons when the window is too small to show
* everything that should otherwise appear on the screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.graphics.shapes.RoundedPolygon
import androidx.graphics.shapes.rectangle
import androidx.window.core.layout.WindowSizeClass
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import coil3.request.crossfade
Expand All @@ -97,8 +98,8 @@ import com.android.developers.androidify.theme.components.ScaleIndicationNodeFac
import com.android.developers.androidify.theme.components.SecondaryOutlinedButton
import com.android.developers.androidify.theme.sharedBoundsRevealWithShapeMorph
import com.android.developers.androidify.theme.sharedBoundsWithDefaults
import com.android.developers.androidify.util.calculateWindowSizeClass
import com.android.developers.androidify.util.dashedRoundedRectBorder
import com.android.developers.androidify.util.isHorizontalWindow
import com.android.developers.androidify.creation.R as CreationR

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

/***
* 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 shouldShowHorizontalPhotoPrompt(): Boolean {
val sizeClass = calculateWindowSizeClass()
val isHorizontalWindow = sizeClass.minWidthDp >= sizeClass.minHeightDp
val isHeightSmallerThanMedium = !sizeClass.isHeightAtLeastBreakpoint(WindowSizeClass.HEIGHT_DP_MEDIUM_LOWER_BOUND)
return isHorizontalWindow && isHeightSmallerThanMedium
}

@Composable
private fun VerticallyAlignedUploadEmptyState(
onCameraPressed: () -> Unit,
Expand Down