material-components / material-components/material-components-android
[BottomSheetBehavior] Giving touch priority to a nested bottom sheet
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 17.4k
- Forks
- 3.2k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Is your feature request related to a problem? Please describe.
My app uses two bottom sheets, one nested into the other. Overall, there are few issues with it, except for the fact that the container bottom sheet intercepts most touch and nested scrolling events to it, preventing me from swiping up the nested sheet if there is a scrolling view within it, and preventing me from swiping down the nested sheet normally once it is expanded.
Describe the solution you'd like
An attribute like behavior_nestedBottomSheetId that allows me to specify the ID of a nested bottom sheet within the layout. The parent bottom sheet would then check for that ID, see if the touch/nested scrolling event actually applies to the nested sheet, and then delegate to the nested sheet instead of consuming the
Describe alternatives you've considered
I can hack in a kind of touch priority with the following override in the container bottom sheet:
override fun onInterceptTouchEvent(
parent: CoordinatorLayout,
child: V,
event: MotionEvent
): Boolean = super.onInterceptTouchEvent(parent, child, event) && state != STATE_EXPANDED // Do not consume nested scrolling events when expanded so they are delegated to the nested sheet
And the following code in a BottomSheetCallback:
containerBottomSheetBehavior.isDraggable = nestedBottomSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED // if nested sheet is expanded, do not intercept dragging downwards
But I don't really feel like these will work correctly in all cases compared to a native solution for handling touch events.
Additional context
I can understand if you reject this, since I think nesting sheets like this is not really expected by the library. If you want me to file more particular bug reports for the issues I encountered, that is also okay.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit BottomSheetBehavior.onInterceptTouchEvent und dem im Issue beschriebenen Verhalten beim verschachtelten Scrollen. Verfolge, wie ein übergeordnetes und ein verschachteltes Bottom Sheet Touch- und Scroll-Ereignisse empfangen, und definiere und teste anschließend das vorgeschlagene Prioritätsverhalten für verschachtelte Sheets, einschließlich expandierter und kollabierter Zustände.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, kotlin
- Bereich
- mobile
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100