Skip to content

Commit

Permalink
Merge pull request #4 from mucahitdev/dev
Browse files Browse the repository at this point in the history
chore: new components
  • Loading branch information
mucahitdev authored Oct 15, 2023
2 parents 08b93ed + a265c54 commit b57fcec
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/customizers/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Button, type ButtonProps } from 'react-native';

export const customizeButton = (customProps: ButtonProps) => {
const ButtonRender = (Button as any).render;
if (!ButtonRender) {
(Button as any).defaultProps = customProps;
return;
}
(Button as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return ButtonRender.call(this, props, ref);
};
};
16 changes: 16 additions & 0 deletions src/customizers/flatList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FlatList, type FlatListProps } from 'react-native';

export const customizeFlatList = (customProps: FlatListProps<any>) => {
const FlatListRender = (FlatList as any).render;
if (!FlatListRender) {
(FlatList as any).defaultProps = customProps;
return;
}
(FlatList as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return FlatListRender.call(this, props, ref);
};
};
6 changes: 3 additions & 3 deletions src/customizers/image.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Image, type ImageProps } from 'react-native';

export const customizeImage = (customProps: ImageProps) => {
const TextRender = (Image as any).render;
if (!TextRender) {
const ImageRender = (Image as any).render;
if (!ImageRender) {
(Image as any).defaultProps = customProps;
return;
}
Expand All @@ -12,6 +12,6 @@ export const customizeImage = (customProps: ImageProps) => {
...props,
style: [customProps.style, props.style],
};
return TextRender.call(this, props, ref);
return ImageRender.call(this, props, ref);
};
};
17 changes: 17 additions & 0 deletions src/customizers/imageBackground.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ImageBackground, type ImageBackgroundProps } from 'react-native';

export const customizeImageBackground = (customProps: ImageBackgroundProps) => {
const ImageBackgroundRender = (ImageBackground as any).render;
if (!ImageBackgroundRender) {
(ImageBackground as any).defaultProps = customProps;
return;
}
(ImageBackground as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return ImageBackgroundRender.call(this, props, ref);
};
};
21 changes: 21 additions & 0 deletions src/customizers/keyboardAvoidingView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
KeyboardAvoidingView,
type KeyboardAvoidingViewProps,
} from 'react-native';

export const customizeKeyboardAvoidingView = (
customProps: KeyboardAvoidingViewProps
) => {
const KeyboardAvoidingViewRender = (KeyboardAvoidingView as any).render;
if (!KeyboardAvoidingViewRender) {
(KeyboardAvoidingView as any).defaultProps = customProps;
return;
}
(KeyboardAvoidingView as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return KeyboardAvoidingViewRender.call(this, props, ref);
};
};
17 changes: 17 additions & 0 deletions src/customizers/modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Modal, type ModalProps } from 'react-native';

export const customizeModal = (customProps: ModalProps) => {
const ModalRender = (Modal as any).render;
if (!ModalRender) {
(Modal as any).defaultProps = customProps;
return;
}
(Modal as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return ModalRender.call(this, props, ref);
};
};
17 changes: 17 additions & 0 deletions src/customizers/pressable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Pressable, type PressableProps } from 'react-native';

export const customizePressable = (customProps: PressableProps) => {
const PressableRender = (Pressable as any).render;
if (!PressableRender) {
(Pressable as any).defaultProps = customProps;
return;
}
(Pressable as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return PressableRender.call(this, props, ref);
};
};
16 changes: 16 additions & 0 deletions src/customizers/refreshControl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RefreshControl, type RefreshControlProps } from 'react-native';

export const customizeRefreshControl = (customProps: RefreshControlProps) => {
const RefreshControlRender = (RefreshControl as any).render;
if (!RefreshControlRender) {
(RefreshControl as any).defaultProps = customProps;
return;
}
(RefreshControl as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return RefreshControlRender.call(this, props, ref);
};
};
16 changes: 16 additions & 0 deletions src/customizers/scrollView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ScrollView, type ScrollViewProps } from 'react-native';

export const customizeScrollView = (customProps: ScrollViewProps) => {
const ScrollViewRender = (ScrollView as any).render;
if (!ScrollViewRender) {
(ScrollView as any).defaultProps = customProps;
return;
}
(ScrollView as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return ScrollViewRender.call(this, props, ref);
};
};
16 changes: 16 additions & 0 deletions src/customizers/sectionList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SectionList, type SectionListProps } from 'react-native';

export const customizeSectionList = (customProps: SectionListProps<any>) => {
const SectionListRender = (SectionList as any).render;
if (!SectionListRender) {
(SectionList as any).defaultProps = customProps;
return;
}
(SectionList as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return SectionListRender.call(this, props, ref);
};
};
16 changes: 16 additions & 0 deletions src/customizers/statusBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StatusBar, type StatusBarProps } from 'react-native';

export const customizeStatusBar = (customProps: StatusBarProps) => {
const StatusBarRender = (StatusBar as any).render;
if (!StatusBarRender) {
(StatusBar as any).defaultProps = customProps;
return;
}
(StatusBar as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
};
return StatusBarRender.call(this, props, ref);
};
};
6 changes: 3 additions & 3 deletions src/customizers/switch.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Switch, type SwitchProps } from 'react-native';

export const customizeTextSwitch = (customProps: SwitchProps) => {
const TextRender = (Switch as any).render;
if (!TextRender) {
const SwitchRender = (Switch as any).render;
if (!SwitchRender) {
(Switch as any).defaultProps = customProps;
return;
}
Expand All @@ -12,6 +12,6 @@ export const customizeTextSwitch = (customProps: SwitchProps) => {
...props,
style: [customProps.style, props.style],
};
return TextRender.call(this, props, ref);
return SwitchRender.call(this, props, ref);
};
};
6 changes: 3 additions & 3 deletions src/customizers/textInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TextInput, type TextInputProps } from 'react-native';

export const customizeTextInput = (customProps: TextInputProps) => {
const TextRender = (TextInput as any).render;
if (!TextRender) {
const TextInputRender = (TextInput as any).render;
if (!TextInputRender) {
(TextInput as any).defaultProps = customProps;
return;
}
Expand All @@ -12,6 +12,6 @@ export const customizeTextInput = (customProps: TextInputProps) => {
...props,
style: [customProps.style, props.style],
};
return TextRender.call(this, props, ref);
return TextInputRender.call(this, props, ref);
};
};
83 changes: 83 additions & 0 deletions src/customizers/touchable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {
TouchableHighlight,
TouchableNativeFeedback,
TouchableWithoutFeedback,
TouchableOpacity,
type TouchableHighlightProps,
type TouchableNativeFeedbackProps,
type TouchableWithoutFeedbackProps,
type TouchableOpacityProps,
} from 'react-native';

export const customizeTouchableHighlight = (
customProps: TouchableHighlightProps
) => {
const TouchableHighlightRender = (TouchableHighlight as any).render;
if (!TouchableHighlightRender) {
(TouchableHighlight as any).defaultProps = customProps;
return;
}
(TouchableHighlight as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return TouchableHighlightRender.call(this, props, ref);
};
};

export const customizeTouchableNativeFeedback = (
customProps: TouchableNativeFeedbackProps
) => {
const TouchableNativeFeedbackRender = (TouchableNativeFeedback as any).render;
if (!TouchableNativeFeedbackRender) {
(TouchableNativeFeedback as any).defaultProps = customProps;
return;
}
(TouchableNativeFeedback as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return TouchableNativeFeedbackRender.call(this, props, ref);
};
};

export const customizeTouchableWithoutFeedback = (
customProps: TouchableWithoutFeedbackProps
) => {
const TouchableWithoutFeedbackRender = (TouchableWithoutFeedback as any)
.render;
if (!TouchableWithoutFeedbackRender) {
(TouchableWithoutFeedback as any).defaultProps = customProps;
return;
}
(TouchableWithoutFeedback as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return TouchableWithoutFeedbackRender.call(this, props, ref);
};
};

export const customizeTouchableOpacity = (
customProps: TouchableOpacityProps
) => {
const TouchableOpacityRender = (TouchableOpacity as any).render;
if (!TouchableOpacityRender) {
(TouchableOpacity as any).defaultProps = customProps;
return;
}
(TouchableOpacity as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return TouchableOpacityRender.call(this, props, ref);
};
};
6 changes: 3 additions & 3 deletions src/customizers/view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { View, type ViewProps } from 'react-native';

export const customizeView = (customProps: ViewProps) => {
const TextRender = (View as any).render;
if (!TextRender) {
const ViewRender = (View as any).render;
if (!ViewRender) {
(View as any).defaultProps = customProps;
return;
}
Expand All @@ -12,6 +12,6 @@ export const customizeView = (customProps: ViewProps) => {
...props,
style: [customProps.style, props.style],
};
return TextRender.call(this, props, ref);
return ViewRender.call(this, props, ref);
};
};
Loading

0 comments on commit b57fcec

Please sign in to comment.