[FIX] Keyboard Avoiding View

This commit is contained in:
Andi Firwansyah 2022-12-04 15:53:50 +07:00
parent 6777de5dd0
commit a5a3a145dd
4 changed files with 131 additions and 112 deletions

View File

@ -6,6 +6,8 @@ import {
TextInput, TextInput,
ActivityIndicator, ActivityIndicator,
Image, Image,
KeyboardAvoidingView,
Platform,
} from 'react-native'; } from 'react-native';
import { import {
Container, Container,
@ -57,6 +59,9 @@ const Login = ({route, navigation}) => {
style={styles.translateButtonImage} style={styles.translateButtonImage}
/> />
</TouchableOpacity> </TouchableOpacity>
<KeyboardAvoidingView
style={{flex: 1}}
behavior={Platform.OS === 'ios' ? 'height' : undefined}>
<View style={styles.boardingSection}> <View style={styles.boardingSection}>
<Image <Image
source={require('assets/images/chef-pana.png')} source={require('assets/images/chef-pana.png')}
@ -73,7 +78,8 @@ const Login = ({route, navigation}) => {
<View style={styles.wrapper}> <View style={styles.wrapper}>
<View style={styles.formSection}> <View style={styles.formSection}>
<Text style={styles.formLabel}> <Text style={styles.formLabel}>
{t('phone_input')} <Text style={{color: Colors.PRIMARY}}>*</Text> {t('phone_input')}{' '}
<Text style={{color: Colors.PRIMARY}}>*</Text>
</Text> </Text>
<View style={styles.postSection}> <View style={styles.postSection}>
<View style={styles.numberIdSection}> <View style={styles.numberIdSection}>
@ -106,7 +112,7 @@ const Login = ({route, navigation}) => {
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={styles.buttonSignInSection(keyboardHeight)}> <View style={styles.buttonSignInSection}>
<Button <Button
title={t('login')} title={t('login')}
onPress={() => alert('login')} onPress={() => alert('login')}
@ -122,6 +128,7 @@ const Login = ({route, navigation}) => {
/> />
</View> </View>
</View> </View>
</KeyboardAvoidingView>
</View> </View>
<ModalOTP <ModalOTP
isVisible={modalOTP.visible} isVisible={modalOTP.visible}

View File

@ -112,9 +112,9 @@ export default StyleSheet.create({
}, },
// button section // button section
buttonSignInSection: keyboardHeight => ({ buttonSignInSection: {
marginBottom: Platform.OS === 'ios' ? keyboardHeight : width * 0.05, // marginBottom: Platform.OS === 'ios' ? keyboardHeight : width * 0.05,
}), },
textOr: { textOr: {
fontFamily: FONTS.poppins[500], fontFamily: FONTS.poppins[500],
fontSize: RFValue(12), fontSize: RFValue(12),

View File

@ -1,5 +1,12 @@
import React, {useState} from 'react'; import React, {useState} from 'react';
import {View, ScrollView, Text, TouchableOpacity} from 'react-native'; import {
View,
ScrollView,
Text,
TouchableOpacity,
KeyboardAvoidingView,
Platform,
} from 'react-native';
import {Container, Header, Button, Icon, Input} from 'components'; import {Container, Header, Button, Icon, Input} from 'components';
import {Colors} from 'global-styles'; import {Colors} from 'global-styles';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';
@ -19,6 +26,10 @@ const AddProduct = ({route, navigation}) => {
/> />
<View style={styles.container}> <View style={styles.container}>
<ScrollView> <ScrollView>
<KeyboardAvoidingView
style={{flex: 1}}
keyboardVerticalOffset={100}
behavior={Platform.OS === 'ios' ? 'position' : null}>
<View style={styles.spacing} /> <View style={styles.spacing} />
<View style={styles.imageUploadSection}> <View style={styles.imageUploadSection}>
<Text style={styles.imageUploadLabel}> <Text style={styles.imageUploadLabel}>
@ -65,6 +76,7 @@ const AddProduct = ({route, navigation}) => {
label={t('price_text')} label={t('price_text')}
placeholder="0" placeholder="0"
/> />
</KeyboardAvoidingView>
</ScrollView> </ScrollView>
<Button title="Simpan" onPress={() => navigation.goBack()} /> <Button title="Simpan" onPress={() => navigation.goBack()} />
</View> </View>

View File

@ -1,5 +1,5 @@
import React, {useState} from 'react'; import React, {useState} from 'react';
import {View, ScrollView, TextInput} from 'react-native'; import {View, ScrollView, KeyboardAvoidingView, Platform} from 'react-native';
import {Container, Header, Note, Button, Input} from 'components'; import {Container, Header, Note, Button, Input} from 'components';
import {Colors} from 'global-styles'; import {Colors} from 'global-styles';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';