Skip to content

Commit

Permalink
use constant map padding and quest form peek height (fixes #6039)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Dec 6, 2024
1 parent f533924 commit bc3f658
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,20 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.ui.theme.AppTheme
import de.westnordost.streetcomplete.ui.theme.getMaxQuestFormWidth
import de.westnordost.streetcomplete.ui.theme.getQuestFormPeekHeight
import de.westnordost.streetcomplete.ui.theme.getOpenQuestFormMapPadding

/** A crosshair at the position at which a new POI should be created */
@Composable
fun Crosshair(modifier: Modifier = Modifier) {
BoxWithConstraints(modifier.fillMaxSize()) {
val isLandscape = maxWidth > maxHeight
val crosshairOffsetX = if (isLandscape) getMaxQuestFormWidth(maxWidth) else 0.dp
val crosshairOffsetY = if (isLandscape) 0.dp else getQuestFormPeekHeight(maxHeight, isLandscape)

Icon(
painter = painterResource(R.drawable.crosshair),
contentDescription = null,
modifier = Modifier
.align(Alignment.Center)
.padding(start = crosshairOffsetX, bottom = crosshairOffsetY),
.padding(getOpenQuestFormMapPadding(maxWidth, maxHeight)),
tint = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.medium)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package de.westnordost.streetcomplete.ui.theme

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

/** Padding on the map due to an open quest form */
fun getOpenQuestFormMapPadding(totalWidth: Dp, totalHeight: Dp, ): PaddingValues {

Check failure on line 8 in app/src/main/java/de/westnordost/streetcomplete/ui/theme/Dimensions.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unexpected whitespace
val isLandscape = totalWidth > totalHeight
return PaddingValues.Absolute(
left = if (isLandscape) getMaxQuestFormWidth(totalWidth) else 0.dp,
top = 0.dp,
right = 0.dp,
bottom = if (isLandscape) 0.dp else 320.dp
)
}

fun getMaxQuestFormWidth(totalWidth: Dp): Dp =
if (totalWidth >= 820.dp) 480.dp
else if (totalWidth >= 600.dp) 360.dp
else 480.dp

fun getQuestFormPeekHeight(totalHeight: Dp, isLandscape: Boolean): Dp =
fun getQuestFormPeekHeight(isLandscape: Boolean): Dp =
if (isLandscape) 540.dp
else if (totalHeight >= 720.dp) 442.dp
else 352.dp
else 400.dp
2 changes: 0 additions & 2 deletions app/src/main/res/values-h720dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="quest_form_peekHeight">442dp</dimen>

<dimen name="street_side_puzzle_height">160dp</dimen>
</resources>
6 changes: 4 additions & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
<dimen name="quest_form_leftOffset">0dp</dimen>
<dimen name="quest_form_topOffset">0dp</dimen>
<dimen name="quest_form_rightOffset">0dp</dimen>
<dimen name="quest_form_bottomOffset">@dimen/quest_form_peekHeight</dimen>
<!-- quest_form_peekHeight but push it down a little (80dp) because there are also buttons
at the top, plus the system bar -->
<dimen name="quest_form_bottomOffset">320dp</dimen>

<dimen name="quest_form_peekHeight">352dp</dimen>
<dimen name="quest_form_peekHeight">400dp</dimen>
<dimen name="quest_form_width">@dimen/match_parent</dimen>

<dimen name="quest_form_speech_bubble_top_margin">-27dp</dimen>
Expand Down

0 comments on commit bc3f658

Please sign in to comment.