Add tag datatable
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Dimensions, ScaledSize } from 'react-native';
|
||||
@@ -18,6 +19,7 @@ interface ScaleFunctions {
|
||||
|
||||
interface DimensionsContext {
|
||||
orientation: 'portrait' | 'landscape';
|
||||
dimensions: ScaledSize;
|
||||
responsive: ScaleFunctions;
|
||||
static: ScaleFunctions;
|
||||
}
|
||||
@@ -42,15 +44,16 @@ const DimensionsProvider = ({ children }: { children: ReactNode }) => {
|
||||
const orientation =
|
||||
dimensions.width > dimensions.height ? 'landscape' : 'portrait';
|
||||
|
||||
const [initialDimensions, setInitialDimensions] = useState(dimensions);
|
||||
const [initialOrientation] = useState(orientation);
|
||||
|
||||
if (initialOrientation === 'landscape') {
|
||||
setInitialDimensions({
|
||||
width: initialDimensions.height,
|
||||
height: initialDimensions.width,
|
||||
} as ScaledSize);
|
||||
}
|
||||
const initialDimensions = useMemo(() => {
|
||||
if (orientation === 'landscape') {
|
||||
return {
|
||||
width: dimensions.height,
|
||||
height: dimensions.width,
|
||||
} as ScaledSize;
|
||||
}
|
||||
return dimensions;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const responsiveScale = createScaleFunctions(dimensions);
|
||||
const staticScale = createScaleFunctions(initialDimensions);
|
||||
@@ -71,6 +74,7 @@ const DimensionsProvider = ({ children }: { children: ReactNode }) => {
|
||||
<DimensionsContext.Provider
|
||||
value={{
|
||||
orientation,
|
||||
dimensions,
|
||||
responsive: responsiveScale,
|
||||
static: staticScale,
|
||||
}}>
|
||||
|
Reference in New Issue
Block a user