[TIMOB-28489] iOS 15/Android: Add cross-platform page sheet component
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Unknown |
Created | 2021-06-12T13:02:26.000+0000 |
Updated | 2021-11-11T15:57:01.000+0000 |
Description
iOS 15 finally adds support for medium-sized modal page sheet (like the BottomSheet component on Android), it is also swipeable and therefore could be a great cross-platform API.
A first test for Android: [demo video](https://migaweb.de/ti_bottomsheet.mp4) Idea for properties, events, methods: * method: toggle (to show hide it) * method: addView (adding content) * event: stateChanged (e.g. after toggle) * property: peekHeight ("height" when collpased)
Start for Android: https://github.com/appcelerator/titanium_mobile/pull/12966 Not sure what iOS can do and how we should call methods and so on. But it's a start and don't want to lose that code ;)
[~michael], on iOS, Titanium devs can already do this today via a "modal"
Ti.UI.Window
using a bottom sheet style. The Android equivalent to this would be the JavaBottomSheetDialog
, but I wouldn't want to attempt parity on Android with a modalActivity
which doesn't quite work the same. Maybe we need introduce 2 different Titanium types? *Ti.UI.BottomSheetView
which you add to aTi.UI.Window
. The idea is you can tap outside the bottom sheet without collapsing it. *Ti.UI.BottomSheetDialog
where tapping outside of it would automatically close it. (Or maybe this should be a "style" applied toAlertDialog
?)That sounds like a good idea. I had the BottomSheetDialog running already, too. But since there is https://github.com/hansemannn/titanium-android-bottom-sheet I switched to the normal view. But I like the style idea but perhaps for the OptionDialog
My 2 cents: The new iOS 15 API is definitely also window-based, not view based. Actually, it's just a simple property in the
open({ ... })
settings, likemodalStyle
. Therefore, for a "real" bottom sheet, the base should always be a window (or a view that is internally added / opened as a window). In any case, I'd vote for theTi.UI.BottomSheetDialog
and do the parity under the hood: Use similar code like in my module for Android and add the view to a natively-create TiUIWindowProxy for iOS. Doable![~hknoechel], I agree with you. Implementing a
Ti.UI.BottomSheetDialog
is probably the way to go. Or should we call it aPageSheetDialog
? I haven't checked how it works on iPad. Maybe the name shouldn't imply it comes from the bottom only... even though that's how it currently works on iPhone and Android. (I'm open to different names.)+1 for page sheet. On the iPad, it's shown modally for best UX.
I think both are great. BottomSheet for a normal (none darkening) overlay and the BottomSheetDialog/PageSheetDialog for the modal one: https://www.migaweb.de/ti_bottomsheet_dialog.mp4
providing an androidView will render the table, just the options will create a normal optionDialog like titanium-android-bottom-sheet. Still need to add the other parameters.
The BottomSheet brings some problems with the z-order and clicking through it since it has to be in a CoordinatorLayout. Have to do some more tests there. The Dialog version is looking better. I've extended the options to accept an object with title, image (for the left icon) and a custom text color. Makes it more powerful ot use
The BottomSheet brings some problems with the z-order and clicking through it since it has to be in a CoordinatorLayout. [~michael], the reason buttons appear on-top of the bottom sheet view is because their "elevation" is set to a higher value. Elevation literally raises the view higher on the z-axis and ignores the order in the view group. Buttons have elevation set on them by default to show a drop shadow. A simple solution might be to apply elevation to BottomSheetView by default. This would give it a drop-shadow effect which people would probably want anyways. We should probably double check how navigation drawer layout does this since it's a view (not a dialog) and doesn't have this elevation problem.
Okay, so why not do this via a slim module? We could use ti.draggable for the iOS < 15 backwards compatibility and the discussed BottomSheet API for Android. So it'd be available for all versions and all platforms. Brilliant. To get things started, I just open sourced the module we made internally and use in production for our app: https://github.com/hansemannn/titanium-bottom-sheet I will add the iOS 15 APIs there as well and make ti.draggable a dependency for iOS. Then we could polyfill iOS < 15 support via a JS bridge. Is that still possible for native modules?
Can be closed in favor of the modules. iOS: https://github.com/mbender74/ti.bottomsheetcontroller-ios