import React from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import { useTheme } from 'react-native-paper';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: '5%',
  },
  centered: {
    justifyContent: 'center',
    alignItems: 'center',
  },
});

const PaddedView = ({
  children,
  style,
  centered,
}: {
  children: React.ReactNode;
  style?: StyleProp<ViewStyle>;
  centered?: boolean;
  }): React.JSX.Element => {
  const { colors } = useTheme();

  return (
    <View style={[styles.container, centered && styles.centered, { backgroundColor: colors.background }, style]}>
      {children}
    </View>
  );
};

export default PaddedView;
