Skip to content

Commit

Permalink
Merge pull request #165 from codevise/add-playbackProgress-and-access…
Browse files Browse the repository at this point in the history
…oryImage-to-listItem

Add playbackProgress and accessoryImage for list items
  • Loading branch information
birkir authored Feb 16, 2024
2 parents cd0bee2 + cf188ed commit 109c0a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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 @@ -644,6 +644,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 @@ -997,6 +1003,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
10 changes: 10 additions & 0 deletions packages/react-native-carplay/src/interfaces/ListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export interface ListItem {
* @namespace iOS
*/
isPlaying?: boolean;
/**
** Value between 0.0 and 1.0 for progress bar of the list item cell.
* @namespace iOS
*/
playbackProgress?: number;
/**
* The image from file system displayed on the trailing edge of the list item cell.
* @namespace iOS
*/
accessoryImage?: ImageSourcePropType;
/**
* Sets the initial enabled state for Row.
* @default true
Expand Down

0 comments on commit 109c0a6

Please sign in to comment.