@eslam-elmeniawy/react-native-common-components
Version:
Common `ReactNative` components packed in library for usage in projects.
74 lines • 3.5 kB
TypeScript
import type { BaseDimensions } from './ResponsiveDimensions.types';
declare class ResponsiveDimensions {
private static _baseWidth;
private static _baseHeight;
/**
* Sets the base dimensions for scaling calculations.
* This is the screen size on which the design is based.
*
* @param width - The base width to set. If not provided, the existing base width remains unchanged.
* @param height - The base height to set. If not provided, the existing base height remains unchanged.
*/
static setBaseDimensions({ width, height }: BaseDimensions): void;
static get windowWidth(): any;
static get windowHeight(): any;
/**
* Scales a given size based on the current window width relative to a predefined base width.
*
* @param size - The size to be scaled.
* @returns The scaled size adjusted for the current window width.
*/
static scale(size: number): number;
/**
* Scales a given size based on the current window height relative to a predefined base height.
*
* @param size - The size to be scaled.
* @returns The scaled size adjusted for the current window height.
*/
static verticalScale(size: number): number;
/**
* Applies a moderate scaling to a given size, blending the original size
* with a scaled size based on the current window width. The blend is
* controlled by a factor, allowing for fine-tuning of the scaling effect.
*
* @param size - The original size to be scaled.
* @param factor - The factor to adjust the scaling effect, defaulting to 0.5.
* @returns The moderately scaled size.
*/
static moderateScale(size: number, factor?: number): number;
/**
* Applies a moderate scaling to a given size, blending the original size
* with a scaled size based on the current window height. The blend is
* controlled by a factor, allowing for fine-tuning of the scaling effect.
*
* @param size - The original size to be scaled.
* @param factor - The factor to adjust the scaling effect, defaulting to 0.5.
* @returns The moderately scaled size.
*/
static moderateVerticalScale(size: number, factor?: number): number;
static readonly s: typeof ResponsiveDimensions.scale;
static readonly vs: typeof ResponsiveDimensions.verticalScale;
static readonly ms: typeof ResponsiveDimensions.moderateScale;
static readonly mvs: typeof ResponsiveDimensions.moderateVerticalScale;
/**
* Calculates the width as a percentage of the current window width.
*
* @param percent - The percentage of the window width to calculate. Must be between 0 and 100.
* @returns The calculated width in pixels.
* @throws Error if the percent is less than 0 or greater than 100.
*/
static percentWidth(percent: number): number;
/**
* Calculates the height as a percentage of the current window height.
*
* @param percent - The percentage of the window height to calculate. Must be between 0 and 100.
* @returns The calculated height in pixels.
* @throws Error if the percent is less than 0 or greater than 100.
*/
static percentHeight(percent: number): number;
static readonly pw: typeof ResponsiveDimensions.percentWidth;
static readonly ph: typeof ResponsiveDimensions.percentHeight;
}
export { ResponsiveDimensions };
export default ResponsiveDimensions;
//# sourceMappingURL=ResponsiveDimensions.d.ts.map