import { ReactNode } from "react";
import { Portal, Snackbar, SnackbarProps } from "react-native-paper";

interface AppSnackbarProps extends SnackbarProps {
  children: ReactNode;
}

export const AppSnackbar = ({
  visible,
  onDismiss,
  action,
  wrapperStyle,
  duration,
  children,
}: AppSnackbarProps) => {
  return (
    <Portal>
      <Snackbar
        visible={visible}
        onDismiss={onDismiss}
        action={action}
        duration={duration}
        wrapperStyle={[{ zIndex: 1001 }, wrapperStyle]}
      >
        {children}
      </Snackbar>
    </Portal>
  );
};
