oleksandrbalan / programguide

Lazy layout to display program guide data on the two directional plane.
Apache License 2.0
40 stars 7 forks source link

How to make timeline of 30 min step instead of 1 hour? #15

Open chat2goku opened 6 months ago

chat2goku commented 6 months ago

I want to make timeline of 30 min step. what should I change?

oleksandrbalan commented 6 months ago

Hey 👋

You have to double "count" of timeline items in timeline lambda. And then use index to place each item correctly and show the correct time. For example this updated timeline lambda in ProgramGuideSimpleScreen:

timeline(
    // timeline variable is defined as a range 8..22, thus we want double the count of
    // items in this range. Plus 1 is used to add a last 22:30-23:00 item
    count = timeline.count() * 2 + 1,
    layoutInfo = {
        // Then use index to calculate the correct start & end hours, keep in mind that
        // 10.5 is 10:30
        val start = timeline.first + 0.5f * it
        ProgramGuideItem.Timeline(
            startHour = start,
            endHour = start + 0.5f
        )
    },
    itemContent = {
        // Again use an index to calculate the correct hour to show in the text
        TimelineItemCell(timeline.first + 0.5f * it)
    },
)

Produces 30m intervals:

image
chat2goku commented 5 months ago

Hi

Thank you for your amazing guidance. It is really appreciated.

I also have one more question. Is there any way to make timeline like this image.

Let me know, Do you know how to achieve this or just tell me in which file of library need to be changed.

Thank you very much...

Screenshot 2024-03-28 at 6 31 36 PM
ChetanPatelPlayBoxTV commented 4 months ago

working fine for timeline of 30 min step but how can we increase width size of 30 min slab?

ChetanPatelPlayBoxTV commented 4 months ago

@oleksandrbalan How do we increase timeline width size in 3o min slab?

oleksandrbalan commented 4 months ago

@chat2goku I have answered in https://github.com/oleksandrbalan/programguide/issues/17#issuecomment-2066862664, sorry for the late response.

@ChetanPatelPlayBoxTV See dimensions parameter in ProgramGuide, where you can set the width of the whole hour: timelineHourWidth.

ProgramGuide(
    dimensions = ProgramGuideDefaults.dimensions.copy(timelineHourWidth = 256.dp),
    ...
) { ... }

timeline-width.webm