Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android tooltipText prop #49044

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const UIView = {
nativeID: true,
testID: true,
renderToHardwareTextureAndroid: true,
tooltipTextAndroid: true,
shouldRasterizeIOS: true,
onLayout: true,
onAccessibilityAction: true,
Original file line number Diff line number Diff line change
@@ -99,6 +99,11 @@ export interface ViewPropsAndroid {
*/
renderToHardwareTextureAndroid?: boolean | undefined;

/**
* Displays a small descriptive message that appears near a view when users long press the view or hover their mouse over it
*/
tooltipTextAndroid?: string | undefined;

/**
* Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
*/
Original file line number Diff line number Diff line change
@@ -315,6 +315,15 @@ type AndroidViewProps = $ReadOnly<{
*/
renderToHardwareTextureAndroid?: ?boolean,

/**
* Displays a small descriptive message that appears near a view when users long press the view or hover their mouse over it
*
* @platform android
*
* See https://reactnative.dev/docs/view#tooltipTextAndroid
*/
tooltipTextAndroid?: ?string,

/**
* Controls how view is important for accessibility which is if it
* fires accessibility events and if it is reported to accessibility services
Original file line number Diff line number Diff line change
@@ -182,6 +182,7 @@ const validAttributesForNonEventProps = {
shadowColor: {process: require('../StyleSheet/processColor').default},
zIndex: true,
renderToHardwareTextureAndroid: true,
tooltipTextAndroid: true,
testID: true,
nativeID: true,
accessibilityLabelledBy: true,
Original file line number Diff line number Diff line change
@@ -3926,6 +3926,7 @@ exports[`public API should not change unintentionally Libraries/Components/View/
nativeID: true,
testID: true,
renderToHardwareTextureAndroid: true,
tooltipTextAndroid: true,
shouldRasterizeIOS: true,
onLayout: true,
onAccessibilityAction: true,
@@ -4186,6 +4187,7 @@ type AndroidViewProps = $ReadOnly<{
nativeBackgroundAndroid?: ?AndroidDrawable,
nativeForegroundAndroid?: ?AndroidDrawable,
renderToHardwareTextureAndroid?: ?boolean,
tooltipTextAndroid?: ?string,
importantForAccessibility?: ?(\\"auto\\" | \\"yes\\" | \\"no\\" | \\"no-hide-descendants\\"),
hasTVPreferredFocus?: ?boolean,
nextFocusDown?: ?number,
2 changes: 2 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
@@ -3954,6 +3954,7 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo
public fun setPointerOver (Landroid/view/View;Z)V
public fun setPointerOverCapture (Landroid/view/View;Z)V
public fun setRenderToHardwareTexture (Landroid/view/View;Z)V
public fun setTooltipText (Landroid/view/View;Z)V
public fun setResponderEnd (Landroid/view/View;Z)V
public fun setResponderGrant (Landroid/view/View;Z)V
public fun setResponderMove (Landroid/view/View;Z)V
@@ -5354,6 +5355,7 @@ public final class com/facebook/react/uimanager/ViewProps {
public static final field POINTER_EVENTS Ljava/lang/String;
public static final field POSITION Ljava/lang/String;
public static final field RENDER_TO_HARDWARE_TEXTURE Ljava/lang/String;
public static final field TOOLTIP_TEXT Ljava/lang/String;
public static final field RESIZE_METHOD Ljava/lang/String;
public static final field RESIZE_MODE Ljava/lang/String;
public static final field RIGHT Ljava/lang/String;
Original file line number Diff line number Diff line change
@@ -271,6 +271,11 @@ public void setRenderToHardwareTexture(@NonNull T view, boolean useHWTexture) {
view.setTag(R.id.use_hardware_layer, useHWTexture);
}

@ReactProp(name = ViewProps.TOOLTIP_TEXT)
public void setTooltipText(@NonNull T view, String tooltipText) {
view.setTooltipText(tooltipText);
}

@ReactProp(name = ViewProps.TEST_ID)
public void setTestId(@NonNull T view, @Nullable String testId) {
view.setTag(R.id.react_test_id, testId);
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ public abstract class BaseViewManagerDelegate<
ViewProps.RENDER_TO_HARDWARE_TEXTURE ->
mViewManager.setRenderToHardwareTexture(view, value as Boolean? ?: false)

ViewProps.TOOLTIP_TEXT ->
mViewManager.setTooltipText(view, value as String?)

ViewProps.ROTATION -> mViewManager.setRotation(view, (value as Double?)?.toFloat() ?: 0.0f)

ViewProps.SCALE_X -> mViewManager.setScaleX(view, (value as Double?)?.toFloat() ?: 1.0f)
Original file line number Diff line number Diff line change
@@ -147,6 +147,7 @@ public object ViewProps {
public const val SHADOW_COLOR: String = "shadowColor"
public const val Z_INDEX: String = "zIndex"
public const val RENDER_TO_HARDWARE_TEXTURE: String = "renderToHardwareTextureAndroid"
public const val TOOLTIP_TEXT: String = "tooltipTextAndroid"
public const val ACCESSIBILITY_LABEL: String = "accessibilityLabel"
public const val ACCESSIBILITY_COLLECTION: String = "accessibilityCollection"
public const val ACCESSIBILITY_COLLECTION_ITEM: String = "accessibilityCollectionItem"
Original file line number Diff line number Diff line change
@@ -85,6 +85,15 @@ HostPlatformViewProps::HostPlatformViewProps(
rawProps,
"renderToHardwareTextureAndroid",
sourceProps.renderToHardwareTextureAndroid,
{})),
tooltipTextAndroid(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.tooltipTextAndroid
: convertRawProp(
context,
rawProps,
"tooltipTextAndroid",
sourceProps.tooltipTextAndroid,
{})) {}

#define VIEW_EVENT_CASE(eventType) \
@@ -513,6 +522,11 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
oldProps->renderToHardwareTextureAndroid) {
result["renderToHardwareTextureAndroid"] = renderToHardwareTextureAndroid;
}

if (tooltipTextAndroid !=
oldProps->tooltipTextAndroid) {
result["tooltipTextAndroid"] = tooltipTextAndroid;
}

if (opacity != oldProps->opacity) {
result["opacity"] = opacity;
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ class HostPlatformViewProps : public BaseViewProps {
bool hasTVPreferredFocus{false};
bool needsOffscreenAlphaCompositing{false};
bool renderToHardwareTextureAndroid{false};
std::string tooltipTextAndroid{};

#pragma mark - Convenience Methods

13 changes: 13 additions & 0 deletions packages/rn-tester/js/examples/View/ViewExample.js
Original file line number Diff line number Diff line change
@@ -657,6 +657,14 @@ function BoxSizingExample(): React.Node {
);
}

function TooltipTextAndroidExample(): React.Node {
return (
<View testID={'view-test-tooltip-text'}>
<View tooltipTextAndroid={'test tooltip text'} style={{height: 50, width: 50, backgroundColor: "red"}} />
</View>
);
}

export default ({
title: 'View',
documentationURL: 'https://reactnative.dev/docs/view',
@@ -1321,5 +1329,10 @@ export default ({
name: 'box-sizing',
render: BoxSizingExample,
},
{
title: 'Tooltip text android',
name: 'tooltip-text',
render: TooltipTextAndroidExample,
},
],
}: RNTesterModule);
1 change: 1 addition & 0 deletions tools/api/ReactNativeCPP.api
Original file line number Diff line number Diff line change
@@ -23195,6 +23195,7 @@ class HostPlatformViewProps : public BaseViewProps {
bool hasTVPreferredFocus{false};
bool needsOffscreenAlphaCompositing{false};
bool renderToHardwareTextureAndroid{false};
std::string tooltipTextAndroid{};
bool getProbablyMoreHorizontalThanVertical_DEPRECATED() const;
};
} // namespace facebook::react