1 | /**
|
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | * @format
|
8 | */
|
9 |
|
10 | import type * as React from 'react';
|
11 | import {
|
12 | MeasureInWindowOnSuccessCallback,
|
13 | MeasureLayoutOnSuccessCallback,
|
14 | MeasureOnSuccessCallback,
|
15 | } from '../../types/public/ReactNativeTypes';
|
16 |
|
17 | export interface UIManagerStatic {
|
18 | /**
|
19 | * Determines the location on screen, width, and height of the given view and
|
20 | * returns the values via an async callback. If successful, the callback will
|
21 | * be called with the following arguments:
|
22 | *
|
23 | * - x
|
24 | * - y
|
25 | * - width
|
26 | * - height
|
27 | * - pageX
|
28 | * - pageY
|
29 | *
|
30 | * Note that these measurements are not available until after the rendering
|
31 | * has been completed in native. If you need the measurements as soon as
|
32 | * possible, consider using the [`onLayout`
|
33 | * prop](docs/view.html#onlayout) instead.
|
34 | *
|
35 | * @deprecated Use `ref.measure` instead.
|
36 | */
|
37 | measure(node: number, callback: MeasureOnSuccessCallback): void;
|
38 |
|
39 | /**
|
40 | * Determines the location of the given view in the window and returns the
|
41 | * values via an async callback. If the React root view is embedded in
|
42 | * another native view, this will give you the absolute coordinates. If
|
43 | * successful, the callback will be called with the following
|
44 | * arguments:
|
45 | *
|
46 | * - x
|
47 | * - y
|
48 | * - width
|
49 | * - height
|
50 | *
|
51 | * Note that these measurements are not available until after the rendering
|
52 | * has been completed in native.
|
53 | *
|
54 | * @deprecated Use `ref.measureInWindow` instead.
|
55 | */
|
56 | measureInWindow(
|
57 | node: number,
|
58 | callback: MeasureInWindowOnSuccessCallback,
|
59 | ): void;
|
60 |
|
61 | /**
|
62 | * Like [`measure()`](#measure), but measures the view relative an ancestor,
|
63 | * specified as `relativeToNativeNode`. This means that the returned x, y
|
64 | * are relative to the origin x, y of the ancestor view.
|
65 | *
|
66 | * As always, to obtain a native node handle for a component, you can use
|
67 | * `React.findNodeHandle(component)`.
|
68 | *
|
69 | * @deprecated Use `ref.measureLayout` instead.
|
70 | */
|
71 | measureLayout(
|
72 | node: number,
|
73 | relativeToNativeNode: number,
|
74 | onFail: () => void /* currently unused */,
|
75 | onSuccess: MeasureLayoutOnSuccessCallback,
|
76 | ): void;
|
77 |
|
78 | /**
|
79 | * Automatically animates views to their new positions when the
|
80 | * next layout happens.
|
81 | *
|
82 | * A common way to use this API is to call it before calling `setState`.
|
83 | *
|
84 | * Note that in order to get this to work on **Android** you need to set the following flags via `UIManager`:
|
85 | *
|
86 | * UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
|
87 | */
|
88 | setLayoutAnimationEnabledExperimental?:
|
89 | | ((value: boolean) => void)
|
90 | | undefined;
|
91 |
|
92 | getViewManagerConfig: (name: string) => {
|
93 | Commands: {[key: string]: number};
|
94 | };
|
95 |
|
96 | hasViewManagerConfig: (name: string) => boolean;
|
97 |
|
98 | /**
|
99 | * Used to call a native view method from JavaScript
|
100 | *
|
101 | * reactTag - Id of react view.
|
102 | * commandID - Id of the native method that should be called.
|
103 | * commandArgs - Args of the native method that we can pass from JS to native.
|
104 | */
|
105 | dispatchViewManagerCommand: (
|
106 | reactTag: number | null,
|
107 | commandID: number | string,
|
108 | commandArgs?: Array<any>,
|
109 | ) => void;
|
110 | }
|
111 |
|
112 | export const UIManager: UIManagerStatic;
|
113 | export type UIManager = UIManagerStatic;
|