oleksandrbalan / programguide

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

Focus Issue On Android Tv #8

Closed rahat14 closed 9 months ago

rahat14 commented 10 months ago

Item does not scroll with dpad

oleksandrbalan commented 9 months ago

Hey 👋 Thx for trying ProgramGuide!

I guess you are referring to the issue, when the program guide is not scrolled automatically on the focused item. In this case I would recommend to add an onFocusChanged modifier to your composables for program cell / channel / timeline, and use an appropriate ProgramGuideState::animateTo* method for each.

For example for cell item it would be:

ProgramCell(
    program = program,
    onClick = {
        ...
    },
    modifier = Modifier
        .onFocusChanged { focusState ->
            if (focusState.hasFocus) {
                val index = programs.indexOf(program)
                scope.launch { state.animateToProgram(index) }
            }
        }
)

This way the focused item will always be visible, see the video below:

https://github.com/oleksandrbalan/programguide/assets/80771513/5b07a03c-7639-4133-b818-d00f620feaf8

rahat14 commented 9 months ago

i will definitely try and give feed back to u