|
| 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 | + |
| 8 | +package com.facebook.react.uimanager |
| 9 | + |
| 10 | +import android.graphics.Rect |
| 11 | +import android.view.View |
| 12 | + |
| 13 | +/** |
| 14 | + * Interface that should be implemented by [View] subclasses that support `removeClippedSubviews` |
| 15 | + * property. When this property is set for the [ViewGroup] subclass it's responsible for detaching |
| 16 | + * it's child views that are clipped by the view boundaries. Those view boundaries should be |
| 17 | + * determined based on it's parent clipping area and current view's offset in parent and doesn't |
| 18 | + * necessarily reflect the view visible area (in a sense of a value that [View.getGlobalVisibleRect] |
| 19 | + * may return). In order to determine the clipping rect for current view helper method |
| 20 | + * [ReactClippingViewGroupHelper.calculateClippingRect] can be used that takes into account parent |
| 21 | + * view settings. |
| 22 | + */ |
| 23 | +public interface ReactClippingViewGroup { |
| 24 | + /** |
| 25 | + * Notify view that clipping area may have changed and it should recalculate the list of children |
| 26 | + * that should be attached/detached. This method should be called only when property |
| 27 | + * `removeClippedSubviews` is set to `true` on a view. |
| 28 | + * |
| 29 | + * CAUTION: Views are responsible for calling [updateClippingRect] on it's children. This should |
| 30 | + * happen if child implement [ReactClippingViewGroup], return true from [getRemoveClippedSubviews] |
| 31 | + * and clipping rect change of the current view may affect clipping rect of this child. |
| 32 | + */ |
| 33 | + public fun updateClippingRect() |
| 34 | + |
| 35 | + /** |
| 36 | + * Get rectangular bounds to which view is currently clipped to. Called only on views that has set |
| 37 | + * `removeCLippedSubviews` property value to `true`. |
| 38 | + * |
| 39 | + * @param outClippingRect output clipping rect should be written to this object. |
| 40 | + */ |
| 41 | + public fun getClippingRect(outClippingRect: Rect) |
| 42 | + |
| 43 | + /** |
| 44 | + * Sets property `removeClippedSubviews` as a result of property update in JS. Should be called |
| 45 | + * only from [ViewManager.updateView] method. |
| 46 | + * |
| 47 | + * Helper method [ReactClippingViewGroupHelper.applyRemoveClippedSubviewsProperty] may be used by |
| 48 | + * [ViewManager] subclass to apply this property based on property update map |
| 49 | + * [ReactStylesDiffMap]. |
| 50 | + */ |
| 51 | + public var removeClippedSubviews: Boolean |
| 52 | +} |
0 commit comments