import { NativeBaseProvider as BaseProvider, NativeBaseProviderProps } from "native-base"; import React, { ReactElement } from "react"; import { Helmet } from "react-helmet"; // Polyfills required for react-native and lingui import "@formatjs/intl-locale/polyfill"; import "@formatjs/intl-pluralrules/polyfill"; import { chain, keys, mapValues, omit, pick, toLower } from "lodash"; import { fontConfig, FontID, getFamiliesUrl } from "./utils/fonts"; type ILoadFonts = { [fontId in FontID]?: boolean; }; const FAMILIES = chain(fontConfig) .mapValues(getFamiliesUrl) .mapKeys((_, key) => toLower(key) as FontID) .value(); const FAMILIES_AVAILABLE = keys(FAMILIES); const DEFAULT_FAMILIES = mapValues(FAMILIES, () => true); export const NativeBaseProvider = ({ children, ...props }: NativeBaseProviderProps & ILoadFonts): ReactElement => { const rest = omit(props, FAMILIES_AVAILABLE); const loadFonts = chain(DEFAULT_FAMILIES).clone().assign(pick(props, FAMILIES_AVAILABLE)).pickBy().keys().value(); return ( {/* @ts-ignore - Helmet is valid in web environment */} {loadFonts.length && [ , ]} {loadFonts.map((fontID, index) => ( ))} {children} ); };