Site icon Android Tutorial Online

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

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

Program Guide

Program Guide, aka EPG, library for Jetpack Compose.

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.

Usage

Get a dependency

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

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

Or in settings.gradle:

pluginManagement {
    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:

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.

simple.mp4

https://user-images.githubusercontent.com/20944869/240821369-20fefbce-80cc-4e43-87d9-e359edf64c35.mp4

Fully configurable layout.

configuration.mp4

https://user-images.githubusercontent.com/20944869/240821926-9ce2ecc6-7b80-470b-9254-77dcd5e670c1.mp4

If you need further customization options, check MinaBox library.

GitHub

View Github

Exit mobile version