https://kotlinlang.org logo
#compose
Title
# compose
m

Marcin Wisniowski

05/11/2022, 11:05 AM
Compose previews. Top or bottom of the file? I can think of reasons for both ways.
⬇️ 27
f

Filip Wiesner

05/11/2022, 11:07 AM
Voted ⬇️ but sometimes Previews can be in completely separate file if there is more of them
👍 1
💯 1
f

f.babic

05/11/2022, 11:08 AM
I would say it depends on the use case If you're developing apps for yourself (without the possibility of other people using your code), having them at top is also okay - quick preview of the implementation. If you're developing SDKs/components for use elsewhere, the impl is generally more important than the UI, so it can be at the bottom. But yeah, separate files also work as @Filip Wiesner says
m

Marcin Wisniowski

05/11/2022, 11:08 AM
The argument for top I can think of is that previews serve as documentation/samples, and so similarly to JavaDoc comments go above what they are documenting.
f

f.babic

05/11/2022, 11:11 AM
Yeah that's a good point - but my POV comes from - if you look up a file, e.g. `TypingIndicator.kt`˛ most of the time you're probably looking to work on the code and/or implement it in another file, so the thing that's most common should be at the top in that case (the code in my opinion) But yeah, you could also say that if you're looking into something regularly, you want to make sure the UI is the same/looks the way you want
4 Views