File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed
Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const App = () => {
2222 } }
2323 >
2424 < InteractiveTextInput />
25- < InteractiveTextInput />
25+ < InteractiveTextInput placeholder = "Password" secureTextEntry enableIcon />
2626 < InteractiveTextInput />
2727 </ SafeAreaView >
2828 ) ;
Original file line number Diff line number Diff line change 66 TextInputProps ,
77 ViewStyle ,
88 Animated ,
9+ Image ,
10+ TouchableOpacity ,
11+ View ,
912} from "react-native" ;
1013/**
1114 * ? Local Imports
@@ -25,6 +28,9 @@ type CustomStyleProp = StyleProp<ViewStyle> | Array<StyleProp<ViewStyle>>;
2528
2629interface IInteractiveTextInputProps extends TextInputProps {
2730 style ?: CustomStyleProp ;
31+ ImageComponent ?: any ;
32+ IconComponent ?: any ;
33+ enableIcon ?: boolean ;
2834}
2935
3036interface IState { }
@@ -57,7 +63,40 @@ export default class InteractiveTextInput extends React.Component<
5763 } ) . start ( ) ;
5864 } ;
5965
60- render ( ) {
66+ /* -------------------------------------------------------------------------- */
67+ /* Render Methods */
68+ /* -------------------------------------------------------------------------- */
69+
70+ renderIcon = ( ) => {
71+ const {
72+ enableIcon,
73+ ImageComponent = Image ,
74+ IconComponent = TouchableOpacity ,
75+ } = this . props ;
76+
77+ return (
78+ enableIcon && (
79+ < IconComponent
80+ style = { {
81+ right : 16 ,
82+ position : "absolute" ,
83+ } }
84+ >
85+ < ImageComponent
86+ resizeMode = "contain"
87+ source = { require ( "../assets/visibility-button.png" ) }
88+ style = { {
89+ height : 20 ,
90+ width : 20 ,
91+ tintColor : "#b5b9bb" ,
92+ } }
93+ />
94+ </ IconComponent >
95+ )
96+ ) ;
97+ } ;
98+
99+ renderAnimatedTextInput = ( ) => {
61100 let borderColor = this . interpolatedColor . interpolate ( {
62101 inputRange : [ ORIGINAL_VALUE , SUCCESS_VALUE ] ,
63102 outputRange : [ ORIGINAL_COLOR , SUCCESS_COLOR ] ,
@@ -87,7 +126,17 @@ export default class InteractiveTextInput extends React.Component<
87126 onBlur = { ( ) => {
88127 this . showOriginColor ( ) ;
89128 } }
129+ { ...this . props }
90130 />
91131 ) ;
132+ } ;
133+
134+ render ( ) {
135+ return (
136+ < View style = { { flexDirection : "row" , alignItems : "center" } } >
137+ { this . renderAnimatedTextInput ( ) }
138+ { this . renderIcon ( ) }
139+ </ View >
140+ ) ;
92141 }
93142}
You can’t perform that action at this time.
0 commit comments