import { TouchableOpacity, View, Image } from "react-native";
import React from "react";

// To enable this logic please add in the manifest of the plugin this code in style section:
/*
styles: {
  {
      group: true,
      label: "Close/Back button",
      tooltip:
        "These fields affect customization of the close/back button when full screen presented, otherwise button will be hidden",
      folded: true,
      fields: [
        {
          type: "switch",
          key: "close_button_hidden",
          label_tooltip: "Define if close/next button will be hidden",
          initial_value: true,
        },
        {
          type: "uploader",
          key: "close_button_image",
          label: "Close Button Image",
          label_tooltip: "Image for the close button of the screen.",
        },
        {
          type: "number_input",
          key: "close_button_top_offset",
          tooltip_text: "Set top offset of the close button",
          initial_value: 45,
        },
        {
          type: "select",
          key: "close_button_position",
          label: "Close Button Position",
          label_tooltip:
            "Determines the corner side of the screen where the button is placed.",
          options: [
            {
              text: "Left",
              value: "Left",
            },
            {
              text: "Right",
              value: "Right",
            },
          ],
          initial_value: "Right",
        },
      ],
    },
}
*/

const closeButtonStyle: any = {
  width: 50,
  height: 50,
  resizeMode: "contain",
};

type FloatingButtonProps = {
  onPress: () => void;
  buttonStyles: any;
  imageUrl: string;
  imageStyle?: any;
};

const FloatingButton = ({
  onPress,
  buttonStyles,
  imageUrl,
  imageStyle = closeButtonStyle,
}: FloatingButtonProps) => {
  return (
    <View style={buttonStyles}>
      <TouchableOpacity onPress={onPress}>
        <Image source={{ uri: imageUrl }} style={imageStyle} />
      </TouchableOpacity>
    </View>
  );
};

export default FloatingButton;
