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

export type HandleProps = {
  enabled: boolean;
  color: string;
  focusedColor: string;
};

const styles = StyleSheet.create({
  container: {
    width: "100%",
    height: 44,
    justifyContent: "flex-end",
    alignItems: "center",
  },
  handle: {
    width: 40,
    height: 5,
    marginBottom: 8,
    opacity: 0.8,
    borderRadius: 100,
  },
});

export function Handle(props: HandleProps & { focused: boolean }) {
  const { enabled, focused, focusedColor, color } = props;

  if (!enabled) {
    return null;
  }

  return (
    <View style={styles.container}>
      <View
        style={[
          styles.handle,
          { backgroundColor: focused ? focusedColor : color },
        ]}
      />
    </View>
  );
}
