import * as React from "react";
import * as R from "ramda";
import { NativeRouter, useHistory, useLocation } from "react-router-native";
// @ts-ignore
import { createQuickBrickApp } from "@applicaster/quick-brick-core";
import * as Contexts from "@applicaster/zapp-react-native-ui-components/Contexts";
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
import { OfflineHandler } from "@applicaster/zapp-react-native-ui-components/Components/OfflineHandler";

import { InteractionManager } from "./InteractionManager";

import { Layout } from "./Layout";

type Props = ZappScreenProps & ZappRiver;

export const ZappApp: React.ComponentType<Props> = createQuickBrickApp({
  navigations: {
    Router: NativeRouter,
    useHistory,
    useLocation,
  },
  QuickBrickManager,
  Layout,
  OfflineHandler,
  InteractionManager, // mostly back button handle in Android
  ContextProviders: R.map(R.prop("withProvider"), R.values(Contexts)),
});
