import * as React from "react";
import { DimensionsProvider } from "./DimensionsProvider";
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";

export function withDimensionsProvider(Component) {
  return function DimensionsProviderWrapper(props) {
    const dimensions = useDimensions("window", { deviceInfo: true });
    const deviceInfo = dimensions?.deviceInfo;

    return (
      <DimensionsProvider>
        <Component {...props} deviceInfo={deviceInfo} />
      </DimensionsProvider>
    );
  };
}
