Merge pull request #14 from maieonbrix/master

convert all custom function [wip][do_not_merge_now]
This commit is contained in:
Andrew Jackson
2018-10-08 10:14:00 -04:00
committed by GitHub
16 changed files with 228 additions and 253 deletions

View File

@@ -1,19 +1,19 @@
import { ActivityIndicator } from 'react-native'; import { ActivityIndicator } from 'react-native'
export const setCustomActivityIndicator = customProps => { export const setCustomActivityIndicator = customProps => {
const ActivityIndicatorRender = ActivityIndicator.prototype.render; const ActivityIndicatorRender = ActivityIndicator.render
const initialDefaultProps = ActivityIndicator.prototype.constructor.defaultProps; const initialDefaultProps = ActivityIndicator.defaultProps
ActivityIndicator.prototype.constructor.defaultProps = { ActivityIndicator.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
ActivityIndicator.prototype.render = function render() { ActivityIndicator.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ActivityIndicatorRender.apply(this, arguments); return ActivityIndicatorRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Image } from 'react-native'
Image
} from 'react-native';
export const setCustomImage = customProps => { export const setCustomImage = customProps => {
const ImageRender = Image.prototype.render; const ImageRender = Image.render
const initialDefaultProps = Image.prototype.constructor.defaultProps; const initialDefaultProps = Image.defaultProps
Image.prototype.constructor.defaultProps = { Image.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Image.prototype.render = function render() { Image.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ImageRender.apply(this, arguments); return ImageRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,19 +1,19 @@
import { KeyboardAvoidingView } from 'react-native'; import { KeyboardAvoidingView } from 'react-native'
export const setCustomKeyboardAvoidingView = customProps => { export const setCustomKeyboardAvoidingView = customProps => {
const KeyboardAvoidingViewRender = KeyboardAvoidingView.prototype.render; const KeyboardAvoidingViewRender = KeyboardAvoidingView.render
const initialDefaultProps = KeyboardAvoidingView.prototype.constructor.defaultProps; const initialDefaultProps = KeyboardAvoidingView.defaultProps
KeyboardAvoidingView.prototype.constructor.defaultProps = { KeyboardAvoidingView.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
KeyboardAvoidingView.prototype.render = function render() { KeyboardAvoidingView.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return KeyboardAvoidingViewRender.apply(this, arguments); return KeyboardAvoidingViewRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { ListView } from 'react-native'
ListView
} from 'react-native';
export const setCustomListView = customProps => { export const setCustomListView = customProps => {
const ListViewRender = ListView.prototype.render; const ListViewRender = ListView.render
const initialDefaultProps = ListView.prototype.constructor.defaultProps; const initialDefaultProps = ListView.defaultProps
ListView.prototype.constructor.defaultProps = { ListView.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
ListView.prototype.render = function render() { ListView.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ListViewRender.apply(this, arguments); return ListViewRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Modal } from 'react-native'
Modal
} from 'react-native';
export const setCustomModal = customProps => { export const setCustomModal = customProps => {
const ModalRender = Modal.prototype.render; const ModalRender = Modal.render
const initialDefaultProps = Modal.prototype.constructor.defaultProps; const initialDefaultProps = Modal.defaultProps
Modal.prototype.constructor.defaultProps = { Modal.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Modal.prototype.render = function render() { Modal.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ModalRender.apply(this, arguments); return ModalRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Picker } from 'react-native'
Picker
} from 'react-native';
export const setCustomPicker = customProps => { export const setCustomPicker = customProps => {
const PickerRender = Picker.prototype.render; const PickerRender = Picker.render
const initialDefaultProps = Picker.prototype.constructor.defaultProps; const initialDefaultProps = Picker.defaultProps
Picker.prototype.constructor.defaultProps = { Picker.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Picker.prototype.render = function render() { Picker.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return PickerRender.apply(this, arguments); return PickerRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { RefreshControl } from 'react-native'
RefreshControl
} from 'react-native';
export const setCustomRefreshControl = customProps => { export const setCustomRefreshControl = customProps => {
const RefreshControlRender = RefreshControl.prototype.render; const RefreshControlRender = RefreshControl.render
const initialDefaultProps = RefreshControl.prototype.constructor.defaultProps; const initialDefaultProps = RefreshControl.defaultProps
RefreshControl.prototype.constructor.defaultProps = { RefreshControl.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
RefreshControl.prototype.render = function render() { RefreshControl.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return RefreshControlRender.apply(this, arguments); return RefreshControlRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { ScrollView } from 'react-native'
ScrollView
} from 'react-native';
export const setCustomScrollView = customProps => { export const setCustomScrollView = customProps => {
const ScrollViewRender = ScrollView.prototype.render; const ScrollViewRender = ScrollView.render
const initialDefaultProps = ScrollView.prototype.constructor.defaultProps; const initialDefaultProps = ScrollView.defaultProps
ScrollView.prototype.constructor.defaultProps = { ScrollView.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
ScrollView.prototype.render = function render() { ScrollView.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ScrollViewRender.apply(this, arguments); return ScrollViewRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Slider } from 'react-native'
Slider
} from 'react-native';
export const setCustomSlider = customProps => { export const setCustomSlider = customProps => {
const SliderRender = Slider.prototype.render; const SliderRender = Slider.render
const initialDefaultProps = Slider.prototype.constructor.defaultProps; const initialDefaultProps = Slider.defaultProps
Slider.prototype.constructor.defaultProps = { Slider.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Slider.prototype.render = function render() { Slider.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return SliderRender.apply(this, arguments); return SliderRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { StatusBar } from 'react-native'
StatusBar
} from 'react-native';
export const setCustomStatusBar = customProps => { export const setCustomStatusBar = customProps => {
const StatusBarRender = StatusBar.prototype.render; const StatusBarRender = StatusBar.render
const initialDefaultProps = StatusBar.prototype.constructor.defaultProps; const initialDefaultProps = StatusBar.defaultProps
StatusBar.prototype.constructor.defaultProps = { StatusBar.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
StatusBar.prototype.render = function render() { StatusBar.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return StatusBarRender.apply(this, arguments); return StatusBarRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Switch } from 'react-native'
Switch
} from 'react-native';
export const setCustomSwitch = customProps => { export const setCustomSwitch = customProps => {
const SwitchRender = Switch.prototype.render; const SwitchRender = Switch.render
const initialDefaultProps = Switch.prototype.constructor.defaultProps; const initialDefaultProps = Switch.defaultProps
Switch.prototype.constructor.defaultProps = { Switch.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Switch.prototype.render = function render() { Switch.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return SwitchRender.apply(this, arguments); return SwitchRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { Text } from 'react-native'
Text,
} from 'react-native';
export const setCustomText = customProps => { export const setCustomText = customProps => {
const TextRender = Text.prototype.render; const TextRender = Text.render
const initialDefaultProps = Text.prototype.constructor.defaultProps; const initialDefaultProps = Text.defaultProps
Text.prototype.constructor.defaultProps = { Text.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
Text.prototype.render = function render() { Text.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return TextRender.apply(this, arguments); return TextRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -1,21 +1,19 @@
import { import { TextInput } from 'react-native'
TextInput
} from 'react-native';
export const setCustomTextInput = customProps => { export const setCustomTextInput = customProps => {
const TextInputRender = TextInput.prototype.render; const TextInputRender = TextInput.render
const initialDefaultProps = TextInput.prototype.constructor.defaultProps; const initialDefaultProps = TextInput.defaultProps
TextInput.prototype.constructor.defaultProps = { TextInput.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
TextInput.prototype.render = function render() { TextInput.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return TextInputRender.apply(this, arguments); return TextInputRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -5,74 +5,71 @@ import {
TouchableOpacity TouchableOpacity
} from 'react-native'; } from 'react-native';
export const setCustomTouchableHighlight = customProps => {
const TouchableHighlightRender = TouchableHighlight.prototype.render;
const initialDefaultProps = TouchableHighlight.prototype.constructor.defaultProps;
TouchableHighlight.prototype.constructor.defaultProps = {
...initialDefaultProps,
...customProps,
}
TouchableHighlight.prototype.render = function render() {
let oldProps = this.props;
this.props = { ...this.props, style: [customProps.style, this.props.style] };
try {
return TouchableHighlightRender.apply(this, arguments);
} finally {
this.props = oldProps;
}
};
};
export const setCustomTouchableNativeFeedback = customProps => { export const setCustomTouchableNativeFeedback = customProps => {
const TouchableNativeFeedbackRender = TouchableNativeFeedback.prototype.render; const TouchableNativeFeedbackRender = TouchableNativeFeedback.render
const initialDefaultProps = TouchableNativeFeedback.prototype.constructor.defaultProps; const initialDefaultProps = TouchableNativeFeedback.defaultProps
TouchableNativeFeedback.prototype.constructor.defaultProps = { TouchableNativeFeedback.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
TouchableNativeFeedback.prototype.render = function render() { TouchableNativeFeedback.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return TouchableNativeFeedbackRender.apply(this, arguments); return TouchableNativeFeedbackRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }
export const setCustomTouchableWithoutFeedback = customProps => { export const setCustomTouchableWithoutFeedback = customProps => {
const TouchableWithoutFeedbackRender = TouchableWithoutFeedback.prototype.render; const TouchableWithoutFeedbackRender = TouchableWithoutFeedback.render
const initialDefaultProps = TouchableWithoutFeedback.prototype.constructor.defaultProps; const initialDefaultProps = TouchableWithoutFeedback.defaultProps
TouchableWithoutFeedback.prototype.constructor.defaultProps = { TouchableWithoutFeedback.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
TouchableWithoutFeedback.prototype.render = function render() { TouchableWithoutFeedback.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return TouchableWithoutFeedbackRender.apply(this, arguments); return TouchableWithoutFeedbackRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }
export const setCustomTouchableOpacity = customProps => { export const setCustomTouchableOpacity = customProps => {
const TouchableOpacityRender = TouchableOpacity.prototype.render; const TouchableOpacityRender = TouchableOpacity.render
const initialDefaultProps = TouchableOpacity.prototype.constructor.defaultProps; const initialDefaultProps = TouchableOpacity.defaultProps
TouchableOpacity.prototype.constructor.defaultProps = { TouchableOpacity.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
TouchableOpacity.prototype.render = function render() { TouchableOpacity.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return TouchableOpacityRender.apply(this, arguments); return TouchableOpacityRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }
export const setCustomTouchableHighlight = customProps => {
const TouchableHighlightRender = TouchableHighlight.render
const initialDefaultProps = TouchableHighlight.defaultProps
TouchableHighlight.defaultProps = {
...initialDefaultProps,
...customProps
}
TouchableHighlight.render = function render(props) {
let oldProps = props
props = { ...props, style: [customProps.style, props.style] }
try {
return TouchableHighlightRender.apply(this, arguments)
} finally {
props = oldProps
}
}
}

View File

@@ -3,19 +3,19 @@ import {
} from 'react-native'; } from 'react-native';
export const setCustomView = customProps => { export const setCustomView = customProps => {
const ViewRender = View.prototype.render; const ViewRender = View.render
const initialDefaultProps = View.prototype.constructor.defaultProps; const initialDefaultProps = View.defaultProps
View.prototype.constructor.defaultProps = { View.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
View.prototype.render = function render() { View.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return ViewRender.apply(this, arguments); return ViewRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }

View File

@@ -3,19 +3,19 @@ import {
} from 'react-native'; } from 'react-native';
export const setCustomWebView = customProps => { export const setCustomWebView = customProps => {
const WebViewRender = WebView.prototype.render; const WebViewRender = WebView.render
const initialDefaultProps = WebView.prototype.constructor.defaultProps; const initialDefaultProps = WebView.defaultProps
WebView.prototype.constructor.defaultProps = { WebView.defaultProps = {
...initialDefaultProps, ...initialDefaultProps,
...customProps, ...customProps
} }
WebView.prototype.render = function render() { WebView.render = function render(props) {
let oldProps = this.props; let oldProps = props
this.props = { ...this.props, style: [customProps.style, this.props.style] }; props = { ...props, style: [customProps.style, props.style] }
try { try {
return WebViewRender.apply(this, arguments); return WebViewRender.apply(this, arguments)
} finally { } finally {
this.props = oldProps; props = oldProps
} }
}; }
}; }