"use strict";

/** @format */

import React, { useEffect, useRef } from 'react';
import { Animated, Easing, View, StyleSheet } from 'react-native';
import { jsx as _jsx } from "react/jsx-runtime";
export default function Loader({
  size = 32,
  color = '#3498db'
}) {
  const spinValue = useRef(new Animated.Value(0)).current;
  useEffect(() => {
    const spinAnimation = Animated.loop(Animated.timing(spinValue, {
      toValue: 1,
      duration: 1000,
      easing: Easing.linear,
      useNativeDriver: true
    }));
    spinAnimation.start();
    return () => {
      spinAnimation.stop();
    };
  }, [spinValue]);
  const spin = spinValue.interpolate({
    inputRange: [0, 1],
    outputRange: ['0deg', '360deg']
  });
  const borderWidth = size ? size / 8 : 4;
  return /*#__PURE__*/_jsx(View, {
    style: styles.container,
    children: /*#__PURE__*/_jsx(Animated.View, {
      style: [{
        width: size,
        height: size,
        borderRadius: size / 2,
        borderWidth: borderWidth,
        borderTopColor: color,
        borderRightColor: 'transparent',
        borderBottomColor: 'transparent',
        borderLeftColor: 'transparent',
        transform: [{
          rotate: spin
        }]
      }]
    })
  });
}
const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
    padding: 8
  }
});
//# sourceMappingURL=Loader.js.map