Status Update
Comments
f....@gmail.com <f....@gmail.com> #2
Oh sorry, this should be marked as a feature request.
f....@gmail.com <f....@gmail.com> #3
This is really easy to implement, and I've made a patch just by adapting the code for FabPosition.End
. The only thing is that I can't produce the screenshots for the testing code to use.
Could someone please have a look at this and try to merge it? The changes to actual Compose (not test) code are literally like this, it's so simple:
# androidx-main/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
401a402
> FabPosition.Start -> FabStartSpacing.roundToPx()
416a418
> private val FabStartSpacing = 16.dp
# androidx-main/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
79a80,85
> * Position FAB at the bottom of the screen at the start, above the [BottomAppBar] (if it
> * exists)
> */
> Start,
>
> /**
265a272,277
> }
> else if (fabPosition == FabPosition.Start) {
> if (layoutDirection == LayoutDirection.Ltr) {
> FabSpacing.roundToPx()
> } else {
> layoutWidth - FabSpacing.roundToPx() - fabWidth
Thank you very much.
ni...@google.com <ni...@google.com> #4
ma...@google.com <ma...@google.com> #5
Assigning to Max, it might be a good task to start rumping up on APIs
ma...@google.com <ma...@google.com> #6
Experimented with adding Start alignment but it conflicts with the hamburger menu in the bottom bar. Can we get UX to weigh in on how/if we can work around this? If we decide to support this, it'll most likely require an update to the Material spec
ay...@google.com <ay...@google.com> #7
Hey Max, nice work!
Can you explain why this adopter is looking to have a left aligned FAB? That information will help me evaluate if this pattern is an acceptable user experience and where the hamburger menu could be placed.
ma...@google.com <ma...@google.com> #8
I believe the user has explained the use case as well as provided a screen shot in
f....@gmail.com <f....@gmail.com> #9
As someone named Max myself, I'd also like to say nice work to my fellow Max for the progress on this.
To explain the use case further, I am presenting numerical data on the 'end' side of the bottom sheet, which naturally leaves space on the 'start' end and makes it awkward to place the FAB anywhere else (I have tried). I've attached a screenshot with the FAB in the Start position as I intend. In landscape mode, as you can see, it becomes even more critical to place the FAB at the start because the vertical space is at a premium.
Another point is, assuming a right handed user using their thumb in portrait mode, it's actually a lot easier to tap a FAB on the lower-left hand side of the screen, than one on the lower-right hand side. So IMO the FAB position should be allowed on either side of the screen.
Regarding the hamburger menu, can it just stay at the top left in this case? I don't see how the ability to place a hamburger menu on the bottom left implies that it should be impossible (using the API) to place a FAB there instead.
ay...@google.com <ay...@google.com> #10
Hey all, apologies for the lag time on my end. This is an acceptable modification for the FAB given the content in the bottom sheet.
ma...@google.com <ma...@google.com> #11
Hey Ayan, can you clarify the expected behavior of the screenshot in
ay...@google.com <ay...@google.com> #12
Sorry I missed your question in #6, Max!
One alternative solution is swapping the start placement for the hamburger menu (and icon) to the right. This could result in awkward UX, so I wouldn't advise we add this use case to spec.
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #13
Branch: androidx-main
commit cc2b03e66b081b4b7425e58fdb1fc9209acace9a
Author: Max Alfonso-Ying <maxying@google.com>
Date: Wed Jun 14 19:18:03 2023
Add 'Start' position for FabPosition
Relnote: Added new Start alignment for FabPosition
Fixes:
Test: ScaffoldTest, BottomSheetScaffoldTest, ScaffoldScreenshotTest
Change-Id: Ib7aea97d6ac5c6ee33fd10916c74c540ff5889de
M compose/material/material/api/current.txt
M compose/material/material/api/restricted_current.txt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomSheetScaffoldTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
M compose/material3/material3/api/current.txt
M compose/material3/material3/api/restricted_current.txt
M compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/ScaffoldTest.kt
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/Scaffold.kt
na...@google.com <na...@google.com> #14
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.material:material:1.6.0-alpha02
androidx.compose.material:material-android:1.6.0-alpha02
androidx.compose.material3:material3:1.2.0-alpha04
androidx.compose.material3:material3-android:1.2.0-alpha04
Description
Hi, I just migrated to the Compose implementation of
BottomSheetScaffold
today, but found I couldn't place the FAB on the left side of the screen using thefloatingActionButtonPosition=
argument ofBottomSheetScaffold
.In my app, the FAB needs to be placed on the left side of the screen and can't be placed on the right or in the middle, as you can see in the screenshot.
So I would like to request that a 'Start' position is added to the FabPosition enum.
Thank you.