-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
index.js
38 lines (31 loc) · 1.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { NativeModules, Platform, processColor } from 'react-native';
const AddCalendarEvent = NativeModules.AddCalendarEvent;
export const presentEventViewingDialog = options => {
return AddCalendarEvent.presentEventViewingDialog(processColorsIOS(options));
};
export const presentEventEditingDialog = options => {
return AddCalendarEvent.presentEventEditingDialog(processColorsIOS(options));
};
export const presentEventCreatingDialog = options => {
return AddCalendarEvent.presentEventCreatingDialog(processColorsIOS(options));
};
const processColorsIOS = config => {
if (Platform.OS === 'android' || !config || !config.navigationBarIOS) {
return config;
} else {
return transformConfigColors(config);
}
};
export const transformConfigColors = config => {
const transformedKeys = ['tintColor', 'barTintColor', 'backgroundColor', 'titleColor'];
const { navigationBarIOS } = config;
const processedColors = Object.keys(navigationBarIOS)
.filter(key => transformedKeys.includes(key))
.reduce(
(accumulator, key) => ({ ...accumulator, [key]: processColor(navigationBarIOS[key]) }),
{}
);
const configCopy = { ...config };
configCopy.navigationBarIOS = { ...configCopy.navigationBarIOS, ...processedColors };
return configCopy;
};