Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Template crash fixed and call button action bug fix and TabBar Template tabTitle added #113

Merged
merged 6 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions ios/RNCarPlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ + (id)allocWithZone:(NSZone *)zone {
@"didCancelNavigation",
@"alertActionPressed",
@"selectedPreviewForTrip",
@"startedTrip"
@"startedTrip",
@"buttonPressed",
];
}

Expand Down Expand Up @@ -150,7 +151,14 @@ - (UIImage *)imageWithSize:(UIImage *)image convertToSize:(CGSize)size {
}
else if ([type isEqualToString:@"list"]) {
NSArray *sections = [self parseSections:[RCTConvert NSArray:config[@"sections"]]];
CPListTemplate *listTemplate = [[CPListTemplate alloc] initWithTitle:title sections:sections];
CPListTemplate *listTemplate;
if (@available(iOS 15.0, *)) {
CPAssistantCellConfiguration *conf = [[CPAssistantCellConfiguration alloc] initWithPosition: CPAssistantCellPositionTop visibility:CPAssistantCellVisibilityAlways assistantAction:CPAssistantCellActionTypeStartCall];
listTemplate = [[CPListTemplate alloc] initWithTitle:title sections:sections assistantCellConfiguration:conf];
} else {
// Fallback on earlier versions
listTemplate = [[CPListTemplate alloc] initWithTitle:title sections:sections];
}
[listTemplate setLeadingNavigationBarButtons:leadingNavigationBarButtons];
[listTemplate setTrailingNavigationBarButtons:trailingNavigationBarButtons];
CPBarButton *backButton = [[CPBarButton alloc] initWithTitle:@" Back" handler:^(CPBarButton * _Nonnull barButton) {
Expand Down Expand Up @@ -191,8 +199,9 @@ - (UIImage *)imageWithSize:(UIImage *)image convertToSize:(CGSize)size {
tabBarTemplate.delegate = self;
template = tabBarTemplate;
} else if ([type isEqualToString:@"contact"]) {
CPContact *contact = [[CPContact alloc] init];
[contact setName:config[@"name"]];
NSString *nm = [RCTConvert NSString:config[@"name"]];
UIImage *img = [RCTConvert UIImage:config[@"image"]];
CPContact *contact = [[CPContact alloc] initWithName:nm image:img];
[contact setSubtitle:config[@"subtitle"]];
[contact setActions:[self parseButtons:config[@"actions"] templateId:templateId]];
CPContactTemplate *contactTemplate = [[CPContactTemplate alloc] initWithContact:contact];
Expand Down Expand Up @@ -269,10 +278,12 @@ - (UIImage *)imageWithSize:(UIImage *)image convertToSize:(CGSize)size {
if (config[@"tabImage"]) {
template.tabImage = [RCTConvert UIImage:config[@"tabImage"]];
}

if (config[@"tabTitle"]) {
template.tabTitle = [RCTConvert NSString:config[@"tabTitle"]];
}

[template setUserInfo:@{ @"templateId": templateId }];
[store setTemplate:templateId template:template];
[store setTemplate:templateId _template:template];
}

RCT_EXPORT_METHOD(createTrip:(NSString*)tripId config:(NSDictionary*)config) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/ContactTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ContactTemplate extends Template<ContactTemplateConfig> {
}
get eventMap() {
return {
gridButtonPressed: 'onButtonPressed',
buttonPressed: 'onButtonPressed',
};
}
}