Skip to content

Commit

Permalink
Expose CPListTemplate.maximumImageSize and CPListImageRowItem.maximum…
Browse files Browse the repository at this point in the history
…ImageSize
  • Loading branch information
janwiebe-jump committed Mar 25, 2024
1 parent e8777f9 commit a489eb7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/react-native-carplay/ios/RNCarPlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,20 @@ - (void)updateListRowItemImageWithURL:(CPListImageRowItem *)item imgUrl:(NSStrin
}
}

RCT_EXPORT_METHOD(getMaximumListItemImageSize:(NSString *)templateId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
RNCPStore *store = [RNCPStore sharedManager];
CPTemplate *template = [store findTemplateById:templateId];
if (template) {
CPListTemplate *listTemplate = (CPListTemplate*) template;
resolve(@(CPListItem.maximumImageSize));
} else {
NSLog(@"Failed to find template %@", template);
reject(@"template_not_found", @"Template not found in store", nil);
}
}

RCT_EXPORT_METHOD(getMaximumListSectionCount:(NSString *)templateId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
Expand Down Expand Up @@ -746,6 +760,20 @@ - (void)updateListRowItemImageWithURL:(CPListImageRowItem *)item imgUrl:(NSStrin
}
}

RCT_EXPORT_METHOD(getMaximumListImageRowItemImageSize:(NSString *)templateId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
RNCPStore *store = [RNCPStore sharedManager];
CPTemplate *template = [store findTemplateById:templateId];
if (template) {
CPListTemplate *listTemplate = (CPListTemplate*) template;
resolve(@(CPListImageRowItem.maximumImageSize));
} else {
NSLog(@"Failed to find template %@", template);
reject(@"template_not_found", @"Template not found in store", nil);
}
}

RCT_EXPORT_METHOD(updateMapTemplateConfig:(NSString *)templateId config:(NSDictionary*)config) {
CPTemplate *template = [[RNCPStore sharedManager] findTemplateById:templateId];
if (template) {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-carplay/src/CarPlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export interface InternalCarPlay extends NativeModule {
dismissPanningInterface(id: string, animated: boolean): void;
getMaximumListSectionCount(id: string): Promise<number>;
getMaximumListItemCount(id: string): Promise<number>;
getMaximumListItemImageSize(id: string): Promise<number>;
getMaximumNumberOfGridImages(id: string): Promise<number>;
getMaximumListImageRowItemImageSize(id: string): Promise<number>;
reactToSelectedResult(status: boolean): void;
updateListTemplateSections(id: string, config: unknown): void;
updateListTemplateItem(id: string, config: unknown): void;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native-carplay/src/templates/ListTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ export class ListTemplate extends Template<ListTemplateConfig> {
return CarPlay.bridge.getMaximumListSectionCount(this.id);
}

public getMaximumListItemImageSize() {
return CarPlay.bridge.getMaximumListItemImageSize(this.id);
}

public getMaximumNumberOfGridImages() {
return CarPlay.bridge.getMaximumNumberOfGridImages(this.id);
}

public getMaximumListImageRowItemImageSize() {
return CarPlay.bridge.getMaximumListImageRowItemImageSize(this.id);
}
}

0 comments on commit a489eb7

Please sign in to comment.