1.0.5 • Published 7 months ago

rn-leanback v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-native-leanback

Android TV leanback wrapper for React Native

Installation

Move styles.xml and values.xml to your androidtv resources folder.

Install via package.json:

"@reactseals/react-native-leanback": "2.0.3"

Install from the command line:

npm install @reactseals/react-native-leanback@2.0.3

Usage

import { Row } from '@reactseals/react-native-leanback';

<Row
    data={data}
    attributes={{
        width: 313,
        height: 173,
    }}
    style={{ width: '100%' }}
    title="Title for row"
    onFocus={(item) => console.log(item)}
    onPress={(item) => console.log(item)}
/>
import { Grid } from 'react-native-leanback';

<Grid
    data={data}
    attributes={{
        width: 313,
        height: 173,
    }}
    style={{ width: '100%' }}
    onFocus={(item) => console.log(item)}
    onPress={(item) => console.log(item)}
    onDataIdsReady={(item) => console.log(item)}
/>

Data Model

KeyRequiredDescription
idyesUnique id of the card
cardImageUrlyesCard image url
videoUrlnoVideo url
titlenoTitle of the card, visible underneath of the image
descriptionnoDescription of the card, visible underneath of the title
displayLiveBadgenoHides or displays live stream badge
liveBadgeColornoColor of the badge which represents live stream
liveProgressBarColornoProgress bar color
overlayImageUrlnoUrl of overlay image visible on the top of the card image
overlayTextnoOverlay text visible on the top of card image
overlayPositionnoPosition of overlay text
progressnoPercentage which indicates progress of live stream
backgroundColornoBackground color of the card
programStartTimestampnoTimestamp of live stream start. Must be combined with programEndTimestamp then progress gets automatically calculated
programEndTimestampnoTimestamp of live stream end. Must be combined with programStartTimestamp then progress gets automatically calculated
viewIdnoUnique viewId which can be used to prevent or force focus. If it's not defined then random unique id is generated automatically

Props

PropTypeDefaultDescription
dataarrayData for row. See Data Model
styleobjectContainer holder style
titlestringRow title
numOfColsenum(4, 5, 6)4Number how many columns grid should contain(Grid only)
showOnlyFocusedInfobooleanfalseShow info field block underneath ONLY when card is focused(Grid only)
forbiddenFocusDirectionsarray of enum('up', 'down', 'left', 'right')Prevents any element to be focused when user navigates out of grid/row to provided directions
nextFocusUpIdstringDesignates the next view to receive focus when the user navigates up
nextFocusDownIdstringDesignates the next view to receive focus when the user navigates down
nextFocusLeftIdstringDesignates the next view to receive focus when the user navigates left
nextFocusRightIdstringDesignates the next view to receive focus when the user navigates right
attributes.widthintegerWidth of card
attributes.heightintegerHeight of card
attributes.cardShapeenum('round', 'square')squareShape of the card
attributes.focusedCardAlignmentenum('left', 'center')centerAlignment of focus
attributes.numberOfRowsnumber1Number of rows in Row component
attributes.borderRadiusnumberBorder radius
attributes.imageTransformationModeenum('noTransformation','centerCrop')fitCenterTransformation mode of the card image

Methods

requestFocus()

Imperative method for requesting focus of specific Row or Grid E.g.

ref.current.requestFocus()

Here ref.current refers to the ref passed to the Grid or Row component.

Example

//TODO

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago