From cf188ed4092f9d2fa10c3cdd075424b7a32a784b Mon Sep 17 00:00:00 2001 From: Daniel Kuhn Date: Thu, 25 Jan 2024 15:11:14 +0100 Subject: [PATCH] feat: add playbackProgress and accessoryImage for list items Adds support for playbackProgress (https://developer.apple.com/documentation/carplay/cplistitem/3551779-playbackprogress) accessoryImage (https://developer.apple.com/documentation/carplay/cplistitem/3626470-setaccessoryimage) to list items. --- packages/react-native-carplay/ios/RNCarPlay.m | 12 ++++++++++++ .../react-native-carplay/src/interfaces/ListItem.ts | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/react-native-carplay/ios/RNCarPlay.m b/packages/react-native-carplay/ios/RNCarPlay.m index 5bc6833b..fea24870 100644 --- a/packages/react-native-carplay/ios/RNCarPlay.m +++ b/packages/react-native-carplay/ios/RNCarPlay.m @@ -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); } @@ -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]; diff --git a/packages/react-native-carplay/src/interfaces/ListItem.ts b/packages/react-native-carplay/src/interfaces/ListItem.ts index b4f90643..91320451 100644 --- a/packages/react-native-carplay/src/interfaces/ListItem.ts +++ b/packages/react-native-carplay/src/interfaces/ListItem.ts @@ -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