import React, { MutableRefObject } from 'react';
import { Animated } from 'react-native';
import { FormHandles } from '@unform/core';
import { IFilterOptions, IViewList } from '../../../hooks/useViewList';
import { IPropsNavActions } from '../../NavActions';
import { IPropsTabs, ITabsRef } from '../../Tabs/Tabs.interface';
import { IPropsTagFilter, ITagFilterRef } from '../../TagsFilters/TagsFilters.interface';

export type IFilterComponent<T = any> = React.FunctionComponent<{
   handleFilters: (data: any) => void;
   filters: T;
   formRef: MutableRefObject<FormHandles>;
}>;

export interface IPageListingProps {
   viewList: IViewList;
   // Componentes
   FiltersContainerComponent?: React.FunctionComponent<IPageListingChildrenProps>;
   HeaderListingContainerComponent?: React.FunctionComponent<IPageListingChildrenProps>;
   TitleContainerComponent?: React.FunctionComponent<IPageListingChildrenProps>;
   FiltersComponent: IFilterComponent;
   renderResource: (resource: any, index: number) => JSX.Element;
   renderResourceSkeleton: (resource: any, index: number) => JSX.Element;
   //
   navActions?: IPropsNavActions;
   // Tabs
   tabs?: IPropsTabs;
   sortOptions?: {
      name: any;
      value: any;
   }[];
   tagsFilters?: Partial<IPropsTagFilter>;
   // Header
   title?: string;
   textResourceSingular?: string;
   textResourcePlural?: string;
   // Callback ao clicar no botão adicionar
   onClickHeaderBtn?: () => void;
   //
   showCountListing?: boolean;
}

export interface IPageListingChildrenProps extends IPageListingProps {
   // FiltersComponent: React.FunctionComponent<any>;
   tabsRef: React.MutableRefObject<ITabsRef>;
   tagsFiltersRef: React.MutableRefObject<ITagFilterRef>;
   formSortRef: React.MutableRefObject<FormHandles>;
   scrollListingRef: React.MutableRefObject<any>;
   scrollPosRef: React.MutableRefObject<number>;
   scrollCardHeightRef: React.MutableRefObject<number>;

   openFilters: () => void;
   closeFilters: () => void;
   setTagsFilterSize: any;
   filterMobileOpen: boolean;
   setFilterMobileOpen: (v: boolean) => void;
   animateScrollY: Animated.Value;
   animatedNavActions: Animated.Value;
   paddingScroll: number;
   navActionsSize: number;
}
