import React, {useEffect} from 'react'; import {View, StyleSheet, ViewProps, Keyboard} from 'react-native'; import * as Animatable from 'react-native-animatable'; interface RegistrationWizardProps extends ViewProps { step: 'one' | 'two' | 'three' | 'four' | 'five' | 'six'; } const RegistrationWizard = (props: RegistrationWizardProps) => { const stepStyle = styles.step; const stepActiveStyle = [styles.step, styles.stepActive]; // detects visibility of keyboard to display or hide wizard const [keyboardVisible, setKeyboardVisible] = React.useState(false); useEffect(() => { const showKeyboard = () => setKeyboardVisible(true); Keyboard.addListener('keyboardWillShow', showKeyboard); return () => Keyboard.removeListener('keyboardWillShow', showKeyboard); }, []); useEffect(() => { const hideKeyboard = () => setKeyboardVisible(false); Keyboard.addListener('keyboardWillHide', hideKeyboard); return () => Keyboard.removeListener('keyboardWillHide', hideKeyboard); }, []); return ( {!keyboardVisible && ( )} {keyboardVisible && ( )} ); }; const styles = StyleSheet.create({ container: { flexDirection: 'row', justifyContent: 'center', alignItems: 'center', }, step: { height: 18, width: 18, borderRadius: 9, borderWidth: 2, borderColor: '#e1f0ff', }, stepActive: { backgroundColor: '#e1f0ff', }, progress: { width: '13%', height: 2, backgroundColor: '#e1f0ff', }, }); export default RegistrationWizard;