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 {Insets} from '../../../types/public/Insets';
|
12 | import {GestureResponderHandlers} from '../../../types/public/ReactNativeRenderer';
|
13 | import {StyleProp} from '../../StyleSheet/StyleSheet';
|
14 | import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
|
15 | import {LayoutChangeEvent, PointerEvents} from '../../Types/CoreEventTypes';
|
16 | import {Touchable} from '../Touchable/Touchable';
|
17 | import {AccessibilityProps} from './ViewAccessibility';
|
18 |
|
19 | export interface TVViewPropsIOS {
|
20 | /**
|
21 | * *(Apple TV only)* When set to true, this view will be focusable
|
22 | * and navigable using the Apple TV remote.
|
23 | *
|
24 | * @platform ios
|
25 | */
|
26 | isTVSelectable?: boolean | undefined;
|
27 |
|
28 | /**
|
29 | * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
|
30 | *
|
31 | * @platform ios
|
32 | */
|
33 | hasTVPreferredFocus?: boolean | undefined;
|
34 |
|
35 | /**
|
36 | * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
|
37 | *
|
38 | * @platform ios
|
39 | */
|
40 | tvParallaxShiftDistanceX?: number | undefined;
|
41 |
|
42 | /**
|
43 | * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
|
44 | *
|
45 | * @platform ios
|
46 | */
|
47 | tvParallaxShiftDistanceY?: number | undefined;
|
48 |
|
49 | /**
|
50 | * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
|
51 | *
|
52 | * @platform ios
|
53 | */
|
54 | tvParallaxTiltAngle?: number | undefined;
|
55 |
|
56 | /**
|
57 | * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
|
58 | *
|
59 | * @platform ios
|
60 | */
|
61 | tvParallaxMagnification?: number | undefined;
|
62 | }
|
63 |
|
64 | export interface ViewPropsIOS extends TVViewPropsIOS {
|
65 | /**
|
66 | * Whether this view should be rendered as a bitmap before compositing.
|
67 | *
|
68 | * On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children;
|
69 | * for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view
|
70 | * and quickly composite it during each frame.
|
71 | *
|
72 | * Rasterization incurs an off-screen drawing pass and the bitmap consumes memory.
|
73 | * Test and measure when using this property.
|
74 | */
|
75 | shouldRasterizeIOS?: boolean | undefined;
|
76 | }
|
77 |
|
78 | export interface ViewPropsAndroid {
|
79 | /**
|
80 | * Views that are only used to layout their children or otherwise don't draw anything
|
81 | * may be automatically removed from the native hierarchy as an optimization.
|
82 | * Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
|
83 | */
|
84 | collapsable?: boolean | undefined;
|
85 |
|
86 | /**
|
87 | * Setting to false prevents direct children of the view from being removed
|
88 | * from the native view hierarchy, similar to the effect of setting
|
89 | * `collapsable={false}` on each child.
|
90 | */
|
91 | collapsableChildren?: boolean | undefined;
|
92 |
|
93 | /**
|
94 | * Whether this view should render itself (and all of its children) into a single hardware texture on the GPU.
|
95 | *
|
96 | * On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale:
|
97 | * in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be
|
98 | * re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation.
|
99 | */
|
100 | renderToHardwareTextureAndroid?: boolean | undefined;
|
101 |
|
102 | /**
|
103 | * Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
|
104 | */
|
105 | focusable?: boolean | undefined;
|
106 |
|
107 | /**
|
108 | * Indicates whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
|
109 | * See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
110 | * for more details.
|
111 | *
|
112 | * Supports the following values:
|
113 | * - 0 (View is focusable)
|
114 | * - -1 (View is not focusable)
|
115 | */
|
116 | tabIndex?: 0 | -1 | undefined;
|
117 | }
|
118 |
|
119 | /**
|
120 | * @see https://reactnative.dev/docs/view#props
|
121 | */
|
122 | export interface ViewProps
|
123 | extends ViewPropsAndroid,
|
124 | ViewPropsIOS,
|
125 | GestureResponderHandlers,
|
126 | Touchable,
|
127 | PointerEvents,
|
128 | AccessibilityProps {
|
129 | children?: React.ReactNode | undefined;
|
130 | /**
|
131 | * This defines how far a touch event can start away from the view.
|
132 | * Typical interface guidelines recommend touch targets that are at least
|
133 | * 30 - 40 points/density-independent pixels. If a Touchable view has
|
134 | * a height of 20 the touchable height can be extended to 40 with
|
135 | * hitSlop={{top: 10, bottom: 10, left: 0, right: 0}}
|
136 | * NOTE The touch area never extends past the parent view bounds and
|
137 | * the Z-index of sibling views always takes precedence if a touch
|
138 | * hits two overlapping views.
|
139 | */
|
140 | hitSlop?: null | Insets | number | undefined;
|
141 |
|
142 | /**
|
143 | * Used to reference react managed views from native code.
|
144 | */
|
145 | id?: string | undefined;
|
146 |
|
147 | /**
|
148 | * Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.
|
149 | * The default (false) falls back to drawing the component and its children
|
150 | * with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value.
|
151 | * This default may be noticeable and undesired in the case where the View you are setting an opacity on
|
152 | * has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).
|
153 | *
|
154 | * Rendering offscreen to preserve correct alpha behavior is extremely expensive
|
155 | * and hard to debug for non-native developers, which is why it is not turned on by default.
|
156 | * If you do need to enable this property for an animation,
|
157 | * consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame).
|
158 | * If that property is enabled, this View will be rendered off-screen once,
|
159 | * saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU.
|
160 | */
|
161 | needsOffscreenAlphaCompositing?: boolean | undefined;
|
162 |
|
163 | /**
|
164 | * Invoked on mount and layout changes with
|
165 | *
|
166 | * {nativeEvent: { layout: {x, y, width, height}}}.
|
167 | */
|
168 | onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
|
169 |
|
170 | /**
|
171 | *
|
172 | * In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class:
|
173 | *
|
174 | * .box-none {
|
175 | * pointer-events: none;
|
176 | * }
|
177 | * .box-none * {
|
178 | * pointer-events: all;
|
179 | * }
|
180 | *
|
181 | * box-only is the equivalent of
|
182 | *
|
183 | * .box-only {
|
184 | * pointer-events: all;
|
185 | * }
|
186 | * .box-only * {
|
187 | * pointer-events: none;
|
188 | * }
|
189 | *
|
190 | * But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes,
|
191 | * we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform.
|
192 | */
|
193 | pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
|
194 |
|
195 | /**
|
196 | *
|
197 | * This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews,
|
198 | * most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound.
|
199 | * The subviews must also have overflow: hidden, as should the containing view (or one of its superviews).
|
200 | */
|
201 | removeClippedSubviews?: boolean | undefined;
|
202 |
|
203 | style?: StyleProp<ViewStyle> | undefined;
|
204 |
|
205 | /**
|
206 | * Used to locate this view in end-to-end tests.
|
207 | */
|
208 | testID?: string | undefined;
|
209 |
|
210 | /**
|
211 | * Used to reference react managed views from native code.
|
212 | */
|
213 | nativeID?: string | undefined;
|
214 | }
|
215 |
|
\ | No newline at end of file |