Hey people, I have a question. How do you usually ...
# compose
s
Hey people, I have a question. How do you usually go through the process of "I want to do X" while working with Compose? So far when I want to do something, I've been trying to google for it, but the google results are almost always very bad. This is natural, with all the stackoverflow posts, blogs etc. covering how to do some stuff in the previous versions which are very often deprecated. I am sure this will get better as we have a more stable API now, but right now it's very challenging for me. For example now, I wanted to look into making a bottom sheet, but not one that expands fully like the one
BottomSheetScaffold
provides, just have it appear at let's say 30% of the screen and be able to swipe it down again. After trying to search for it, or even trying out some ideas myself I feel like I very often end up in dead-ends (and not just this bottom sheet idea, anything non-trivial I try to achieve). This is not something that I had experienced when working with non-compose Android before due to the massive amount of information that there is online. Any advice on how to approach this?
👍 1
t
I think in general for compose you have to get familiar with compose. And then you can build many thinks yourself. Compose provides much more general base components which can be used to create more complicated UIs. So you do not need to have a library for many things.
a
In your specific use-case, you’re trying to hack around the material design specs. They are built to be strict in a sense, you might have to copy the material code and implement your own if you really want a behavior, or try to hack around the available API. So you won’t see resources on that, you’ll need to do your own tinkering.
Or simply implement your own BottomSheet
b
Agree that googling is really bad for Compose, at least for now. In my case: 1. My 1st approach is to search in this channel. 2. My 2nd approach is to search for usages / samples in https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:compose/ 3. My 3rd approach is to google, but only looking at official docs and samples
h
4. Actually ask in this channel 😄
☝️ 2
s
I specifically asked because I don't feel good spamming this channel too much. And slack has a pretty back searching experience anyway, I feel like so many useful questions and answers get lost in here. But thank you for the suggestions everyone! I think going over the usages is a critical thing I am not doing. I just wish it was a bit easier with built-in support inside Android studio instead of browsing the cs.android website which is much slower than inside the IDE. And I agree that with enough understanding of compose I could just "simply implement my own X" as Allan suggests, but I am not there yet, and I assume most people feel the same way, considering most of us have very limited experience with Compose. I am sure some years down the line it will all feel so much smoother and easier.
👍 1
a
Ah, let me clarify my wording a bit. By “simply” I meant it’s simpler than the other 2 approaches I suggested (the hack and the copy-paste).
s
Yeah of course, I understand what you are saying. I will tinker with it as you said, or just drop the idea if I don't manage.
c
All of the api docs have a little snippet of a sample which is really nice. Look at the material api ref for example: https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary
v
If you have a general sense about classic Android, something like this might also be useful - https://jetpackcompose.app/What-is-the-equivalent-of--in-Jetpack-Compose I need to update it to reflect the latest changes after beta and I definitely plan to do that this week. I was getting a bit burnt out with all the updates so paused it for a bit. Now that the API surface won’t change as often, it will be slightly easier to maintain things like this. I’m sure that the folks who are maintaining the official docs also felt some churn during the alpha so its understandable that it gets hard to always keep things up-to-date
s
@Colton Idle ModalBottomSheetLayout was what I was looking for and I didn't even know it. It does exactly what I wanted to achieve. Ah it's so hard to know all the available APIs right now. This is also a perfect opportunity for me to see how it's implemented and understand it. Thank you everyone for trying to help me out!
c
@Stylianos Gakis glad I could help. I agree though. It is very hard to know what the exact api surface is and what composables are available to us. Don't want to call in Jim Sproch necessarily, but Jim do you think there's value in submitting a bug for having like some sort of composable library or something where we can see all composables available at one time? I know material has a little MDC app like this for the old view system? Or is this basically just "hey this stuff is new, you'll learn it as time goes on"