import React from 'react';
import LinearGradient from 'react-native-linear-gradient';
import {
  StyleSheet,
  TouchableWithoutFeedback,
  Keyboard,
  ViewProps,
  View,
} from 'react-native';
import {CenteredView} from '../common';

interface BackgroundProps extends ViewProps {
  centered?: boolean;
}
const Background: React.FC<BackgroundProps> = (props) => {
  return (
    <LinearGradient
      colors={['#9F00FF', '#27EAE9']}
      useAngle={true}
      angle={154.72}
      angleCenter={{x: 0.5, y: 0.5}}
      style={styles.container}>
      <TouchableWithoutFeedback accessible={false} onPress={Keyboard.dismiss}>
        {props.centered ? (
          <CenteredView {...props}>{props.children}</CenteredView>
        ) : (
          <View {...props}>{props.children}</View>
        )}
      </TouchableWithoutFeedback>
    </LinearGradient>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default Background;
