import React from "react";
import { useTranslation } from "react-i18next";
import { StyleSheet, Text, View } from "react-native";
import { Checkbox } from "react-native-paper";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { toggleDeleteAfterUpload } from "../../redux/app/app.actions";
import { selectDeleteAfterUpload } from "../../redux/app/app.selectors";

const mapStateToProps = createStructuredSelector({
  deleteAfterUpload: selectDeleteAfterUpload,
});

const mapDispatchToProps = (dispatch) => ({
  toggleDeleteAfterUpload: () => dispatch(toggleDeleteAfterUpload()),
});

export function UploadDeleteSwitch({
  deleteAfterUpload,
  toggleDeleteAfterUpload,
}) {
  const { t } = useTranslation();
  return (
    <View style={styles.container}>
      <Text style={styles.text}>
        {t("mediabrowser.labels.deleteafterupload")}
      </Text>
      <Checkbox
        // trackColor={{ false: '#767577', true: '#81b0ff' }}
        // thumbColor={deleteAfterUpload ? 'tomato' : '#f4f3f4'}
        // ios_backgroundColor='#3e3e3e'
        onPress={() => {
          toggleDeleteAfterUpload();
        }}
        status={deleteAfterUpload ? "checked" : "unchecked"}
      />
    </View>
  );
}
const styles = StyleSheet.create({
  container: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    margin: 10,
  },

  text: {
    flex: 1,
  },
});
export default connect(mapStateToProps, mapDispatchToProps)(UploadDeleteSwitch);
