react-native-macos/packages/rn-tester
Justin Huntington bc1e602e0c Add ScrollView.automaticallyAdjustsScrollIndicatorInsets prop (on iOS) (#29809)
Summary:
iOS 13 added a new property to `UIScrollView`: `automaticallyAdjustsScrollIndicatorInsets`, which is `YES` by default.  The property changes the meaning of the `scrollIndicatorInsets` property.  When `YES`, any such insets are **in addition to** whatever insets would be applied by the device's safe area.  When `NO`, the iOS <13 behavior is restored, which is for such insets to not account for safe area.

In other words, this effects ScrollViews that underlay the device's safe area (i.e. under the notch).  When `YES`, the OS "automatically" insets the scroll indicators, when `NO` it does not.

There are two problems with the default `YES` setting:

1. It means applying `scrollIndicatorInsets` to a `ScrollView` has a different effect on iOS 13 versus iOS 12.
2. It limits developers' control over `scrollIndicatorInsets`.  Since negative insets are not supported, if the insets the OS chooses are too large for your app, you cannot fix it.

Further explanation & sample code is available in issue https://github.com/facebook/react-native/issues/28140 .

This change sets the default for this property to `NO`, making the behavior consistent across iOS versions, and allowing developers full control.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - ScrollView scrollIndicatorInsets to not automatically add safe area on iOS13+

Pull Request resolved: https://github.com/facebook/react-native/pull/29809

Test Plan:
Updated the RNTester example to explain what to expect. Also removed the `pageScreen` modal example for now as mentioned in my Github comment.

{F628636466}

Here are screenshots of the demo app (from the original bug) before (with safe area applied to insets) & after (without safe area applied to insets):

![before](https://user-images.githubusercontent.com/428831/91644197-ea03a700-ea07-11ea-9489-be27820930eb.png)

![after](https://user-images.githubusercontent.com/428831/91644200-eff98800-ea07-11ea-8788-daf1e783639d.png)

Reviewed By: p-sun

Differential Revision: D28229603

Pulled By: lunaleaps

fbshipit-source-id: 2e774ae150b1dc41680b8b7886c7ceac8808136a
2021-07-07 20:23:36 -07:00
..
NativeModuleExample Remove "use strict" directive from ES Modules 2021-02-02 11:12:56 -08:00
RCTTest Bump Flipper-Folly to 2.5.3 and RCT-Folly to 2021.04.26.00 2021-04-29 10:39:25 -07:00
RNTester Support user-defined PlatformColors on iOS (#31258) 2021-06-10 12:15:12 -07:00
RNTester-tvOS Continuous Integration cleanup 2020-11-05 06:09:36 -08:00
RNTesterIntegrationTests Continuous Integration cleanup 2020-11-05 06:09:36 -08:00
RNTesterPods.xcodeproj Fix Hermes + no Flipper build on Xcode 12.5 2021-05-11 15:00:58 -07:00
RNTesterPods.xcworkspace Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
RNTesterUnitTests Migrate NativeModules to initialize 2021-05-21 14:49:51 -07:00
android/app Bump Android deps to 0.93 (#31675) 2021-06-11 04:30:49 -07:00
e2e New Button Component Use Cases (#29848) 2020-09-23 19:51:49 -07:00
js Add ScrollView.automaticallyAdjustsScrollIndicatorInsets prop (on iOS) (#29809) 2021-07-07 20:23:36 -07:00
.eslintrc Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
BUCK Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
Gemfile Remove iOS10/tvOS10 support from remaining podfiles 2021-02-19 13:47:25 -08:00
Podfile Update flipper in RNTester and template (#31010) 2021-02-24 12:23:27 -08:00
Podfile.lock Bump Flipper to 0.93 (#31708) 2021-06-18 07:08:31 -07:00
README.md feat: Enable Hermes to work on iOS (#29914) 2020-11-03 01:14:38 -08:00
package.json React Native sync for revisions 6d3ecb7...c9aab1c 2021-04-06 12:42:37 -07:00

README.md

RNTester

The RNTester showcases React Native views and modules.

Running this app

Before running the app, make sure you ran:

git clone https://github.com/facebook/react-native.git
cd react-native
yarn install

Running on iOS

Both macOS and Xcode are required.

  • cd packages/rn-tester
  • Install Bundler: gem install bundler. We use bundler to install the right version of CocoaPods locally.
  • Install Bundler and CocoaPods dependencies: bundle install && bundle exec pod install. In order to use Hermes engine instead of JSC, run: USE_HERMES=1 bundle exec pod install instead.
  • Open the generated RNTesterPods.xcworkspace. This is not checked in, as it is generated by CocoaPods. Do not open RNTesterPods.xcodeproj directly.

Running on Android

You'll need to have all the prerequisites (SDK, NDK) for Building React Native installed.

Start an Android emulator.

cd react-native
./gradlew :packages:rn-tester:android:app:installJscDebug
./scripts/packager.sh

Note: Building for the first time can take a while.

Open the RNTester app in your emulator. If you want to use a physical device, run adb devices, then adb -s <device name> reverse tcp:8081 tcp:8081. See Running on Device for additional instructions on using a physical device.

Running with Buck

Follow the same setup as running with gradle.

Install Buck from here.

Run the following commands from the react-native folder:

./gradlew :ReactAndroid:packageReactNdkLibsForBuck
buck fetch rntester
buck install -r rntester
./scripts/packager.sh

Note: The native libs are still built using gradle. Full build with buck is coming soon(tm).

Running Detox Tests on iOS

Install Detox from here.

To run the e2e tests locally, run the following commands from the react-native folder:

yarn build-ios-e2e
yarn test-ios-e2e

These are the equivalent of running:

detox build -c ios.sim.release
detox test -c ios.sim.release --cleanup

These build the app in Release mode, so the production code is bundled and included in the built app.

When developing E2E tests, you may want to run in development mode, so that changes to the production code show up immediately. To do this, run:

detox build -c ios.sim.debug
detox test -c ios.sim.debug

You will also need to have Metro running in another terminal. Note that if you've previously run the E2E tests in release mode, you may need to delete the RNTester/build folder before rerunning detox build.

Building from source

Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.

This is different from apps created using react-native init which have a dependency on a specific version of React Native JS and native code, declared in a package.json file (and build.gradle for Android apps).