import React from 'react';
import { ViewStyle } from 'react-native';
import { ThemedView } from '@/components/ThemedView';

interface ListProps {
    data: any;
    renderItem: Function;
    viewStyle?: ViewStyle;
}

const CustomList: React.FC<ListProps> = ({ data, renderItem, viewStyle }) => {
    const renderList = () => {
        let list: any[] = [];

        for (let i = 0; i < data.length; i++) {
            const item = data[ i ];

            list[ i ] = renderItem( item, i );
        }

        return list;
    };

    return (
        <ThemedView style={viewStyle ? viewStyle : undefined}>
            {renderList()}
        </ThemedView>
    );
};

export default CustomList;