Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): hide onboarding images that are likely to collide with text #770

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Changes from 2 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 @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.absoluteOffset
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
Expand All @@ -44,6 +45,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.isGranted
import com.mbta.tid.mbta_app.android.MyApplicationTheme
Expand Down Expand Up @@ -131,7 +133,7 @@ fun OnboardingScreenView(
-((screenHeight / 2f) - (screenHeight / 3f))
}
val haloOffsetDp = with(LocalDensity.current) { haloOffset.roundToInt().toDp() }
val buttonModifier = Modifier.fillMaxWidth().height(52.dp)
val buttonModifier = Modifier.fillMaxWidth().heightIn(min = 52.dp)
val haloTransition = rememberInfiniteTransition(label = "infinite")
val haloSizeMultiplier =
haloTransition.animateFloat(
Expand All @@ -151,38 +153,42 @@ fun OnboardingScreenView(
locationHaloSize.roundToInt().toDp() * haloSizeMultiplier.value
}

val textScale = with(LocalDensity.current) { 1.sp.toPx() / 1.dp.toPx() }

Column {
when (screen) {
OnboardingScreen.Feedback -> {

Box(modifier = Modifier.fillMaxSize()) {
Image(
painterResource(
if (isDarkTheme) {
R.drawable.onboarding_more_button_dark
} else {
R.drawable.onboarding_more_button
}
),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().align(Alignment.Center)
)
Image(
painterResource(
if (isDarkTheme) {
R.drawable.onboarding_halo_dark
} else {
R.drawable.onboarding_halo
}
),
contentDescription = null,
modifier =
Modifier.width(moreHaloSizeDp)
.height(moreHaloSizeDp)
.absoluteOffset(y = haloOffsetDp)
.align(Alignment.Center)
)
Box(modifier = Modifier.fillMaxSize().background(colorResource(R.color.fill2))) {
if (textScale < 1.9f) {
Image(
painterResource(
if (isDarkTheme) {
R.drawable.onboarding_more_button_dark
} else {
R.drawable.onboarding_more_button
}
),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().align(Alignment.Center)
)
Image(
painterResource(
if (isDarkTheme) {
R.drawable.onboarding_halo_dark
} else {
R.drawable.onboarding_halo
}
),
contentDescription = null,
modifier =
Modifier.width(moreHaloSizeDp)
.height(moreHaloSizeDp)
.absoluteOffset(y = haloOffsetDp)
.align(Alignment.Center)
)
}
Column(
modifier =
Modifier.align(Alignment.BottomCenter)
Expand All @@ -204,7 +210,7 @@ fun OnboardingScreenView(
)
Spacer(modifier = Modifier.height(16.dp))
Button(
modifier = Modifier.fillMaxWidth().height(52.dp),
modifier = buttonModifier,
onClick = advance,
shape = RoundedCornerShape(8.dp),
) {
Expand Down Expand Up @@ -258,10 +264,7 @@ fun OnboardingScreenView(
}
Spacer(modifier = Modifier.weight(1f))
Button(
modifier =
Modifier.fillMaxWidth()
.height(52.dp)
.padding(start = 32.dp, end = 32.dp),
modifier = buttonModifier.padding(start = 32.dp, end = 32.dp),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want the 32 padding on all the buttons if that was the thing causing the line breaks that messed up formatting? 16 seems reasonable and safer, but not a huge deal either way, these all need to just be their own composable, which we shouldn't spend time on now 🤷

Copy link
Member Author

@boringcactus boringcactus Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't; 16 across all buttons might be the better move there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered that, but wasn't sure if it was ok to be adding back some of the padding around the Text that was removed in #754 for the elevator accessibility buttons (not sure why just those had the padding on the text rather than the button, maybe that was part of the problem).

Copy link
Member Author

@boringcactus boringcactus Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, no, the weird inconsistencies between these buttons are annoying to disentangle here, and the right fix is a more comprehensive refactor anyway. The one that's most likely to wrap is "Show elevator closures", and that one's getting its padding removed in #754 anyway.

shape = RoundedCornerShape(8.dp),
onClick = { hideMaps(true) },
) {
Expand All @@ -274,8 +277,7 @@ fun OnboardingScreenView(
Spacer(modifier = Modifier.height(16.dp))
Button(
modifier =
Modifier.fillMaxWidth()
.height(52.dp)
buttonModifier
.padding(start = 32.dp, end = 32.dp)
.border(
1.dp,
Expand Down Expand Up @@ -316,37 +318,39 @@ fun OnboardingScreenView(
contentScale = ContentScale.Crop
),
) {
Image(
painter =
painterResource(
id =
if (isDarkTheme) {
R.drawable.onboarding_transit_lines_dark
} else {
R.drawable.onboarding_transit_lines
}
),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.align(Alignment.Center).fillMaxSize()
)
Image(
painter =
painterResource(
id =
if (isDarkTheme) {
R.drawable.onboarding_halo_dark
} else {
R.drawable.onboarding_halo
}
),
contentDescription = null,
modifier =
Modifier.align(Alignment.Center)
.width(locationHaloSizeDp)
.height(locationHaloSizeDp)
.absoluteOffset(y = haloOffsetDp)
)
if (textScale < 1.5f) {
Image(
painter =
painterResource(
id =
if (isDarkTheme) {
R.drawable.onboarding_transit_lines_dark
} else {
R.drawable.onboarding_transit_lines
}
),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.align(Alignment.Center).fillMaxSize()
)
Image(
painter =
painterResource(
id =
if (isDarkTheme) {
R.drawable.onboarding_halo_dark
} else {
R.drawable.onboarding_halo
}
),
contentDescription = null,
modifier =
Modifier.align(Alignment.Center)
.width(locationHaloSizeDp)
.height(locationHaloSizeDp)
.absoluteOffset(y = haloOffsetDp)
)
}
Column(
modifier =
Modifier.align(Alignment.BottomCenter)
Expand Down Expand Up @@ -402,14 +406,17 @@ fun OnboardingScreenView(
contentScale = ContentScale.Crop
),
) {
Image(
painter = painterResource(id = R.drawable.accessibility_icon_accessible),
contentDescription = null,
modifier =
Modifier.align(Alignment.Center)
.size(192.dp)
.absoluteOffset(y = haloOffsetDp)
)
if (textScale < 2f) {
Image(
painter =
painterResource(id = R.drawable.accessibility_icon_accessible),
contentDescription = null,
modifier =
Modifier.align(Alignment.Center)
.size(192.dp)
.absoluteOffset(y = haloOffsetDp)
)
}
Column(
modifier =
Modifier.align(Alignment.BottomCenter)
Expand All @@ -431,7 +438,7 @@ fun OnboardingScreenView(
)

Button(
modifier = Modifier.fillMaxWidth().height(52.dp),
modifier = buttonModifier,
shape = RoundedCornerShape(8.dp),
onClick = { showStationAccessibility(true) },
colors =
Expand All @@ -449,13 +456,11 @@ fun OnboardingScreenView(
}
Button(
modifier =
Modifier.fillMaxWidth()
.height(52.dp)
.border(
1.dp,
color = colorResource(R.color.key),
shape = RoundedCornerShape(8.dp)
),
buttonModifier.border(
1.dp,
color = colorResource(R.color.key),
shape = RoundedCornerShape(8.dp)
),
shape = RoundedCornerShape(8.dp),
onClick = { showStationAccessibility(false) },
colors =
Expand Down