@javascriptcommon/react-native-carplay 2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +633 -0
- package/ios/RCTConvert+RNCarPlay.h +19 -0
- package/ios/RCTConvert+RNCarPlay.m +95 -0
- package/ios/RNCPStore.h +22 -0
- package/ios/RNCPStore.m +68 -0
- package/ios/RNCarPlay.h +32 -0
- package/ios/RNCarPlay.m +1755 -0
- package/ios/RNCarPlay.xcodeproj/project.pbxproj +300 -0
- package/lib/CarPlay.js +146 -0
- package/lib/index.js +63 -0
- package/lib/interfaces/Action.js +2 -0
- package/lib/interfaces/AlertAction.js +2 -0
- package/lib/interfaces/BarButton.js +2 -0
- package/lib/interfaces/CarColor.js +2 -0
- package/lib/interfaces/GridButton.js +2 -0
- package/lib/interfaces/Header.js +2 -0
- package/lib/interfaces/ListItem.js +2 -0
- package/lib/interfaces/ListItemUpdate.js +2 -0
- package/lib/interfaces/ListSection.js +2 -0
- package/lib/interfaces/Maneuver.js +2 -0
- package/lib/interfaces/MapButton.js +2 -0
- package/lib/interfaces/NavigationAlert.js +9 -0
- package/lib/interfaces/NavigationInfo.js +2 -0
- package/lib/interfaces/NavigationStep.js +2 -0
- package/lib/interfaces/Pane.js +2 -0
- package/lib/interfaces/PauseReason.js +11 -0
- package/lib/interfaces/Place.js +2 -0
- package/lib/interfaces/TextConfiguration.js +2 -0
- package/lib/interfaces/TimeRemainingColor.js +2 -0
- package/lib/interfaces/TravelEstimates.js +2 -0
- package/lib/interfaces/VoiceControlState.js +2 -0
- package/lib/navigation/NavigationSession.js +53 -0
- package/lib/navigation/Trip.js +19 -0
- package/lib/templates/ActionSheetTemplate.js +15 -0
- package/lib/templates/AlertTemplate.js +15 -0
- package/lib/templates/ContactTemplate.js +15 -0
- package/lib/templates/GridTemplate.js +16 -0
- package/lib/templates/InformationTemplate.js +24 -0
- package/lib/templates/ListTemplate.js +67 -0
- package/lib/templates/MapTemplate.js +115 -0
- package/lib/templates/NowPlayingTemplate.js +17 -0
- package/lib/templates/PointOfInterestTemplate.js +16 -0
- package/lib/templates/SearchTemplate.js +41 -0
- package/lib/templates/TabBarTemplate.js +26 -0
- package/lib/templates/Template.js +74 -0
- package/lib/templates/VoiceControlTemplate.js +19 -0
- package/lib/templates/android/AndroidNavigationBaseTemplate.js +29 -0
- package/lib/templates/android/MessageTemplate.js +10 -0
- package/lib/templates/android/NavigationTemplate.js +16 -0
- package/lib/templates/android/PaneTemplate.js +10 -0
- package/lib/templates/android/PlaceListMapTemplate.js +18 -0
- package/lib/templates/android/PlaceListNavigationTemplate.js +19 -0
- package/lib/templates/android/RoutePreviewNavigationTemplate.js +22 -0
- package/package.json +71 -0
- package/react-native-carplay.podspec +21 -0
- package/src/CarPlay.ts +286 -0
- package/src/index.ts +50 -0
- package/src/interfaces/Action.ts +15 -0
- package/src/interfaces/AlertAction.ts +5 -0
- package/src/interfaces/BarButton.ts +41 -0
- package/src/interfaces/CarColor.ts +1 -0
- package/src/interfaces/GridButton.ts +25 -0
- package/src/interfaces/Header.ts +16 -0
- package/src/interfaces/ListItem.ts +84 -0
- package/src/interfaces/ListItemUpdate.ts +14 -0
- package/src/interfaces/ListSection.ts +21 -0
- package/src/interfaces/Maneuver.ts +30 -0
- package/src/interfaces/MapButton.ts +27 -0
- package/src/interfaces/NavigationAlert.ts +46 -0
- package/src/interfaces/NavigationInfo.ts +19 -0
- package/src/interfaces/NavigationStep.ts +17 -0
- package/src/interfaces/Pane.ts +29 -0
- package/src/interfaces/PauseReason.ts +7 -0
- package/src/interfaces/Place.ts +12 -0
- package/src/interfaces/TextConfiguration.ts +5 -0
- package/src/interfaces/TimeRemainingColor.ts +1 -0
- package/src/interfaces/TravelEstimates.ts +39 -0
- package/src/interfaces/VoiceControlState.ts +8 -0
- package/src/navigation/NavigationSession.ts +57 -0
- package/src/navigation/Trip.ts +36 -0
- package/src/templates/ActionSheetTemplate.ts +21 -0
- package/src/templates/AlertTemplate.ts +20 -0
- package/src/templates/ContactTemplate.ts +45 -0
- package/src/templates/GridTemplate.ts +45 -0
- package/src/templates/InformationTemplate.ts +42 -0
- package/src/templates/ListTemplate.ts +167 -0
- package/src/templates/MapTemplate.ts +231 -0
- package/src/templates/NowPlayingTemplate.ts +31 -0
- package/src/templates/PointOfInterestTemplate.ts +40 -0
- package/src/templates/SearchTemplate.ts +70 -0
- package/src/templates/TabBarTemplate.ts +56 -0
- package/src/templates/Template.ts +164 -0
- package/src/templates/VoiceControlTemplate.ts +25 -0
- package/src/templates/android/AndroidNavigationBaseTemplate.ts +46 -0
- package/src/templates/android/MessageTemplate.ts +19 -0
- package/src/templates/android/NavigationTemplate.ts +50 -0
- package/src/templates/android/PaneTemplate.ts +16 -0
- package/src/templates/android/PlaceListMapTemplate.ts +64 -0
- package/src/templates/android/PlaceListNavigationTemplate.ts +57 -0
- package/src/templates/android/RoutePreviewNavigationTemplate.ts +66 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#import "RCTConvert+RNCarPlay.h"
|
|
2
|
+
#import <React/RCTConvert+CoreLocation.h>
|
|
3
|
+
#import <Availability.h>
|
|
4
|
+
|
|
5
|
+
@implementation RCTConvert (RNCarPlay)
|
|
6
|
+
|
|
7
|
+
RCT_ENUM_CONVERTER(CPTripEstimateStyle, (@{
|
|
8
|
+
@"light": @(CPTripEstimateStyleLight),
|
|
9
|
+
@"dark": @(CPTripEstimateStyleDark)
|
|
10
|
+
}),
|
|
11
|
+
CPTripEstimateStyleDark,
|
|
12
|
+
integerValue)
|
|
13
|
+
|
|
14
|
+
RCT_ENUM_CONVERTER(CPPanDirection, (@{
|
|
15
|
+
@"up": @(CPPanDirectionUp),
|
|
16
|
+
@"right": @(CPPanDirectionRight),
|
|
17
|
+
@"bottom": @(CPPanDirectionDown),
|
|
18
|
+
@"left": @(CPPanDirectionLeft),
|
|
19
|
+
@"none": @(CPPanDirectionNone)
|
|
20
|
+
}), CPPanDirectionNone, integerValue)
|
|
21
|
+
|
|
22
|
+
RCT_ENUM_CONVERTER(CPAssistantCellPosition, (@{
|
|
23
|
+
@"top": @(CPAssistantCellPositionTop),
|
|
24
|
+
@"bottom": @(CPAssistantCellPositionBottom)
|
|
25
|
+
}), CPAssistantCellPositionTop, integerValue)
|
|
26
|
+
|
|
27
|
+
RCT_ENUM_CONVERTER(CPAssistantCellVisibility, (@{
|
|
28
|
+
@"off": @(CPAssistantCellVisibilityOff),
|
|
29
|
+
@"always": @(CPAssistantCellVisibilityAlways),
|
|
30
|
+
@"limited": @(CPAssistantCellVisibilityWhileLimitedUIActive)
|
|
31
|
+
}), CPAssistantCellVisibilityOff, integerValue)
|
|
32
|
+
|
|
33
|
+
RCT_ENUM_CONVERTER(CPAssistantCellActionType, (@{
|
|
34
|
+
@"playMedia": @(CPAssistantCellActionTypePlayMedia),
|
|
35
|
+
@"startCall": @(CPAssistantCellActionTypeStartCall)
|
|
36
|
+
}), CPAssistantCellActionTypeStartCall, integerValue)
|
|
37
|
+
|
|
38
|
+
+ (CPMapButton*)CPMapButton:(id)json withHandler:(void (^)(CPMapButton * _Nonnull mapButton))handler {
|
|
39
|
+
CPMapButton *mapButton = [[CPMapButton alloc] initWithHandler:handler];
|
|
40
|
+
|
|
41
|
+
if ([json objectForKey:@"image"]) {
|
|
42
|
+
[mapButton setImage:[RCTConvert UIImage:json[@"image"]]];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ([json objectForKey:@"focusedImage"]) {
|
|
46
|
+
[mapButton setImage:[RCTConvert UIImage:json[@"focusedImage"]]];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ([json objectForKey:@"disabled"]) {
|
|
50
|
+
[mapButton setEnabled:![RCTConvert BOOL:json[@"disabled"]]];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if ([json objectForKey:@"hidden"]) {
|
|
54
|
+
[mapButton setHidden:[RCTConvert BOOL:json[@"hidden"]]];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return mapButton;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
+ (MKMapItem*)MKMapItem:(id)json {
|
|
61
|
+
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([RCTConvert double:json[@"latitude"]], [RCTConvert double:json[@"longitude"]]);
|
|
62
|
+
NSString *name = [RCTConvert NSString:json[@"name"]];
|
|
63
|
+
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate];
|
|
64
|
+
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
|
|
65
|
+
mapItem.name = name;
|
|
66
|
+
return mapItem;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
+ (CPRouteChoice*)CPRouteChoice:(id)json {
|
|
70
|
+
return [[CPRouteChoice alloc] initWithSummaryVariants:[RCTConvert NSStringArray:json[@"additionalInformationVariants"]] additionalInformationVariants:[RCTConvert NSStringArray:json[@"selectionSummaryVariants"]] selectionSummaryVariants:[RCTConvert NSStringArray:json[@"summaryVariants"]]];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
+ (CPPointOfInterest*)CPPointOfInterest:(id)json API_AVAILABLE(ios(14.0)){
|
|
74
|
+
MKMapItem *location = [RCTConvert MKMapItem:json[@"location"]];
|
|
75
|
+
NSString *title = [RCTConvert NSString:json[@"title"]];
|
|
76
|
+
NSString *subtitle = [RCTConvert NSString:json[@"subtitle"]];
|
|
77
|
+
NSString *summary = [RCTConvert NSString:json[@"summary"]];
|
|
78
|
+
NSString *detailTitle = [RCTConvert NSString:json[@"detailTitle"]];
|
|
79
|
+
NSString *detailSubtitle = [RCTConvert NSString:json[@"detailSubtitle"]];
|
|
80
|
+
NSString *detailSummary = [RCTConvert NSString:json[@"detailSummary"]];
|
|
81
|
+
|
|
82
|
+
CPPointOfInterest *poi = [[CPPointOfInterest alloc] initWithLocation:location title:title subtitle:subtitle summary:summary detailTitle:detailTitle detailSubtitle:detailSubtitle detailSummary:detailSummary pinImage:nil];
|
|
83
|
+
return poi;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
+ (CPAlertActionStyle)CPAlertActionStyle:(NSString*) json {
|
|
87
|
+
if ([json isEqualToString:@"cancel"]) {
|
|
88
|
+
return CPAlertActionStyleCancel;
|
|
89
|
+
} else if ([json isEqualToString:@"destructive"]) {
|
|
90
|
+
return CPAlertActionStyleDestructive;
|
|
91
|
+
}
|
|
92
|
+
return CPAlertActionStyleDefault;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@end
|
package/ios/RNCPStore.h
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <CarPlay/CarPlay.h>
|
|
3
|
+
|
|
4
|
+
@interface RNCPStore : NSObject {
|
|
5
|
+
CPInterfaceController *interfaceController;
|
|
6
|
+
CPWindow *window;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@property (nonatomic, retain) CPInterfaceController *interfaceController;
|
|
10
|
+
@property (nonatomic, retain) CPWindow *window;
|
|
11
|
+
|
|
12
|
+
+ (id)sharedManager;
|
|
13
|
+
- (CPTemplate*) findTemplateById: (NSString*)templateId;
|
|
14
|
+
- (NSString*) setTemplate:(NSString*)templateId template:(CPTemplate*)carPlayTemplate;
|
|
15
|
+
- (CPTrip*) findTripById: (NSString*)tripId;
|
|
16
|
+
- (NSString*) setTrip:(NSString*)tripId trip:(CPTrip*)trip;
|
|
17
|
+
- (CPNavigationSession*) findNavigationSessionById:(NSString*)navigationSessionId;
|
|
18
|
+
- (NSString*) setNavigationSession:(NSString*)navigationSessionId navigationSession:(CPNavigationSession*)navigationSession;
|
|
19
|
+
- (Boolean) isConnected;
|
|
20
|
+
- (void) setConnected:(Boolean) isConnected;
|
|
21
|
+
|
|
22
|
+
@end
|
package/ios/RNCPStore.m
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#import "RNCPStore.h"
|
|
2
|
+
|
|
3
|
+
@implementation RNCPStore {
|
|
4
|
+
NSMutableDictionary* _templatesStore;
|
|
5
|
+
NSMutableDictionary* _navigationSessionsStore;
|
|
6
|
+
NSMutableDictionary* _tripsStore;
|
|
7
|
+
Boolean _connected;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@synthesize window;
|
|
11
|
+
@synthesize interfaceController;
|
|
12
|
+
|
|
13
|
+
-(instancetype)init {
|
|
14
|
+
if (self = [super init]) {
|
|
15
|
+
_templatesStore = [[NSMutableDictionary alloc] init];
|
|
16
|
+
_navigationSessionsStore = [[NSMutableDictionary alloc] init];
|
|
17
|
+
_tripsStore = [[NSMutableDictionary alloc] init];
|
|
18
|
+
_connected = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
+ (RNCPStore*) sharedManager {
|
|
25
|
+
static RNCPStore *shared = nil;
|
|
26
|
+
static dispatch_once_t onceToken;
|
|
27
|
+
dispatch_once(&onceToken, ^{
|
|
28
|
+
shared = [[self alloc] init];
|
|
29
|
+
});
|
|
30
|
+
return shared;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void) setConnected:(Boolean) isConnected {
|
|
34
|
+
_connected = isConnected;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (Boolean) isConnected {
|
|
38
|
+
return _connected;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (CPTemplate*) findTemplateById:(NSString*)templateId {
|
|
42
|
+
return [_templatesStore objectForKey:templateId];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (NSString*) setTemplate:(NSString*)templateId template:(CPTemplate*)carPlayTemplate {
|
|
46
|
+
[_templatesStore setObject:carPlayTemplate forKey:templateId];
|
|
47
|
+
return templateId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (CPTrip*) findTripById:(NSString*)tripId {
|
|
51
|
+
return [_tripsStore objectForKey:tripId];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (NSString*) setTrip:(NSString*)tripId trip:(CPTrip*)trip {
|
|
55
|
+
[_tripsStore setObject:trip forKey:tripId];
|
|
56
|
+
return tripId;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (CPNavigationSession*) findNavigationSessionById:(NSString*)navigationSessionId {
|
|
60
|
+
return [_navigationSessionsStore objectForKey:navigationSessionId];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (NSString*) setNavigationSession:(NSString*)navigationSessionId navigationSession:(CPNavigationSession*)navigationSession {
|
|
64
|
+
[_navigationSessionsStore setObject:navigationSession forKey:navigationSessionId];
|
|
65
|
+
return navigationSessionId;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@end
|
package/ios/RNCarPlay.h
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <CarPlay/CarPlay.h>
|
|
3
|
+
#import <React/RCTBridgeModule.h>
|
|
4
|
+
#import <React/RCTEventEmitter.h>
|
|
5
|
+
#import "RCTConvert+RNCarPlay.h"
|
|
6
|
+
#import "RNCPStore.h"
|
|
7
|
+
|
|
8
|
+
API_AVAILABLE(ios(12.0))
|
|
9
|
+
typedef void (^SearchResultUpdateBlock)(NSArray<CPListItem *> *_Nonnull);
|
|
10
|
+
typedef void (^SelectedResultBlock)(void);
|
|
11
|
+
|
|
12
|
+
API_AVAILABLE(ios(12.0))
|
|
13
|
+
@interface RNCarPlay : RCTEventEmitter <RCTBridgeModule, CPInterfaceControllerDelegate, CPSearchTemplateDelegate, CPListTemplateDelegate, CPMapTemplateDelegate, CPTabBarTemplateDelegate, CPPointOfInterestTemplateDelegate, CPNowPlayingTemplateObserver>
|
|
14
|
+
{
|
|
15
|
+
CPInterfaceController *interfaceController;
|
|
16
|
+
CPWindow *window;
|
|
17
|
+
SearchResultUpdateBlock searchResultBlock;
|
|
18
|
+
SelectedResultBlock selectedResultBlock;
|
|
19
|
+
BOOL isNowPlayingActive;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@property(nonatomic, retain) CPInterfaceController * _Nonnull interfaceController;
|
|
23
|
+
@property(nonatomic, retain) CPWindow * _Nonnull window;
|
|
24
|
+
@property(nonatomic, copy) SearchResultUpdateBlock _Nullable searchResultBlock;
|
|
25
|
+
@property(nonatomic, copy) SelectedResultBlock _Nullable selectedResultBlock;
|
|
26
|
+
@property(nonatomic) BOOL isNowPlayingActive;
|
|
27
|
+
@property(nullable, nonatomic, copy) void (^listImageRowHandler)(CPListImageRowItem * _Nonnull item, NSInteger index, dispatch_block_t _Nonnull completionBlock) API_AVAILABLE(ios(14.0));
|
|
28
|
+
|
|
29
|
+
+ (void)connectWithInterfaceController:(CPInterfaceController *_Nonnull)interfaceController window:(CPWindow *_Nonnull)window;
|
|
30
|
+
+ (void)disconnect;
|
|
31
|
+
|
|
32
|
+
@end
|