birkir / react-native-carplay

CarPlay with React Native
https://birkir.dev/react-native-carplay/
MIT License
625 stars 103 forks source link

onItemSelect is not working in ListTemplate for android #156

Open shubhadeep-foodhub opened 7 months ago

shubhadeep-foodhub commented 7 months ago
const template = new ListTemplate({
            sections: [
                {
                    header: 'HEADER',
                    items: [
                        {
                            text: 'Item 1',
                        },
                    ],
                },
            ],
            title: 'Test Android Auto',
            async onItemSelect(e) {
                console.log("test clicked", e);
            },
        });
        CarPlay.setRootTemplate(template);

When testing the list ListTemplate, the onItemSelect function is not working.

To Reproduce Steps to reproduce the behavior:

  1. click on list item

Expected behavior Should fire a onItemSelect event

Android Auto (please complete the following information):

birkir commented 7 months ago

Awesome, first Android bug (I expect loads...) I will look at this

shubhadeep-foodhub commented 7 months ago

Yes, it has lots of bugs which is causing frequent app crashes. waiting for a stable release.

tanquetav commented 6 months ago

List view items only trigger events if they are browsable items:

const template = new ListTemplate({
            sections: [
                {
                    header: 'HEADER',
                    items: [
                        {
                            text: 'Item 1',
                            browsable: true,
                        },
                    ],
                },
            ],
            title: 'Test Android Auto',
            async onItemSelect(e) {
                console.log("test clicked", e);
            },
        });
        CarPlay.setRootTemplate(template);
Deepak-Foodhub commented 3 months ago

List view items only trigger events if they are browsable items:

const template = new ListTemplate({
            sections: [
                {
                    header: 'HEADER',
                    items: [
                        {
                            text: 'Item 1',
                            browsable: true,
                        },
                    ],
                },
            ],
            title: 'Test Android Auto',
            async onItemSelect(e) {
                console.log("test clicked", e);
            },
        });
        CarPlay.setRootTemplate(template);

It works. Thanks @tanquetav