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

interface BackgroundProps extends ViewProps {}
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}>
      <KeyboardAvoidingView
        behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
        style={styles.container}>
        <TouchableWithoutFeedback accessible={false} onPress={Keyboard.dismiss}>
          <View style={[styles.container, styles.view]} {...props}>
            {props.children}
          </View>
        </TouchableWithoutFeedback>
      </KeyboardAvoidingView>
    </LinearGradient>
  );
};

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

export default Background;
