import {
  ViewStyle,
  StyleProp,
  Animated,
  ScrollView,
  TextStyle,
} from 'react-native';
import {
  NavigationState,
  Route,
  SceneRendererProps,
  TabBarProps as RNTVTabBarProps,
} from 'react-native-tab-view';
import {TextVariant} from '@components/Text';
import {ChipSize} from '@components/_HuGo/Chip/interfaces';
import {ScrollEvent} from '@interfaces/generic';

export interface TabViewRoute {
  key: string;
  title: string;
  badge?: number;
  module?: string;
}

export type TabViewRenderScene<T extends TabViewRoute> = SceneRendererProps & {
  route: T;
};

export interface TabBarProps<T extends TabViewRoute>
  extends SceneRendererProps {
  navigationState: NavigationState<T>;
  style?: StyleProp<ViewStyle>;
  handleTabPress?: (key: string, selectedTab: string, module?: string) => void;
  size?: ChipSize;
}

export type TVTabBarProps = SceneRendererProps & {
  navigationState: NavigationState<Route>;
};

export type RenderSceneProps = TabViewRenderScene<TabViewRoute>;

export enum TabBarVariant {
  pills = 'pills',
  tabs = 'tabs',
}

export type TabBarVariantType = keyof typeof TabBarVariant;

export interface TabBarItemElement {
  container?: StyleProp<ViewStyle>;
  textVariant?: TextVariant;
  text?: StyleProp<TextStyle>;
}
export interface TabViewRef {
  currentIndex: number;
  goToIndex: (index: number) => void;
}

export type RNTabBarProps = RNTVTabBarProps<Route>;

export interface ScrollableElement {
  getScrollResponder: () => ScrollView;
}

export type Mapping = {[key: string]: Mapping} | Animated.Value;

export interface CollapsibleTabProps {
  scrollY?: Animated.Value;
  collapsibleHeaderListener: (event: ScrollEvent) => void;
  minimumScrollDistance: number;
  animatedArgumentMapping: Array<Nullable<Mapping>>;
  isSelected?: boolean;
  positionY?: number;
  syncScrollOffset: () => void;
}
