diff --git a/src/CustomFunctions/extractProps.js b/src/CustomFunctions/extractProps.js new file mode 100644 index 0000000..ea93e00 --- /dev/null +++ b/src/CustomFunctions/extractProps.js @@ -0,0 +1,11 @@ +export default (customProps, originalProps) => { + if (Array.isArray(originalProps.style)) { + originalProps.style.forEach((style) => { + customProps.style = [...customProps.style, style]; + }); + } else { + customProps.style = [...customProps.style, originalProps.style]; + } + + return customProps; +}; diff --git a/src/CustomFunctions/setCustomActivityIndicator.js b/src/CustomFunctions/setCustomActivityIndicator.js index 51b8306..001f5fd 100644 --- a/src/CustomFunctions/setCustomActivityIndicator.js +++ b/src/CustomFunctions/setCustomActivityIndicator.js @@ -1,4 +1,5 @@ import { ActivityIndicator } from 'react-native' +import extractProps from './extractProps' export const setCustomActivityIndicator = customProps => { const ActivityIndicatorRender = ActivityIndicator.render @@ -9,7 +10,10 @@ export const setCustomActivityIndicator = customProps => { } ActivityIndicator.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ActivityIndicatorRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomImage.js b/src/CustomFunctions/setCustomImage.js index 5b36ccf..1ad92f3 100644 --- a/src/CustomFunctions/setCustomImage.js +++ b/src/CustomFunctions/setCustomImage.js @@ -1,4 +1,5 @@ import { Image } from 'react-native' +import extractProps from './extractProps' export const setCustomImage = customProps => { const ImageRender = Image.render @@ -9,7 +10,10 @@ export const setCustomImage = customProps => { } Image.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ImageRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomKeyboardAvoidingView.js b/src/CustomFunctions/setCustomKeyboardAvoidingView.js index 21d7333..039d16b 100644 --- a/src/CustomFunctions/setCustomKeyboardAvoidingView.js +++ b/src/CustomFunctions/setCustomKeyboardAvoidingView.js @@ -1,4 +1,5 @@ import { KeyboardAvoidingView } from 'react-native' +import extractProps from './extractProps' export const setCustomKeyboardAvoidingView = customProps => { const KeyboardAvoidingViewRender = KeyboardAvoidingView.render @@ -9,7 +10,10 @@ export const setCustomKeyboardAvoidingView = customProps => { } KeyboardAvoidingView.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return KeyboardAvoidingViewRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomListView.js b/src/CustomFunctions/setCustomListView.js index 895e2bc..1e50992 100644 --- a/src/CustomFunctions/setCustomListView.js +++ b/src/CustomFunctions/setCustomListView.js @@ -1,4 +1,5 @@ import { ListView } from 'react-native' +import extractProps from './extractProps' export const setCustomListView = customProps => { const ListViewRender = ListView.render @@ -9,7 +10,10 @@ export const setCustomListView = customProps => { } ListView.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ListViewRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomModal.js b/src/CustomFunctions/setCustomModal.js index b63edae..56c554a 100644 --- a/src/CustomFunctions/setCustomModal.js +++ b/src/CustomFunctions/setCustomModal.js @@ -1,4 +1,5 @@ import { Modal } from 'react-native' +import extractProps from './extractProps' export const setCustomModal = customProps => { const ModalRender = Modal.render @@ -9,7 +10,10 @@ export const setCustomModal = customProps => { } Modal.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ModalRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomPicker.js b/src/CustomFunctions/setCustomPicker.js index 2285cb9..fca4ab3 100644 --- a/src/CustomFunctions/setCustomPicker.js +++ b/src/CustomFunctions/setCustomPicker.js @@ -1,4 +1,5 @@ import { Picker } from 'react-native' +import extractProps from './extractProps' export const setCustomPicker = customProps => { const PickerRender = Picker.render @@ -9,7 +10,10 @@ export const setCustomPicker = customProps => { } Picker.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return PickerRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomRefreshControl.js b/src/CustomFunctions/setCustomRefreshControl.js index 7a341bf..fb66796 100644 --- a/src/CustomFunctions/setCustomRefreshControl.js +++ b/src/CustomFunctions/setCustomRefreshControl.js @@ -1,4 +1,5 @@ import { RefreshControl } from 'react-native' +import extractProps from './extractProps' export const setCustomRefreshControl = customProps => { const RefreshControlRender = RefreshControl.render @@ -9,7 +10,10 @@ export const setCustomRefreshControl = customProps => { } RefreshControl.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return RefreshControlRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomScrollView.js b/src/CustomFunctions/setCustomScrollView.js index b0ca8fe..f05f019 100644 --- a/src/CustomFunctions/setCustomScrollView.js +++ b/src/CustomFunctions/setCustomScrollView.js @@ -1,4 +1,5 @@ import { ScrollView } from 'react-native' +import extractProps from './extractProps' export const setCustomScrollView = customProps => { const ScrollViewRender = ScrollView.render @@ -9,7 +10,10 @@ export const setCustomScrollView = customProps => { } ScrollView.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ScrollViewRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomSlider.js b/src/CustomFunctions/setCustomSlider.js index b054c22..7d90d2f 100644 --- a/src/CustomFunctions/setCustomSlider.js +++ b/src/CustomFunctions/setCustomSlider.js @@ -1,4 +1,5 @@ import { Slider } from 'react-native' +import extractProps from './extractProps' export const setCustomSlider = customProps => { const SliderRender = Slider.render @@ -9,7 +10,10 @@ export const setCustomSlider = customProps => { } Slider.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return SliderRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomStatusBar.js b/src/CustomFunctions/setCustomStatusBar.js index 554dda8..a17a110 100644 --- a/src/CustomFunctions/setCustomStatusBar.js +++ b/src/CustomFunctions/setCustomStatusBar.js @@ -1,4 +1,5 @@ import { StatusBar } from 'react-native' +import extractProps from './extractProps' export const setCustomStatusBar = customProps => { const StatusBarRender = StatusBar.render @@ -9,7 +10,10 @@ export const setCustomStatusBar = customProps => { } StatusBar.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return StatusBarRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomSwitch.js b/src/CustomFunctions/setCustomSwitch.js index 29515d3..8d12878 100644 --- a/src/CustomFunctions/setCustomSwitch.js +++ b/src/CustomFunctions/setCustomSwitch.js @@ -1,4 +1,5 @@ import { Switch } from 'react-native' +import extractProps from './extractProps' export const setCustomSwitch = customProps => { const SwitchRender = Switch.render @@ -9,7 +10,10 @@ export const setCustomSwitch = customProps => { } Switch.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return SwitchRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomText.js b/src/CustomFunctions/setCustomText.js index 7f0902b..562c516 100644 --- a/src/CustomFunctions/setCustomText.js +++ b/src/CustomFunctions/setCustomText.js @@ -1,4 +1,5 @@ import { Text } from 'react-native' +import extractProps from './extractProps' export const setCustomText = customProps => { const TextRender = Text.render @@ -9,7 +10,10 @@ export const setCustomText = customProps => { } Text.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TextRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomTextInput.js b/src/CustomFunctions/setCustomTextInput.js index 6757ba7..6e60d09 100644 --- a/src/CustomFunctions/setCustomTextInput.js +++ b/src/CustomFunctions/setCustomTextInput.js @@ -1,4 +1,5 @@ import { TextInput } from 'react-native' +import extractProps from './extractProps' export const setCustomTextInput = customProps => { const TextInputRender = TextInput.render @@ -9,7 +10,10 @@ export const setCustomTextInput = customProps => { } TextInput.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TextInputRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomTouchable.js b/src/CustomFunctions/setCustomTouchable.js index daed390..655359d 100644 --- a/src/CustomFunctions/setCustomTouchable.js +++ b/src/CustomFunctions/setCustomTouchable.js @@ -4,6 +4,7 @@ import { TouchableWithoutFeedback, TouchableOpacity } from 'react-native'; +import extractProps from './extractProps'; export const setCustomTouchableNativeFeedback = customProps => { const TouchableNativeFeedbackRender = TouchableNativeFeedback.render @@ -14,7 +15,10 @@ export const setCustomTouchableNativeFeedback = customProps => { } TouchableNativeFeedback.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TouchableNativeFeedbackRender.apply(this, arguments) } finally { @@ -31,7 +35,10 @@ export const setCustomTouchableWithoutFeedback = customProps => { } TouchableWithoutFeedback.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TouchableWithoutFeedbackRender.apply(this, arguments) } finally { @@ -48,7 +55,10 @@ export const setCustomTouchableOpacity = customProps => { } TouchableOpacity.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TouchableOpacityRender.apply(this, arguments) } finally { @@ -65,7 +75,10 @@ export const setCustomTouchableHighlight = customProps => { } TouchableHighlight.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return TouchableHighlightRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomView.js b/src/CustomFunctions/setCustomView.js index c88734d..1a21fe0 100644 --- a/src/CustomFunctions/setCustomView.js +++ b/src/CustomFunctions/setCustomView.js @@ -1,6 +1,5 @@ -import { - View -} from 'react-native'; +import { View } from 'react-native'; +import extractProps from './extractProps'; export const setCustomView = customProps => { const ViewRender = View.render @@ -11,7 +10,10 @@ export const setCustomView = customProps => { } View.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return ViewRender.apply(this, arguments) } finally { diff --git a/src/CustomFunctions/setCustomWebView.js b/src/CustomFunctions/setCustomWebView.js index 687dc95..4ef5011 100644 --- a/src/CustomFunctions/setCustomWebView.js +++ b/src/CustomFunctions/setCustomWebView.js @@ -1,6 +1,5 @@ -import { - WebView -} from 'react-native'; +import { WebView } from 'react-native'; +import extractProps from './extractProps'; export const setCustomWebView = customProps => { const WebViewRender = WebView.render @@ -11,7 +10,10 @@ export const setCustomWebView = customProps => { } WebView.render = function render(props) { let oldProps = props - props = { ...props, style: [customProps.style, props.style] } + props = { ...props, style: [customProps.style] } + + props = extractProps(props, oldProps) + try { return WebViewRender.apply(this, arguments) } finally {