import React from 'react';

export const TabContext = React.createContext<{
  selectedTabKey: string;
} | null>(null);

export const ScreenContext = React.createContext<string | null>(null);

export const useIsFocused = () => {
  const context = React.useContext(TabContext);
  const key = React.useContext(ScreenContext);
  if (!context || !key) {
    return;
  }

  const isFocused = context.selectedTabKey === key;

  return isFocused;
};
