Skip to content

Commit

Permalink
KeyboardAwareScrollView: Remove redundant props
Browse files Browse the repository at this point in the history
flexGrow is not really appropriate, as the screen resizes, when keyboard is shown. Switch to fixed margin instead
  • Loading branch information
sashko9807 committed Aug 5, 2023
1 parent e379305 commit ddc6d61
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 89 deletions.
33 changes: 0 additions & 33 deletions src/components/KeyboardAwareScrollView.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/components/KeyboardAwareScrollViewWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import React from 'react'
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

const KeyboardAwareScrollViewWrapper = ({ children }) => {
return (
<KeyboardAwareScrollView style={{ flex: 1 }} keyboardShouldPersistTaps>
{children}
</KeyboardAwareScrollView>
)
}

export default KeyboardAwareScrollViewWrapper
1 change: 0 additions & 1 deletion src/screens/Authentication/ForgottenPasswordModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ControlledUserInput from '../../components/ControlledUserInput';
import { useForm } from 'react-hook-form';
import { useForgotPasswordMutation } from '../../api/userQueries';

import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import globalStyles from '../../globals/styles'
import { useApiResultReducer, ACTIONS } from '../../hooks/useApiResultReducer';

Expand Down
5 changes: 3 additions & 2 deletions src/screens/Authentication/RegisterModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { moderateScale } from '../../utils/scaling';

import { useRegisterMutation } from '../../api/userQueries';
import globalStyles from '../../globals/styles'
import KeyboardAwareScrollViewWrapper from '../../components/KeyboardAwareScrollView';
import KeyboardAwareScrollViewWrapper from '../../components/KeyboardAwareScrollViewWrapper';

const EMAIL_REGEXP =
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
Expand Down Expand Up @@ -152,6 +152,7 @@ const mainStyle = StyleSheet.create({
},
authContainer: {
flexGrow: 1,
marginTop: 20,
borderTopRightRadius: 25,
borderTopLeftRadius: 25,
backgroundColor: globalStyles.colorSet.SECONDARY,
Expand Down Expand Up @@ -184,7 +185,7 @@ const mainStyle = StyleSheet.create({
fontWeight: 'bold',
},
btnContainer: {
marginTop: moderateScale(120),
marginTop: moderateScale(160),
borderColor: 'red',
justifyContent: 'flex-end',
},
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Authentication/WelcomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ApiResultModal from '../../components/ApiResultModal'
import ActivityIndicatorComponent from '../../components/ActivityIndicatorComponent';
import { useApiResultReducer, ACTIONS } from '../../hooks/useApiResultReducer';
import { moderateScale } from '../../utils/scaling';
import KeyboardAwareScrollViewWrapper from '../../components/KeyboardAwareScrollView';
import KeyboardAwareScrollViewWrapper from '../../components/KeyboardAwareScrollViewWrapper';

const WelcomeScreen = ({ navigation }) => {
const [email, setEmail] = useState('');
Expand Down Expand Up @@ -179,7 +179,7 @@ const styles = StyleSheet.create({
btnContainer: {
justifyContent: 'space-between',
alignItems: 'center',
marginTop: moderateScale(10),
marginTop: moderateScale(100),
},
buttons: {
position: 'relative',
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Home/buildings/AddBuildingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useForm } from 'react-hook-form';
import globalStyles from '../../../globals/styles'

import { ACTIONS, useApiResultReducer } from '../../../hooks/useApiResultReducer';
import KeyboardAwareScrollViewWrapper from '../../../components/KeyboardAwareScrollView';
import KeyboardAwareScrollViewWrapper from '../../../components/KeyboardAwareScrollViewWrapper';

const AddBuildingScreen = ({ navigation }) => {
const [addBuilding, { isLoading, isSuccess, isError }] =
Expand Down
98 changes: 48 additions & 50 deletions src/screens/Settings/ChangePasswordScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { View, StyleSheet, ScrollView, KeyboardAvoidingView } from 'react-native';
import { View, StyleSheet } from 'react-native';
import { useState } from 'react';

import MainLayout from '../../container/MainLayout';
Expand All @@ -8,7 +8,7 @@ import ApiResultModal from '../../components/ApiResultModal';
import { InlineButton } from '../../components/Buttons';
import ControlledUserInput from '../../components/ControlledUserInput';

import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import KeyboardAwareScrollViewWrapper from '../../components/KeyboardAwareScrollViewWrapper'

import { useForm } from 'react-hook-form';

Expand Down Expand Up @@ -73,61 +73,59 @@ const ChangePasswordScreen = ({ navigation }) => {
/>
)}
<MainLayout>
<KeyboardAvoidingView behavior="padding" style={{ flex: 1 }} enabled keyboardVerticalOffset={80}>
<ScrollView keyboardShouldPersistTaps="handled">
<View style={styles.wrapper}>
<KeyboardAwareScrollViewWrapper>
<View style={styles.wrapper}>
<ControlledUserInput
title={'Current Password'}
name={'currPassword'}
control={control}
placeholder={'Current Password'}
rules={{
required: 'Current Password field is required',
}}
secureTextEntry
/>
<View style={styles.verticalSpacing}>
<ControlledUserInput
title={'Current Password'}
name={'currPassword'}
title={'New Password'}
name={'newPassword'}
control={control}
placeholder={'Current Password'}
placeholder={'New Password'}
rules={{
required: 'Current Password field is required',
required: 'New Password field is required',
minLength: {
value: 6,
message: 'Password must be at least 6 characters long',
},
validate: (value) =>
value === confirmNewPassword || "Passwords don't match",
}}
secureTextEntry
/>
<View style={styles.verticalSpacing}>
<ControlledUserInput
title={'New Password'}
name={'newPassword'}
control={control}
placeholder={'New Password'}
rules={{
required: 'New Password field is required',
minLength: {
value: 6,
message: 'Password must be at least 6 characters long',
},
validate: (value) =>
value === confirmNewPassword || "Passwords don't match",
}}
secureTextEntry
/>
</View>
<View style={styles.verticalSpacing}>
<ControlledUserInput
title={'Confirm New Password'}
name={'confirmNewPassword'}
control={control}
placeholder={'Confirm New Password'}
rules={{
required: 'Confirm New Password field is required',
validate: (value) =>
value === newPassword || "Passwords don't match",
}}
secureTextEntry
/>
</View>
<View style={styles.btnChangePassword}>
<InlineButton
title="Change Password"
onPress={handleSubmit(updateUserPassword)}
borderRadius={10}
/>
</View>
</View>
</ScrollView>
</KeyboardAvoidingView>
<View style={styles.verticalSpacing}>
<ControlledUserInput
title={'Confirm New Password'}
name={'confirmNewPassword'}
control={control}
placeholder={'Confirm New Password'}
rules={{
required: 'Confirm New Password field is required',
validate: (value) =>
value === newPassword || "Passwords don't match",
}}
secureTextEntry
/>
</View>
<View style={styles.btnChangePassword}>
<InlineButton
title="Change Password"
onPress={handleSubmit(updateUserPassword)}
borderRadius={10}
/>
</View>
</View>
</KeyboardAwareScrollViewWrapper>
</MainLayout>
</>
);
Expand Down

0 comments on commit ddc6d61

Please sign in to comment.