-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (27 loc) · 875 Bytes
/
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
const merge = require('lodash/merge')
const mergeWith = require('lodash/mergeWith')
const ReactNative = require('react-native')
module.exports = function (styles) {
function evaluate(func, args) {
if (typeof func !== 'function') return func
return func.apply(null, args)
}
// Handle functions
function customizer(objValue, srcValue) {
if (typeof objValue === 'function' || typeof srcValue === 'function') {
return function () {
return merge(evaluate(objValue, arguments), evaluate(srcValue, arguments))
}
}
return undefined
}
switch (ReactNative.Platform.OS) {
case 'ios':
return mergeWith(styles, styles.ios || {}, customizer)
case 'android':
return mergeWith(styles, styles.android || {}, customizer)
case 'web':
return mergeWith(styles, styles.web || {}, customizer)
}
return {}
}