import React, { useEffect } from "react";
import { Platform, UIManager, Text } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { AppContainer } from "./Apps";
import { UpdateAsync } from "./UpdateAsync";
import { LogBox } from "react-native";
import { FavoriteStationProvider } from "./stateBox/useFavoriteStation";
import { CurrentTrainProvider } from "./stateBox/useCurrentTrain";
import { AreaInfoProvider } from "./stateBox/useAreaInfo";
import { BusAndTrainDataProvider } from "./stateBox/useBusAndTrainData";
import { AllTrainDiagramProvider } from "./stateBox/useAllTrainDiagram";
import { SheetProvider } from "react-native-actions-sheet";
import "./components/ActionSheetComponents/sheets";
import { TrainDelayDataProvider } from "./stateBox/useTrainDelayData";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { DeviceOrientationChangeProvider } from "./stateBox/useDeviceOrientationChange";
import { TrainMenuProvider } from "./stateBox/useTrainMenu";
import { buildProvidersTree } from "./lib/providerTreeProvider";
import { StationListProvider } from "./stateBox/useStationList";
import { NotificationProvider } from "./stateBox/useNotifications";
import { UserPositionProvider } from "./stateBox/useUserPosition";

LogBox.ignoreLogs([
  "ViewPropTypes will be removed",
  "ColorPropType will be removed",
]);

if (Platform.OS === "android") {
  if (UIManager.setLayoutAnimationEnabledExperimental) {
    UIManager.setLayoutAnimationEnabledExperimental(true);
  }
}

export default function App() {
  useEffect(() => {
    UpdateAsync();
  }, []);
  if (Text.defaultProps == null) {
    Text.defaultProps = {};
    Text.defaultProps.allowFontScaling = false;
  }
  const ProviderTree = buildProvidersTree([
    AllTrainDiagramProvider,
    NotificationProvider,
    UserPositionProvider,
    StationListProvider,
    FavoriteStationProvider,
    TrainDelayDataProvider,
    CurrentTrainProvider,
    AreaInfoProvider,
    BusAndTrainDataProvider,
    TrainMenuProvider,
    SheetProvider,
    AppContainer,
  ]);
  return (
    <DeviceOrientationChangeProvider>
      <SafeAreaProvider>
        <GestureHandlerRootView style={{ flex: 1 }}>
          <ProviderTree />
        </GestureHandlerRootView>
      </SafeAreaProvider>
    </DeviceOrientationChangeProvider>
  );
}
