Skip to content

Commit

Permalink
Add playbackProgress and accessoryImage to listItem
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKuhn committed Jan 25, 2024
1 parent 985bb0d commit 84fccb1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/react-native-carplay/ios/RNCarPlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ - (void)updateItemImageWithURL:(CPListItem *)item imgUrl:(NSString *)imgUrlStrin
if (config[@"isPlaying"]) {
[item setPlaying:[RCTConvert BOOL:config[@"isPlaying"]]];
}
if (@available(iOS 14.0, *) && config[@"playbackProgress"]) {
[item setPlaybackProgress:[RCTConvert CGFloat:config[@"playbackProgress"]]];
}
if (@available(iOS 14.0, *) && config[@"accessoryImage"]) {
[item setAccessoryImage:[RCTConvert UIImage:config[@"accessoryImage"]]];
}
} else {
NSLog(@"Failed to find template %@", template);
}
Expand Down Expand Up @@ -983,6 +989,12 @@ - (void) applyConfigForMapTemplate:(CPMapTemplate*)mapTemplate templateId:(NSStr
if ([item objectForKey:@"isPlaying"]) {
[_item setPlaying:[RCTConvert BOOL:[item objectForKey:@"isPlaying"]]];
}
if (@available(iOS 14.0, *) && [item objectForKey:@"playbackProgress"]) {
[_item setPlaybackProgress:[RCTConvert CGFloat:[item objectForKey:@"playbackProgress"]]];
}
if (@available(iOS 14.0, *) && [item objectForKey:@"accessoryImage"]) {
[_item setAccessoryImage:[RCTConvert UIImage:[item objectForKey:@"accessoryImage"]]];
}
if (item[@"imgUrl"]) {
NSString *imgUrlString = [RCTConvert NSString:item[@"imgUrl"]];
[self updateItemImageWithURL:_item imgUrl:imgUrlString];
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-carplay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-carplay",
"version": "2.3.3",
"version": "2.3.4",
"description": "CarPlay for React Native",
"main": "lib/index.js",
"react-native": "src/index.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native-carplay/src/interfaces/ListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ export interface ListItem {
* Is Playing flag.
*/
isPlaying?: boolean;
/**
* Value between 0.0 and 1.0 for progress bar of the list item cell.
*/
playbackProgress?: number;
/**
* The image from file system displayed on the trailing edge of the list item cell.
*/
accessoryImage?: ImageSourcePropType;
}

0 comments on commit 84fccb1

Please sign in to comment.