From 84fccb1d9fdd97604f9375d6d9f5d103727b61e7 Mon Sep 17 00:00:00 2001 From: Daniel Kuhn Date: Thu, 25 Jan 2024 13:38:32 +0100 Subject: [PATCH] Add playbackProgress and accessoryImage to listItem --- packages/react-native-carplay/ios/RNCarPlay.m | 12 ++++++++++++ packages/react-native-carplay/package.json | 2 +- .../react-native-carplay/src/interfaces/ListItem.ts | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/react-native-carplay/ios/RNCarPlay.m b/packages/react-native-carplay/ios/RNCarPlay.m index 8554fb19..d6ec5faf 100644 --- a/packages/react-native-carplay/ios/RNCarPlay.m +++ b/packages/react-native-carplay/ios/RNCarPlay.m @@ -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); } @@ -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]; diff --git a/packages/react-native-carplay/package.json b/packages/react-native-carplay/package.json index bd6d7d0b..13489f4e 100644 --- a/packages/react-native-carplay/package.json +++ b/packages/react-native-carplay/package.json @@ -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", diff --git a/packages/react-native-carplay/src/interfaces/ListItem.ts b/packages/react-native-carplay/src/interfaces/ListItem.ts index 4a7632cf..897a9122 100644 --- a/packages/react-native-carplay/src/interfaces/ListItem.ts +++ b/packages/react-native-carplay/src/interfaces/ListItem.ts @@ -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; }