I wrote a tutorial for creating a custom weekly sc...
# compose
d
I wrote a tutorial for creating a custom weekly schedule layout like in Google Calendar with Compose. It was my first time working with custom layouts so there might have been even simpler ways to do some things (any feedback would be appreciated), but I was pleasantly surprised by how easy and short (~230 lines) it ended up being! https://danielrampelt.com/blog/jetpack-compose-custom-schedule-layout-part-1/
K 8
c
Amazing! Good job! I wonder how much work it would be to show two items on the same day at the same time. Currently google calendar will show two blocks side by side.
z
Great article. About this one (from the screenshot below) - you have defined your
eventContent
callback as:
Copy code
eventContent: @Composable (event: Event) -> Unit = { BasicEvent(event = it) }
As outlined in the API Guideline for Compose, you can add one more input argument to
eventContent
- a
Modifier
and then pass it down to `BasicEvent`:
Copy code
eventContent: @Composable (event: Event, modifier: Modifier) -> Unit = { event, modifier -> 
    BasicEvent(event, modifier) 
}
If you decide to call another composable instead of the
BasicEvent
, it's enough for it to properly handle the passed
Modifier
🙂 Then you won't need the
Box
wrapper. But then again... having a wrapper shouldn't be such big issue with Compose. Sorry if I misunderstood your issue. If so, please forgive me 🙂
d
@Colton Idle Thanks! Good idea - I'll add that to my list of things to look into @Zhelyazko Atanasov Yeah that's probably a better way do it. I considered that, but was worried I wouldn't be able to trust custom event implementations to respect the incoming
modifier
. But that's good to see it's expected in the API guidelines
h
@Daniel Rampelt awesome content! I also tried implementing a clone of Google Calendar. I imitated the way Google Calendar divides the space for clashing events. The question has nothing to do with compose but it's a classic algo&data structures interview question 🙂
👍 1