File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
Libraries/Components/TextInput
packages/rn-tester/js/examples/TextInput Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -532,6 +532,13 @@ export type Props = $ReadOnly<{|
532532 */
533533 editable ?: ?boolean ,
534534
535+ /** `readOnly` works like the `readonly` attribute in HTML.
536+ * If `true`, text is not editable. The default value is `false`.
537+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly
538+ * for more details.
539+ */
540+ readOnly ?: ?boolean ,
541+
535542 forwardedRef ?: ?ReactRefSetter <
536543 React . ElementRef < HostComponent < mixed >> & ImperativeMethods ,
537544 > ,
@@ -1381,6 +1388,7 @@ const ExportedForwardRef: React.AbstractComponent<
13811388 allowFontScaling = true ,
13821389 rejectResponderTermination = true ,
13831390 underlineColorAndroid = 'transparent' ,
1391+ readOnly = false ,
13841392 ...restProps
13851393 } ,
13861394 forwardedRef : ReactRefSetter <
@@ -1392,6 +1400,7 @@ const ExportedForwardRef: React.AbstractComponent<
13921400 allowFontScaling = { allowFontScaling }
13931401 rejectResponderTermination = { rejectResponderTermination }
13941402 underlineColorAndroid = { underlineColorAndroid }
1403+ editable = { ! readOnly }
13951404 { ...restProps }
13961405 forwardedRef = { forwardedRef }
13971406 />
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ const styles = StyleSheet.create({
148148 singleLineWithHeightTextInput : {
149149 height : 30 ,
150150 } ,
151+ default : {
152+ borderWidth : StyleSheet . hairlineWidth ,
153+ borderColor : '#0f0f0f' ,
154+ flex : 1 ,
155+ fontSize : 13 ,
156+ padding : 4 ,
157+ } ,
151158} ) ;
152159
153160exports . title = 'TextInput' ;
@@ -347,6 +354,35 @@ exports.examples = ([
347354 ) ;
348355 } ,
349356 } ,
357+ {
358+ title : 'Editable and Read only ',
359+ render : function ( ) : React . Node {
360+ return (
361+ < View >
362+ < TextInput
363+ placeholder = "editable text input using editable prop"
364+ style = { styles . default }
365+ editable
366+ />
367+ < TextInput
368+ placeholder = "uneditable text input using editable prop"
369+ style = { styles . default }
370+ editable = { false }
371+ />
372+ < TextInput
373+ placeholder = "editable text input using readOnly prop"
374+ style = { styles . default }
375+ readOnly = { false }
376+ />
377+ < TextInput
378+ placeholder = "uneditable text input using readOnly prop"
379+ style = { styles . default }
380+ readOnly
381+ />
382+ </ View >
383+ ) ;
384+ } ,
385+ } ,
350386 {
351387 title : 'Fixed number of lines' ,
352388 platform : 'android' ,
Original file line number Diff line number Diff line change @@ -621,6 +621,35 @@ exports.examples = ([
621621 ) ;
622622 } ,
623623 } ,
624+ {
625+ title : 'Editable and Read only ',
626+ render : function ( ) : React . Node {
627+ return (
628+ < View >
629+ < TextInput
630+ placeholder = "editable text input using editable prop"
631+ style = { styles . default }
632+ editable
633+ />
634+ < TextInput
635+ placeholder = "uneditable text input using editable prop"
636+ style = { styles . default }
637+ editable = { false }
638+ />
639+ < TextInput
640+ placeholder = "editable text input using readOnly prop"
641+ style = { styles . default }
642+ readOnly = { false }
643+ />
644+ < TextInput
645+ placeholder = "uneditable text input using readOnly prop"
646+ style = { styles . default }
647+ readOnly
648+ />
649+ </ View >
650+ ) ;
651+ } ,
652+ } ,
624653 {
625654 title : 'TextInput Intrinsic Size' ,
626655 render : function ( ) : React . Node {
You can’t perform that action at this time.
0 commit comments