-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#149): offset not removed when interacting with iOS password inputs
- Loading branch information
1 parent
31bc3c8
commit 0875024
Showing
6 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useFocusEffect } from '@react-navigation/native'; | ||
import * as React from 'react'; | ||
import { Image, ScrollView, StyleSheet, View } from 'react-native'; | ||
import { AvoidSoftInput } from 'react-native-avoid-softinput'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
import Button from '../components/Button'; | ||
import SingleInput from '../components/SingleInput'; | ||
import { styles as commonStyles } from '../consts/styles'; | ||
|
||
const icon = require('../../assets/AppIconTransparent.png'); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
const NOOP = () => {}; | ||
|
||
export const PasswordFormExample: React.FC = () => { | ||
const onFocusEffect = React.useCallback(() => { | ||
AvoidSoftInput.setShouldMimicIOSBehavior(true); | ||
AvoidSoftInput.setEnabled(true); | ||
return () => { | ||
AvoidSoftInput.setEnabled(false); | ||
AvoidSoftInput.setShouldMimicIOSBehavior(false); | ||
}; | ||
}, []); | ||
|
||
useFocusEffect(onFocusEffect); | ||
|
||
return <SafeAreaView edges={[ 'bottom', 'left', 'right' ]} style={commonStyles.screenContainer}> | ||
<ScrollView | ||
bounces={false} | ||
contentContainerStyle={commonStyles.scrollContainer} | ||
contentInsetAdjustmentBehavior="always" | ||
overScrollMode="always" | ||
showsVerticalScrollIndicator={true} | ||
style={commonStyles.stretch}> | ||
<View style={styles.logoContainer}> | ||
<Image | ||
resizeMode="contain" | ||
source={icon} | ||
style={styles.logo} | ||
/> | ||
</View> | ||
<View style={styles.formContainer}> | ||
<SingleInput placeholder="Username input" /> | ||
<SingleInput textContentType="password" placeholder="Password input" secureTextEntry /> | ||
</View> | ||
<View style={styles.submitButtonContainer}> | ||
<Button | ||
onPress={NOOP} | ||
title="Submit" | ||
/> | ||
</View> | ||
</ScrollView> | ||
</SafeAreaView>; | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
formContainer: { | ||
alignItems: 'center', | ||
alignSelf: 'stretch', | ||
justifyContent: 'center', | ||
paddingHorizontal: 10, | ||
}, | ||
logo: { | ||
height: 200, | ||
width: 200, | ||
}, | ||
logoContainer: { | ||
alignItems: 'center', | ||
alignSelf: 'stretch', | ||
flex: 1, | ||
justifyContent: 'center', | ||
paddingVertical: 100, | ||
}, | ||
submitButtonContainer: { | ||
alignItems: 'center', | ||
alignSelf: 'stretch', | ||
justifyContent: 'center', | ||
marginTop: 100, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters