Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/customizers/image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Image, type ImageProps } from 'react-native';

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

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

export const customizeTextInput = (customProps: TextInputProps) => {
const TextRender = (TextInput as any).render;
if (!TextRender) {
(TextInput as any).defaultProps = customProps;
return;
}
(TextInput as any).render = (props: any, ref: any) => {
props = {
...customProps,
...props,
style: [customProps.style, props.style],
};
return TextRender.call(this, props, ref);
};
};
14 changes: 13 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { customizeView } from './customizers/view';
import { customizeText } from './customizers/text';
import { customizeImage } from './customizers/image';
import { customizeTextInput } from './customizers/textInput';
import { customizeTextSwitch } from './customizers/switch';

const Customizer = {
Text: customizeText,
View: customizeView,
Image: customizeImage,
TextInput: customizeTextInput,
Switch: customizeTextSwitch,
};

export { customizeText, customizeView };
export {
customizeText,
customizeView,
customizeImage,
customizeTextInput,
customizeTextSwitch,
};

export default Customizer;
Loading