birkir / react-native-carplay

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

Back button appears on root template if it's a list #104

Closed gavrichards closed 1 year ago

gavrichards commented 1 year ago

If you set your root template as list template, you will see a "Back" button at the top, even though there is no where to go back to. Pressing the button does nothing.

This is caused by these lines in RNCarPlay.m, specifically adding a back button to list templates:

CPBarButton *backButton = [[CPBarButton alloc] initWithTitle:@" Back" handler:^(CPBarButton * _Nonnull barButton) {
    [self sendEventWithName:@"backButtonPressed" body:@{@"templateId":templateId}];
    [self popTemplate:false];
}];
[listTemplate setBackButton:backButton];

If you comment these lines out, the back button disappears.

It would make sense either for the back button to be an option for the template, or to be removed when the template is mounted as the root.

birkir commented 1 year ago

You can now pass backButtonHidden flag to disable the back button.