1
1
import React from 'react' ;
2
- import { ScrollView , View } from 'react-native' ;
2
+ import { View , TouchableWithoutFeedback , Keyboard } from 'react-native' ;
3
3
import PropTypes from 'prop-types' ;
4
4
import { withSafeAreaInsets } from 'react-native-safe-area-context' ;
5
5
import styles from '../../../styles/styles' ;
6
6
import variables from '../../../styles/variables' ;
7
- import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView' ;
8
7
import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo' ;
9
8
import Text from '../../../components/Text' ;
10
9
import TermsAndLicenses from '../TermsAndLicenses' ;
11
10
import withLocalize , { withLocalizePropTypes } from '../../../components/withLocalize' ;
12
11
import SignInPageForm from '../../../components/SignInPageForm' ;
13
12
import compose from '../../../libs/compose' ;
14
- import scrollViewContentContainerStyles from './signInPageStyles' ;
15
13
import withKeyboardState from '../../../components/withKeyboardState' ;
16
14
import withWindowDimensions , { windowDimensionsPropTypes } from '../../../components/withWindowDimensions' ;
17
- import * as StyleUtils from '../../../styles/StyleUtils' ;
18
15
19
16
const propTypes = {
20
17
/** The children to show inside the layout */
@@ -31,71 +28,58 @@ const propTypes = {
31
28
...windowDimensionsPropTypes ,
32
29
} ;
33
30
34
- const SignInPageContent = props => (
35
- < ScrollView
36
- keyboardShouldPersistTaps = "handled"
37
- showsVerticalScrollIndicator = { false }
38
- style = { [
39
- styles . h100 ,
40
- ! props . isSmallScreenWidth && styles . alignSelfCenter ,
41
- ! props . isSmallScreenWidth && styles . signInPageWideLeftContainer ,
42
- ] }
43
- contentContainerStyle = { [
44
- scrollViewContentContainerStyles ,
45
- styles . alignItemsCenter ,
46
- ! props . isSmallScreenWidth && styles . ph6 ,
47
- ] }
48
- >
49
- < View style = { [ styles . flex1 , styles . flexRow ] } >
50
- < View style = { [
51
- styles . flex1 ,
52
- styles . signInPageNarrowContentContainer ,
53
- ] }
54
- >
55
- < SignInPageForm style = { [
31
+ const SignInPageContent = ( props ) => {
32
+ const dismissKeyboardWhenTappedOutsideOfInput = ( ) => {
33
+ // This prop comes from withKeyboardState
34
+ if ( ! props . isShown ) {
35
+ return ;
36
+ }
37
+ Keyboard . dismiss ( ) ;
38
+ } ;
39
+
40
+ return (
41
+ < TouchableWithoutFeedback onPress = { dismissKeyboardWhenTappedOutsideOfInput } >
42
+ < View
43
+ style = { [
56
44
styles . flex1 ,
57
- styles . alignSelfStretch ,
58
- props . isSmallScreenWidth ? styles . ph5 : styles . ph4 ,
45
+ styles . signInPageLeftContainer ,
46
+ ! props . isSmallScreenWidth && styles . signInPageLeftContainerWide ,
59
47
] }
60
- >
61
- < KeyboardAvoidingView
62
- behavior = "position"
63
- style = { [
64
- StyleUtils . getModalPaddingStyles ( {
65
- shouldAddBottomSafeAreaPadding : true ,
66
- modalContainerStylePaddingBottom : 20 ,
67
- safeAreaPaddingBottom : props . insets . bottom ,
68
- } ) ,
69
- props . isSmallScreenWidth ? styles . signInPageNarrowContentMargin : { } ,
70
- ! props . isMediumScreenWidth || ( props . isMediumScreenWidth && props . windowHeight < variables . minHeightToShowGraphics ) ? styles . signInPageWideLeftContentMargin : { } ,
71
- styles . mb3 ,
72
- ] }
73
- >
74
- < View style = { [
75
- styles . componentHeightLarge ,
76
- ...( props . isSmallScreenWidth ? [ styles . mb2 ] : [ styles . mt6 , styles . mb5 ] ) ,
77
- ] }
78
- >
79
- < ExpensifyCashLogo
80
- width = { variables . componentSizeLarge }
81
- height = { variables . componentSizeLarge }
82
- />
83
- </ View >
84
- { props . shouldShowWelcomeText && (
85
- < Text style = { [ styles . mv5 , styles . textLabel , styles . h3 ] } >
86
- { props . welcomeText }
87
- </ Text >
88
- ) }
89
- { props . children }
90
- </ KeyboardAvoidingView >
91
- </ SignInPageForm >
92
- < View style = { [ styles . mb5 , styles . alignSelfCenter , styles . ph5 ] } >
93
- < TermsAndLicenses />
48
+ >
49
+ < View style = { [ styles . flex1 , styles . alignSelfCenter , styles . signInPageWelcomeFormContainer ] } >
50
+ { /* This empty view creates margin on the top of the sign in form which will shrink and grow depending on if the keyboard is open or not */ }
51
+ < View style = { [ styles . flexGrow1 , styles . signInPageContentTopSpacer ] } />
52
+
53
+ < View style = { [ styles . flexGrow2 ] } >
54
+ < SignInPageForm style = { [ styles . alignSelfStretch ] } >
55
+ < View style = { [
56
+ styles . componentHeightLarge ,
57
+ ...( props . isSmallScreenWidth ? [ styles . mb2 ] : [ styles . mt6 , styles . mb5 ] ) ,
58
+ ] }
59
+ >
60
+ < ExpensifyCashLogo
61
+ width = { variables . componentSizeLarge }
62
+ height = { variables . componentSizeLarge }
63
+ />
64
+ </ View >
65
+ { props . shouldShowWelcomeText && (
66
+ < View style = { [ styles . signInPageWelcomeTextContainer ] } >
67
+ < Text style = { [ styles . mv5 , styles . textLabel , styles . h3 ] } >
68
+ { props . welcomeText }
69
+ </ Text >
70
+ </ View >
71
+ ) }
72
+ { props . children }
73
+ </ SignInPageForm >
74
+ </ View >
75
+ < View style = { [ styles . mv5 ] } >
76
+ < TermsAndLicenses />
77
+ </ View >
94
78
</ View >
95
79
</ View >
96
- </ View >
97
- </ ScrollView >
98
- ) ;
80
+ </ TouchableWithoutFeedback >
81
+ ) ;
82
+ } ;
99
83
100
84
SignInPageContent . propTypes = propTypes ;
101
85
SignInPageContent . displayName = 'SignInPageContent' ;
0 commit comments