11import React from 'react' ;
2- import { View , ScrollView , Dimensions , StyleSheet , Image , TextInput , Text } from 'react-native' ;
2+ import {
3+ SafeAreaView ,
4+ View ,
5+ ScrollView ,
6+ Dimensions ,
7+ StyleSheet ,
8+ Image ,
9+ TextInput ,
10+ Text ,
11+ KeyboardAvoidingView ,
12+ } from 'react-native' ;
313import {
414 NavigationProps ,
515 NavigationComponent ,
@@ -15,6 +25,7 @@ const KEYBOARD_LABEL = 'Keyboard Demo';
1525interface Props extends NavigationProps {
1626 title ?: string ;
1727 autoFocus ?: boolean ;
28+ stickyFooter ?: boolean ;
1829}
1930
2031export default class KeyboardScreen extends NavigationComponent < Props > {
@@ -34,6 +45,7 @@ export default class KeyboardScreen extends NavigationComponent<Props> {
3445 } ,
3546 } ;
3647 }
48+
3749 constructor ( props : Props ) {
3850 super ( props ) ;
3951 Navigation . events ( ) . bindComponent ( this ) ;
@@ -50,30 +62,41 @@ export default class KeyboardScreen extends NavigationComponent<Props> {
5062 }
5163
5264 render ( ) {
65+ const FooterRoot = this . props . stickyFooter === true ? KeyboardAvoidingView : View ;
5366 return (
54- < View style = { styles . root } >
67+ < SafeAreaView style = { styles . root } >
5568 < ScrollView >
5669 < Image style = { styles . image } source = { require ( '../../img/2048.jpeg' ) } />
5770 < View style = { { alignItems : 'center' } } >
5871 < Button
5972 style = { styles . button }
60- label = { 'Modal Keyboard Screen ' }
73+ label = { 'Modal screen ' }
6174 testID = { testIDs . MODAL_BTN }
6275 onPress = { async ( ) => {
6376 await this . openModalKeyboard ( undefined ) ;
6477 } }
6578 />
79+ < View style = { styles . row } >
80+ < Button
81+ style = { styles . button }
82+ label = { 'Push screen w/ focus' }
83+ testID = { testIDs . PUSH_FOCUSED_KEYBOARD_SCREEN }
84+ onPress = { async ( ) => {
85+ await this . openPushedKeyboard ( undefined , true ) ;
86+ } }
87+ />
88+ < Button
89+ style = { styles . button }
90+ label = { 'w/ sticky-footer' }
91+ testID = { testIDs . PUSH_KEYBOARD_SCREEN_STICKY_FOOTER }
92+ onPress = { async ( ) => {
93+ await this . openPushedKeyboard ( undefined , undefined , true ) ;
94+ } }
95+ />
96+ </ View >
6697 < Button
6798 style = { styles . button }
68- label = { 'Push Focused Keyboard Screen' }
69- testID = { testIDs . PUSH_FOCUSED_KEYBOARD_SCREEN }
70- onPress = { async ( ) => {
71- await this . openPushedKeyboard ( undefined , true ) ;
72- } }
73- />
74- < Button
75- style = { styles . button }
76- label = { 'Show Focused Keyboard Screen Modal' }
99+ label = { 'Modal screen w/ focus' }
77100 testID = { testIDs . MODAL_FOCUSED_KEYBOARD_SCREEN }
78101 onPress = { async ( ) => {
79102 await this . openModalKeyboard ( undefined , true ) ;
@@ -104,20 +127,21 @@ export default class KeyboardScreen extends NavigationComponent<Props> {
104127 />
105128 </ View >
106129 </ ScrollView >
107- < View style = { styles . footer } >
108- < Text style = { styles . input } > { KEYBOARD_LABEL } </ Text >
109- </ View >
110- </ View >
130+ < FooterRoot behavior = "height" style = { styles . footer } >
131+ < Text style = { styles . input } > { KEYBOARD_LABEL } </ Text >
132+ </ FooterRoot >
133+ </ SafeAreaView >
111134 ) ;
112135 }
113136
114- openPushedKeyboard = async ( text ?: string , autoFocus ?: boolean ) => {
137+ openPushedKeyboard = async ( text ?: string , autoFocus ?: boolean , stickyFooter ?: boolean ) => {
115138 await Navigation . push ( this . props . componentId , {
116139 component : {
117140 name : Screens . KeyboardScreen ,
118141 passProps : {
119142 title : text ,
120143 autoFocus,
144+ stickyFooter,
121145 } ,
122146 } ,
123147 } ) ;
@@ -169,4 +193,8 @@ const styles = StyleSheet.create({
169193 width : screenWidth ,
170194 resizeMode : 'cover' ,
171195 } ,
196+ row : {
197+ flexDirection : 'row' ,
198+ justifyContent : 'space-between' ,
199+ } ,
172200} ) ;
0 commit comments