Skip to content

Support edge-to-edge content#412

Merged
vinaygaba merged 5 commits intoairbnb:masterfrom
mataku:feature/edge
Aug 17, 2025
Merged

Support edge-to-edge content#412
vinaygaba merged 5 commits intoairbnb:masterfrom
mataku:feature/edge

Conversation

@mataku
Copy link
Contributor

@mataku mataku commented Jul 3, 2025

Context

Closes #399

TargetSDK 35 app requires edge-to-edge support. Of course, it's possible to opt out, but it's better to do it anyway because support is needed by TargetSDK 36, and contents will be natural if supported.

Changes

  • Support edge-to-edge in ShowkaseBrowserActivity and ShowkaseBrowserApp
    • Showkase uses material2, so I added safeDrawingPadding for composable component
  • Set targetsdk to 35 in the sample project
  • Apply enableEdgeToEdge to ensure that it applies to both OS 14 and below and 15

Notes

I tried to change to use TopAppBar instead of Row use for toolbar, but I just found comments:

/**
* Commented out due to TopAppBar not working properly in beta-01 for this use case. Seems to be
* related to use to Surface inside TopAppBar and a TextField. Creating my own implementation
* for now. Will uncomment if this issue gets fixed.
*/

TopAppBar seems to work, but ShowkaseBrowserTest failed, so I kept using custom Row.

Screenshots

OS 14 OS 14 with gesture nav
OS 15 OS 15 with gesture nav

@mataku mataku marked this pull request as ready for review July 3, 2025 15:59
Comment on lines +166 to +176
* for now. Will uncomment if this issue gets fixed.
* for now. Wil
* l uncomment if this issue gets fixed.

Choose a reason for hiding this comment

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

I guess it is not wanted 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦
Thanks! fixed: cba224c

Copy link

@olivierperez olivierperez left a comment

Choose a reason for hiding this comment

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

I'm not a maintainer of this repository but I also would like this PR to be merged ^^

Comment on lines 95 to 98
Surface(
color = Color.White
) {
Scaffold(

Choose a reason for hiding this comment

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

Another thing, I think you need to fix the indent of this file.
The Scaffold should be indented, and later in the file a } is misplaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. fixed: 5890e6e

import com.airbnb.android.showkase.models.insideGroup
import com.airbnb.android.showkase.ui.SemanticsUtils.lineCountVal

@SuppressLint("UnusedMaterialScaffoldPaddingParameter")

Choose a reason for hiding this comment

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

👍

@vinaygaba
Copy link
Collaborator

@mataku Can you tell me what the test failure was when you attempted to use TopAppBar? This code path was written back in ~2021 before even the first stable release of Compose so the APIs were not as reliable as they are now. I'd love to use out of the box solutions wherever possible.

mataku added 2 commits August 4, 2025 13:48
material2 TopAppBar's height is 56dp, so we couldn't set maxLines to 2 or over
@mataku
Copy link
Contributor Author

mataku commented Aug 4, 2025

@vinaygaba
Showkase AppBar supports up to three lines of display and includes a unit test to verify that the correct lines are displayed.

@Composable
fun ToolbarTitle(
string: String,
modifier: Modifier
) {
val lineCount = remember {
mutableStateOf(0)
}
Text(
text = string,
modifier = modifier then Modifier
.padding(vertical = verticalToolbarPadding)
.semantics {
lineCountVal = lineCount.value
},
style = TextStyle(
fontSize = 20.sp,
fontFamily = FontFamily.Monospace,
fontWeight = FontWeight.Bold
),
maxLines = 3,
overflow = TextOverflow.Ellipsis,
onTextLayout = {
lineCount.value = it.lineCount
}
)
}

> Task :showkase-browser-testing:connectedDebugAndroidTest

com.airbnb.android.showkase_browser_testing.ShowcaseBrowserTest > components_with_long_names_have_a_correct_top_app_bar

See details: https://github.com/airbnb/Showkase/actions/runs/16053765228/job/45302791177


The height of the material2 AppBar is fixed at 56 dp, so it appears that it cannot display multiple lines, and uses a custom component for now.

master branch with long text TopAppBar use with long text (in this branch)
master top_app_bar_use

@vinaygaba
Copy link
Collaborator

@mataku this rings a bell and iirc was an intentional choice to show longer component names. I think we can keep it as is and we should be good to merge once all the tests pass.

@mataku
Copy link
Contributor Author

mataku commented Aug 8, 2025

I agree. If it is changed, using the m3 AppBar would make a multi-line display much easier.

@vinaygaba vinaygaba merged commit 0fbde2f into airbnb:master Aug 17, 2025
4 checks passed
@mataku mataku deleted the feature/edge branch August 17, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android 15 edge-to-edge enforcement support

3 participants