import React from 'react';
import LinearGradient from 'react-native-linear-gradient';
import {
  StyleSheet,
  TouchableWithoutFeedback,
  Keyboard,
  ViewProps,
  SafeAreaView,
} from 'react-native';

interface GradientBackgroundProps extends ViewProps {}
const GradientBackground: React.FC<GradientBackgroundProps> = (props) => {
  return (
    <LinearGradient
      locations={[0.89, 1]}
      colors={['transparent', 'rgba(0, 0, 0, 0.6)']}
      style={styles.container}>
      <TouchableWithoutFeedback accessible={false} onPress={Keyboard.dismiss}>
        <SafeAreaView {...props}>{props.children}</SafeAreaView>
      </TouchableWithoutFeedback>
    </LinearGradient>
  );
};

const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'transparent',
    flex: 1,
  },
});

export default GradientBackground;
