/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @generated SignedSource<<7471aa3da6bb64a8be4de0a5dd5bec8a>> * * This file was translated from Flow by scripts/js-api/build-types/index.js. * Original file: packages/react-native/Libraries/Utilities/Dimensions.js */ import { type EventSubscription } from "../vendor/emitter/EventEmitter"; import { type DimensionsPayload, type DisplayMetrics, type DisplayMetricsAndroid } from "./NativeDeviceInfo"; export type { DimensionsPayload, DisplayMetrics, DisplayMetricsAndroid }; /** @deprecated Use DisplayMetrics */ export type ScaledSize = DisplayMetrics; /** * Provides the application window's width and height. Prefer * `useWindowDimensions` in React components. * * @see https://reactnative.dev/docs/dimensions */ declare class Dimensions { /** * Returns the current dimensions for `'window'` or `'screen'`. On Android, * `'window'` dimensions exclude the status bar and navigation bar. * * NOTE: `useWindowDimensions` is the preferred API for React components. * * Although dimensions are available immediately, they may change (e.g. due to * device rotation) so any rendering logic or styles that depend on these * constants should try to call this function on every render, rather than * caching the value. * * Example: `const {height, width} = Dimensions.get('window');` * * @param {string} dim Name of dimension as defined when calling `set`. * @returns {DisplayMetrics? | DisplayMetricsAndroid?} Value for the dimension. */ static get(dim: string): DisplayMetrics | DisplayMetricsAndroid; /** * This should only be called from native code by sending the * didUpdateDimensions event. * * @param {DimensionsPayload} dims Simple string-keyed object of dimensions to set */ static set(dims: Readonly): void; /** * Add an event handler. Supported events: * * - `change`: Fires when a property within the `Dimensions` object changes, * such as on device rotation or foldable device state changes. The argument * to the event handler is a `DimensionsPayload` object with `window` and * `screen` properties whose values are the same as the return values of * `Dimensions.get('window')` and `Dimensions.get('screen')`, respectively. */ static addEventListener(type: "change", handler: Function): EventSubscription; } export default Dimensions;