programguide icon indicating copy to clipboard operation
programguide copied to clipboard

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

Open chat2goku opened this issue 1 year ago • 5 comments

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

chat2goku avatar Mar 01 '24 05:03 chat2goku

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

oleksandrbalan avatar Mar 08 '24 01:03 oleksandrbalan

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

chat2goku avatar Mar 28 '24 13:03 chat2goku

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

ChetanPatelPlayBoxTV avatar Apr 18 '24 10:04 ChetanPatelPlayBoxTV

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

ChetanPatelPlayBoxTV avatar Apr 19 '24 09:04 ChetanPatelPlayBoxTV

@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

oleksandrbalan avatar Apr 19 '24 16:04 oleksandrbalan