programguide

by oleksandrbalan

Lazy layout to display program guide data on the two directional plane.

View on GitHub

Documentation

Maven Central

Program Guide

Program Guide, aka EPG, library for Compose UI.

Lazy layout to display program guide data on the two directional plane. It is build on the MinaBox (which is build on LazyLayout) and provides methods to register item(s) and handles scrolling on the plane.

Multiplatform

Library supports Android, iOS, Desktop (Windows, MacOS, Linux) and Wasm targets.

https://www.jetbrains.com/compose-multiplatform/

Usage

Get a dependency

Step 1. Add the MavenCentral repository to your build file.
Add it in your root build.gradle.kts at the end of repositories:

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

Or in settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        ...
        mavenCentral()
    }
}

Step 2. Add the dependency.
Check latest version on the releases page.

dependencies {
    implementation("io.github.oleksandrbalan:programguide:$version")
}

Use in Composable

The core element of the ProgramGuide layout is a content lambda, where program, channel and timeline items are registered in the similar manner as in LazyColumn or LazyRow.

There are multiple types of items to register:

  • Programs - program item cells. Each program must define channel index, and where it starts and ends.
  • Channels - channel item cells, displayed to the left of the program guide. Each channel must define its index.
  • Timeline - timeline cells, displayed on the top. Each timeline item must define where it starts and ends, so it is not locked to per-hour granularity.
  • Current time - vertical line of the current time.
  • Top corner - place for content in the top left corner, above channels and timeline.

Note: To be independent on date-time libraries, hours are defined as float numbers. For example: 9.5f represents 09:30 and 16.25f represents 16:15.

The size of the items are defined via dimensions parameter.

It is also possible to observe on the scroll state and change it programmatically using an instance of the ProgramGuideState.

ProgramGuide {
    programs(
        // Count of programs
        count = ...,
        // Necessary layout info of the single program cell
        layoutInfo = { ProgramGuideItem.Program(...) }
    ) {
        // Composable for single program cell
    }

    channels(
        // Count of channels
        count = ...,
        // Necessary layout info of the single channel cell
        layoutInfo = { ProgramGuideItem.Channel(...) }
    ) {
        // Composable for single channel cell
    }

    timeline(
        // Count of timeline blocks
        count = ...,
        // Necessary layout info of the single timeline cell
        layoutInfo = { ProgramGuideItem.Timeline(...) }
    ) {
        // Composable for single timeline cell
    }
}

See Demo application and examples for more usage examples.

Examples

Simple EPG data.

https://github.com/oleksandrbalan/programguide/assets/20944869/20fefbce-80cc-4e43-87d9-e359edf64c35

Fully configurable layout.

https://github.com/oleksandrbalan/programguide/assets/20944869/9ce2ecc6-7b80-470b-9254-77dcd5e670c1

If you need further customization options, check MinaBox library.

Dispatch Newsletter
Be the first to discover new Compose libraries
Curated Insights
Digest in 5 minutes or less
Android Analysis
Entertaining takes on happenings
Insider Tips
From top Android developers
Hidden Gems
You won't find elsewhere
"
"I truly love this newsletter ❤️‍🔥 Spot on content and I know there's a lot of effort that goes behind it. Great work!"
theapache64
Staff Software Engineer @ Disney+ Hotstar
Join thousands of Android devs who look forward to Dispatch every week