-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(component): image switch textinput
- Loading branch information
1 parent
dfeabd5
commit 003e4ff
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |