Skip to content

Commit

Permalink
fix: change opacity logic from random to decrement by -0.20 (#46830)
Browse files Browse the repository at this point in the history
Summary:
Part of this: #46757
Solves:

ME2E0003

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[ Internal ] [ Changed ] - The opacity logic is changed from random to decrement the opacity by -0.2
For more details, see:

Pull Request resolved: #46830

Test Plan:
yarn e2e-test-ios
yarn e2e-test-android

Reviewed By: rshest

Differential Revision: D64173519

Pulled By: cipolleschi

fbshipit-source-id: 69a09b64e7e4f098d3bfd72529401dadb49b93d7
  • Loading branch information
sarthak-d11 authored and facebook-github-bot committed Oct 10, 2024
1 parent 1e8bee9 commit af49070
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/rn-tester/NativeComponentExample/js/MyNativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ function getTextFor(measureStruct: MeasureStruct): string {
measureStruct.height,
)}`;
}
const opacityDecrementCounter = 0.2;

function computeNextOpacity(opacity: number): number {
if (parseFloat(opacity.toFixed(1)) > 0.0) {
return opacity - opacityDecrementCounter;
}
return 1.0;
}

// This is an example component that migrates to use the new architecture.
export default function MyNativeView(props: {}): React.Node {
Expand Down Expand Up @@ -201,7 +209,7 @@ export default function MyNativeView(props: {}): React.Node {
<Button
title="Set Opacity"
onPress={() => {
setOpacity(Math.random());
setOpacity(computeNextOpacity(opacity));
setArrayValues([
Math.floor(Math.random() * 100),
Math.floor(Math.random() * 100),
Expand Down

0 comments on commit af49070

Please sign in to comment.