From c2b2e2fc7b888bcf003c21b895d7bf66fcf36e8a Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Mar 2021 14:59:37 -0500 Subject: [PATCH 01/22] add pull yml --- .github/pull.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/pull.yml diff --git a/.github/pull.yml b/.github/pull.yml new file mode 100644 index 00000000000000..0232035eb0f013 --- /dev/null +++ b/.github/pull.yml @@ -0,0 +1,17 @@ +version: "1" +rules: # Array of rules + - base: master # Required. Target branch + upstream: microsoft:master # Required. Must be in the same fork network. + mergeMethod: squash # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. + mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false + assignees: # Optional + - HeyImChris + - saadnajmi + reviewers: # Optional + - HeyImChris + - saadnajmi + conflictReviewers: # Optional, on merge conflict assign a reviewer + - HeyImChris + - saadnajmi +label: ":arrow_heading_down: pull" # Optional +conflictLabel: "merge-conflict" # Optional, on merge conflict assign a custom label, Default: merge-conflict \ No newline at end of file From 7a9006bdb9b72629f61fab0b17089d6876757175 Mon Sep 17 00:00:00 2001 From: "pull[bot]" <39814207+pull[bot]@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:44:03 +0000 Subject: [PATCH 02/22] match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton --- Libraries/LinkingIOS/macos/RCTLinkingManager.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LinkingIOS/macos/RCTLinkingManager.mm b/Libraries/LinkingIOS/macos/RCTLinkingManager.mm index 678c2a67639129..979c36b5fe38f3 100644 --- a/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +++ b/Libraries/LinkingIOS/macos/RCTLinkingManager.mm @@ -82,7 +82,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification NSWindow *lastWindow = [[NSApp windows] lastObject]; [lastWindow makeKeyAndOrderFront:nil]; - [self sendEventWithName:@"url" body:notification.userInfo[@"url"]]; + [self sendEventWithName:@"url" body:notification.userInfo]; } RCT_EXPORT_METHOD(openURL:(NSURL *)URL From d9faa3a52a69e4678a32a4f9a8ad6ca88a9f7b66 Mon Sep 17 00:00:00 2001 From: "pull[bot]" <39814207+pull[bot]@users.noreply.github.com> Date: Thu, 14 Oct 2021 19:00:50 +0000 Subject: [PATCH 03/22] [pull] master from microsoft:master (#11) * Deprecated api (#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (#852) * Ignore javadoc failure * Bringing few more changes from 0.63-stable * Fixing a patch in engine selection * Fixing a patch in nuget spec * Fixing the output directory of nuget pack * Packaging dependencies in the nuget * Fix onMouseEnter/onMouseLeave callbacks not firing on Pressable (#855) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton * fix mouse evetns on pressable * delete extra yml from this branch * Add macOS tags * reorder props to have onMouseEnter/onMouseLeave always be before onPress Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com> Co-authored-by: Anandraj Co-authored-by: Saad Najmi Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton Co-authored-by: Muhammad Hamza Zaman --- .ado/android-pr.yml | 17 +- .ado/publish.yml | 7 + Libraries/Components/Pressable/Pressable.js | 6 + README.md | 6 +- React/Base/macOS/RCTPlatformDisplayLink.m | 12 +- React/Views/RCTActivityIndicatorView.m | 4 +- React/Views/RCTProgressViewManager.m | 6 +- React/Views/RCTSlider.m | 2 +- React/Views/RCTSwitch.m | 8 +- .../Build/ReactAndroid/ReactAndroid.nuspec | 76 ++- .../patches/Build/ReactAndroid/release.gradle | 10 + .../facebook/react/bridge/ReactBridge.java | 18 +- .../react/ReactInstanceManagerBuilder.java | 70 ++- android-patches/scripts/download-deps.py | 296 ---------- .../scripts/downloadDependencies.py | 540 ++++++++++++++++++ packages/rn-tester/Podfile.lock | 58 +- .../js/examples/Pressable/PressableExample.js | 2 + 17 files changed, 774 insertions(+), 364 deletions(-) create mode 100644 android-patches/patches/Build/ReactAndroid/release.gradle delete mode 100644 android-patches/scripts/download-deps.py create mode 100644 android-patches/scripts/downloadDependencies.py diff --git a/.ado/android-pr.yml b/.ado/android-pr.yml index c4275eb91ada58..fd4ac235668491 100644 --- a/.ado/android-pr.yml +++ b/.ado/android-pr.yml @@ -46,11 +46,18 @@ jobs: - template: templates\prep-android-nuget.yml + # Verify depenendencies can be enumerated and downloaded .. + - task: CmdLine@2 + displayName: 'Verify Dependencies can be enumerated' + inputs: + script: sudo apt-get install python3-pip && sudo apt-get install python3-setuptools && pip3 install BeautifulSoup4 && pip3 install wheel && pip3 install wget && python3 android-patches/scripts/downloadDependencies.py $(Build.SourcesDirectory) && tree $(Build.SourcesDirectory)/android + + # Very similar to the default pack task .. but appends 'ndk21' to the nuget pack version - task: CmdLine@2 displayName: 'Verify NuGet can be packed' inputs: - script: NDK=ndk`cat ${ANDROID_SDK_ROOT}/ndk-bundle/source.properties 2>&1 | grep Pkg.Revision | awk '{ print $3}' | awk -F. '{ print $1 }'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(System.DefaultWorkingDirectory) -Properties buildNumber=$(buildNumber)-$NDK;commitId=$(Build.SourceVersion) + script: NDK=ndk`cat ${ANDROID_SDK_ROOT}/ndk-bundle/source.properties 2>&1 | grep Pkg.Revision | awk '{ print $3}' | awk -F. '{ print $1 }'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(Build.StagingDirectory)/final -Properties buildNumber=$(buildNumber)-$NDK;commitId=$(Build.SourceVersion) # Android CI doesn't create a nuget now, but this check is failing builds. Quickest fix to unblock builds is to disable the check... but we need to find the root cause and fix it and enable this again. # - script: '[ -f $(System.DefaultWorkingDirectory)/*.nupkg ]' @@ -70,4 +77,10 @@ jobs: - task: CmdLine@2 displayName: gradlew clean inputs: - script: ./gradlew clean \ No newline at end of file + script: ./gradlew clean + + - task: PublishBuildArtifacts@1 + displayName: 'Publish final artifacts' + inputs: + PathtoPublish: '$(Build.StagingDirectory)/final' + ArtifactName: 'ReactNative-Final' diff --git a/.ado/publish.yml b/.ado/publish.yml index e130fd1562b2ec..410840614be5ce 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -144,6 +144,13 @@ jobs: - template: templates\prep-android-nuget.yml + # Enumerate and download all dependencies .. + - task: CmdLine@2 + displayName: 'Verify Dependencies can be enumerated' + inputs: + script: sudo apt-get install python3-pip && sudo apt-get install python3-setuptools && pip3 install BeautifulSoup4 && pip3 install wheel && pip3 install wget && python3 android-patches/scripts/downloadDependencies.py $(Build.SourcesDirectory) && tree $(Build.SourcesDirectory)/android + + # Very similar to the default pack task .. but appends 'ndk21b' to the nuget pack version - task: CmdLine@2 displayName: 'NuGet pack' diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index b71ff90090cc7e..34d3c8ccf716a3 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -170,6 +170,8 @@ function Pressable(props: Props, forwardedRef): React.Node { delayLongPress, disabled, focusable, + onMouseEnter, // [TODO(macOS GH#774) + onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn, @@ -208,6 +210,8 @@ function Pressable(props: Props, forwardedRef): React.Node { android_disableSound, delayLongPress, delayPressIn: unstable_pressDelay, + onHoverIn: onMouseEnter, // [TODO(macOS GH#774) + onHoverOut: onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn(event: PressEvent): void { @@ -236,6 +240,8 @@ function Pressable(props: Props, forwardedRef): React.Node { delayLongPress, disabled, hitSlop, + onMouseEnter, // [TODO(macOS GH#774) + onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn, diff --git a/README.md b/README.md index e460fe18614386..26aed19de38740 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft. -You can read more about the macOS implementation in our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) +You can read more about the macOS implementation on our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) ## Contents @@ -50,14 +50,14 @@ Search the [existing issues](https://github.com/microsoft/react-native-macos/iss - Ensure the [appropriate template](https://github.com/microsoft/react-native-macos/issues/new/choose) is used when filing your issue(s). ## Contributing -See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to setup your fork of the repo and start a PR to contribute to React Native for macOS. +See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to set up your fork of the repo and start a PR to contribute to React Native for macOS. [Good First Issue](https://github.com/microsoft/react-native-macos/labels/good%20first%20issue) and [help wanted](https://github.com/microsoft/react-native-macos/labels/help%20wanted) are great starting points for PRs. ## Documentation [React Native already has great documentation](https://reactnative.dev/docs/getting-started) and we're working to ensure the React Native for Windows + macOS are part of that documentation story. -[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has it's own separate documentation site where Windows and macOS +[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS specific information, like API docs and blog updates live. We are bootstrapping documentation for macOS at this time, tune in for updates. ### Examples diff --git a/React/Base/macOS/RCTPlatformDisplayLink.m b/React/Base/macOS/RCTPlatformDisplayLink.m index ff51cdceb16744..8e8ebfc45e917b 100644 --- a/React/Base/macOS/RCTPlatformDisplayLink.m +++ b/React/Base/macOS/RCTPlatformDisplayLink.m @@ -15,7 +15,7 @@ #import #import -#import +#import @interface RCTPlatformDisplayLink () @@ -30,7 +30,7 @@ @implementation RCTPlatformDisplayLink __weak id _target; NSRunLoop *_runLoop; NSMutableArray *_modes; - OSSpinLock _lock; // OS_SPINLOCK_INIT == 0 + os_unfair_lock _lock; // OS_UNFAIR_LOCK_INIT == 0 } + (RCTPlatformDisplayLink *)displayLinkWithTarget:(id)target selector:(SEL)sel @@ -47,7 +47,7 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display RCTPlatformDisplayLink *rctDisplayLink = (__bridge RCTPlatformDisplayLink*)displayLinkContext; // Lock and check for invalidation prior to calling out to the runloop - OSSpinLockLock(&rctDisplayLink->_lock); + os_unfair_lock_lock(&rctDisplayLink->_lock); if (rctDisplayLink->_runLoop != nil) { CFRunLoopRef cfRunLoop = [rctDisplayLink->_runLoop getCFRunLoop]; CFRunLoopPerformBlock(cfRunLoop, kCFRunLoopDefaultMode, ^{ @@ -55,7 +55,7 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display }); CFRunLoopWakeUp(cfRunLoop); } - OSSpinLockUnlock(&rctDisplayLink->_lock); + os_unfair_lock_unlock(&rctDisplayLink->_lock); } return kCVReturnSuccess; } @@ -98,10 +98,10 @@ - (void)removeFromRunLoop:(__unused NSRunLoop *)runloop forMode:(NSRunLoopMode)m - (void)invalidate { if (_runLoop != nil) { - OSSpinLockLock(&_lock); + os_unfair_lock_lock(&_lock); _runLoop = nil; _modes = nil; - OSSpinLockUnlock(&_lock); + os_unfair_lock_unlock(&_lock); // CVDisplayLinkStop attempts to acquire a mutex possibly held during the callback's invocation. // Stop the display link outside of the lock to avoid deadlocking here. diff --git a/React/Views/RCTActivityIndicatorView.m b/React/Views/RCTActivityIndicatorView.m index 0305458737e8f6..4b4a8bbf7bf710 100644 --- a/React/Views/RCTActivityIndicatorView.m +++ b/React/Views/RCTActivityIndicatorView.m @@ -23,7 +23,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { self.displayedWhenStopped = NO; - self.style = NSProgressIndicatorSpinningStyle; + self.style = NSProgressIndicatorStyleSpinning; } return self; } @@ -82,7 +82,7 @@ - (void)updateLayer [super updateLayer]; if (_color != nil) { CGFloat r, g, b, a; - [[_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a]; + [[_color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a]; CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"]; [colorPoly setDefaults]; diff --git a/React/Views/RCTProgressViewManager.m b/React/Views/RCTProgressViewManager.m index dd802c059a5b6e..d732342940aaa4 100644 --- a/React/Views/RCTProgressViewManager.m +++ b/React/Views/RCTProgressViewManager.m @@ -14,9 +14,9 @@ @implementation RCTConvert (RCTProgressViewManager) #if TARGET_OS_OSX // [TODO(macOS GH#774) RCT_ENUM_CONVERTER(NSProgressIndicatorStyle, (@{ - @"default": @(NSProgressIndicatorBarStyle), - @"bar": @(NSProgressIndicatorBarStyle), -}), NSProgressIndicatorBarStyle, integerValue) + @"default": @(NSProgressIndicatorStyleBar), + @"bar": @(NSProgressIndicatorStyleBar), +}), NSProgressIndicatorStyleBar, integerValue) #else // ]TODO(macOS GH#774) RCT_ENUM_CONVERTER( UIProgressViewStyle, diff --git a/React/Views/RCTSlider.m b/React/Views/RCTSlider.m index cb11a7a28673c4..7c5b1f655386b5 100644 --- a/React/Views/RCTSlider.m +++ b/React/Views/RCTSlider.m @@ -126,7 +126,7 @@ @implementation RCTSlider { - (instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { - self.cell.controlSize = NSRegularControlSize; + self.cell.controlSize = NSControlSizeRegular; ((RCTSliderCell*)self.cell).delegate = self; } return self; diff --git a/React/Views/RCTSwitch.m b/React/Views/RCTSwitch.m index 2bbb711b0b9827..056f8066090bcc 100644 --- a/React/Views/RCTSwitch.m +++ b/React/Views/RCTSwitch.m @@ -19,7 +19,7 @@ @implementation RCTSwitch - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - self.buttonType = NSSwitchButton; + self.buttonType = NSButtonTypeSwitch; self.title = @""; // default is "Button" } return self; @@ -34,7 +34,7 @@ - (void)setOn:(BOOL)on animated:(BOOL)animated } #else // [TODO(macOS GH#774) - (void)setOn:(BOOL)on animated:(BOOL)animated { - self.state = on ? NSOnState : NSOffState; + self.state = on ? NSControlStateValueOn : NSControlStateValueOff; } #endif // ]TODO(macOS GH#774) @@ -42,12 +42,12 @@ - (void)setOn:(BOOL)on animated:(BOOL)animated { - (BOOL)on { - return self.state == NSOnState; + return self.state == NSControlStateValueOn; } - (void)setOn:(BOOL)on { - self.state = on ? NSOnState : NSOffState; + self.state = on ? NSControlStateValueOn : NSControlStateValueOff; } #endif // ]TODO(macOS GH#774) diff --git a/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec b/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec index b03fdffd8a7c4e..200effcbc06ba7 100644 --- a/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec +++ b/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec @@ -1,6 +1,6 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\ReactAndroid.nuspec" 1969-12-31 16:00:00.000000000 -0800 -+++ "E:\\github\\rnm-63\\ReactAndroid\\ReactAndroid.nuspec" 2020-10-27 20:20:54.071789900 -0700 -@@ -0,0 +1,130 @@ +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\ReactAndroid.nuspec" 1969-12-31 16:00:00.000000000 -0800 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\ReactAndroid.nuspec" 2021-10-12 19:48:38.934480100 -0700 +@@ -0,0 +1,200 @@ + + + @@ -64,6 +64,41 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + @@ -116,6 +151,40 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + @@ -128,6 +197,7 @@ + + + ++ + + + diff --git a/android-patches/patches/Build/ReactAndroid/release.gradle b/android-patches/patches/Build/ReactAndroid/release.gradle new file mode 100644 index 00000000000000..ed6ab89d7ce85e --- /dev/null +++ b/android-patches/patches/Build/ReactAndroid/release.gradle @@ -0,0 +1,10 @@ +--- /home/mganandraj/github/rnm-64-vanilla/ReactAndroid/release.gradle 2021-10-11 17:51:44.286455263 -0700 ++++ /home/mganandraj/github/rnm-64/ReactAndroid/release.gradle 2021-10-07 16:35:28.636536900 -0700 +@@ -74,6 +74,7 @@ + afterEvaluate { project -> + + task androidJavadoc(type: Javadoc) { ++ failOnError false + source = android.sourceSets.main.java.srcDirs + classpath += files(android.bootClasspath) + classpath += files(project.getConfigurations().getByName("compile").asList()) diff --git a/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java b/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java index 6e760b741d1f9a..453802aa68d84f 100644 --- a/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java +++ b/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java @@ -1,11 +1,21 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2020-10-27 20:26:16.762190600 -0700 -+++ "E:\\github\\rnm-63\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2020-10-13 21:38:04.995797000 -0700 -@@ -31,6 +31,14 @@ +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2021-10-12 13:35:49.124099000 -0700 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2021-10-12 13:22:46.508704400 -0700 +@@ -31,6 +31,24 @@ Systrace.beginSection( TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni"); ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START); + -+ SoLoader.loadLibrary("v8jsi"); ++ // JS Engine is configurable .. And we expect only one packaged. ++ // Hence ignore failure. ++ ++ try { ++ SoLoader.loadLibrary("hermes"); ++ } catch (UnsatisfiedLinkError jscE) {} ++ ++ try { ++ SoLoader.loadLibrary("v8jsi"); ++ } catch (UnsatisfiedLinkError jscE) {} ++ + SoLoader.loadLibrary("glog_init"); + SoLoader.loadLibrary("fb"); + SoLoader.loadLibrary("fbjni"); diff --git a/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index 8b8f4bfb7a43a8..0a7078a01da333 100644 --- a/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -1,5 +1,5 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2020-10-27 20:26:16.728167300 -0700 -+++ "E:\\github\\rnm-63\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2020-10-13 21:27:45.535631600 -0700 +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2021-10-12 13:33:12.881732000 -0700 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2021-10-12 13:26:43.722189600 -0700 @@ -26,6 +26,7 @@ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; import com.facebook.react.devsupport.interfaces.DevSupportManager; @@ -8,21 +8,69 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.packagerconnection.RequestHandler; import com.facebook.react.uimanager.UIImplementationProvider; -@@ -291,7 +292,8 @@ +@@ -59,8 +60,21 @@ + private @Nullable JSIModulePackage mJSIModulesPackage; + private @Nullable Map mCustomPackagerCommandHandlers; + ++ public enum JSEngine { ++ Hermes, ++ V8 ++ } ++ ++ private JSEngine mJSEngine = JSEngine.V8; ++ + /* package protected */ ReactInstanceManagerBuilder() {} + ++ public ReactInstanceManagerBuilder setJSEngine( ++ JSEngine jsEngine) { ++ mJSEngine = jsEngine; ++ return this; ++ } ++ + /** Sets a provider of {@link UIImplementation}. Uses default provider if null is passed. */ + public ReactInstanceManagerBuilder setUIImplementationProvider( + @Nullable UIImplementationProvider uiImplementationProvider) { +@@ -291,40 +305,10 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { - try { +- // If JSC is included, use it as normal +- initializeSoLoaderIfNecessary(applicationContext); +- SoLoader.loadLibrary("jscexecutor"); +- return new JSCExecutorFactory(appName, deviceName); +- } catch (UnsatisfiedLinkError jscE) { +- // https://github.com/facebook/hermes/issues/78 shows that +- // people who aren't trying to use Hermes are having issues. +- // https://github.com/facebook/react-native/issues/25923#issuecomment-554295179 +- // includes the actual JSC error in at least one case. +- // +- // So, if "__cxa_bad_typeid" shows up in the jscE exception +- // message, then we will assume that's the failure and just +- // throw now. +- +- if (jscE.getMessage().contains("__cxa_bad_typeid")) { +- throw jscE; +- } +- +- // Otherwise use Hermes +- try { ++ if(mJSEngine == JSEngine.V8) { + return new V8ExecutorFactory(appName, deviceName); -+/* try { - // If JSC is included, use it as normal - initializeSoLoaderIfNecessary(applicationContext); - SoLoader.loadLibrary("jscexecutor"); -@@ -325,6 +327,6 @@ - hermesE.printStackTrace(); - throw jscE; ++ } else { + return new HermesExecutorFactory(); +- } catch (UnsatisfiedLinkError hermesE) { +- // If we get here, either this is a JSC build, and of course +- // Hermes failed (since it's not in the APK), or it's a Hermes +- // build, and Hermes had a problem. +- +- // We suspect this is a JSC issue (it's the default), so we +- // will throw that exception, but we will print hermesE first, +- // since it could be a Hermes issue and we don't want to +- // swallow that. +- hermesE.printStackTrace(); +- throw jscE; } - } -+ } */ } } diff --git a/android-patches/scripts/download-deps.py b/android-patches/scripts/download-deps.py deleted file mode 100644 index 681e0ede5bf1b1..00000000000000 --- a/android-patches/scripts/download-deps.py +++ /dev/null @@ -1,296 +0,0 @@ -from bs4 import BeautifulSoup -import os -import re -import shlex -import shutil -from subprocess import Popen, PIPE -import sys -import wget -import urllib2 -import glob - - -if len(sys.argv) != 2: - print "Please provide RN repo path as argument" - sys.exit() - -root_dir = sys.argv[1] -dependency_dir = os.path.join(root_dir, "android_dependencies_downloaded2") -dependency_list_file_path = os.path.join( - root_dir, "gradle_dependency_list.txt" - ) -# maven_repo_url = "http://central.maven.org/maven2/" -maven_repo_url = "https://repo1.maven.org/maven2/" -# desired_ndk = "androidndk.12.2.0" -desired_sdk = "androidsdk.29.0.1" -# desired_jdk = "jdk.1.8.2" - - -def create_folder(folder_path): - """Create folder if it does not exist - - Parameters - ---------- - folder_path : str - folder path to be checked - """ - if not os.path.exists(folder_path): - print('Trying to create ' + folder_path) - os.makedirs(folder_path) - - -def set_env_variables(): - """ - Sets the NDK, SDK, JAVA_HOME, ANDROID_HOME vars - if they are not set - """ - if 'NugetMachineInstallRoot' not in os.environ: - print "Nuget cache not defined, do you have an office enlistment in this machine?" - sys.exit() - - nugetcache_path = os.environ['NugetMachineInstallRoot'] - # desired_ndk_path = os.path.join(nugetcache_path, desired_ndk) - # desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) - # desired_jdk_path = os.path.join(nugetcache_path, desired_jdk, "x64")# - - #set_env_variable("ANDROID_NDK", desired_ndk_path) - #set_env_variable("ANDOIRD_SDK", desired_sdk_path) - #set_env_variable("ANDROID_HOME", desired_sdk_path) - #set_env_variable("JAVA_HOME", desired_jdk_path) - - set_env_variable("ANDROID_NDK", "E:\\devtools\\android-ndk-r17c") - set_env_variable("ANDOIRD_SDK", "D:\\nugetcache\\androidsdk.29.0.1") - set_env_variable("ANDROID_HOME", "D:\\nugetcache\\androidsdk.29.0.1") - set_env_variable("JAVA_HOME", "D:\\nugetcache\\jdk.1.8.3\\x64") - - -def set_env_variable(key, value): - """Set env variable given key and value - Parameters - ------------- - key : str - enivronment key name - value : str - desired value for key - """ - os.environ[key] = value - - -def list_dependencies(): - """ Write all gradle dependencies to file - """ - os.chdir(root_dir) - -# Note: Likely we need a union of releaseCompileClasspath & releaseRuntimeClasspath & debugCompileClasspath & debugRuntimeClasspath - gradle_command = "gradlew.bat ReactAndroid:dependencies --configuration releaseCompileClasspath" - gradle_command = gradle_command + " > " + \ - "\"" + dependency_list_file_path + "\"" - command_args = shlex.split(gradle_command) - process = Popen(command_args, stdout=PIPE) - (output, err) = process.communicate() - exit_code = process.wait() - - -def parse_dependencies(filepath): - """ Parse gradle dependencies and return list - - Parameters - ----------- - filepath : str - file containing gradle dependency list - - Returns - ----------- - dependency_list : list - list of dependecies in maven format - """ - infile = open(filepath, "r") - dependency_list = [] - - dependency_regex = "\S+:\S+:\S+" - omit_dependency_delim = "(*)" - for line in infile: - if line.endswith(omit_dependency_delim): - continue - - regex_matches = re.search(dependency_regex, line) - if regex_matches != None: - dependency = regex_matches.group(0) - if dependency not in dependency_list: - dependency_list.append(dependency) - - return dependency_list - - -def create_dependency_folder_structure(dependency): - """ Takes dependency in maven format and creates - folder structure required for download. - Returns the path where it should be downloaded - Parameters - ---------- - dependency : str - name in maven format - Returns - ---------- - path : str - folder depth path where dependencies - will be downloaded - """ - group_id, artifact, version = dependency.split(":") - - folder_chain = [] - for group in group_id.split("."): - folder_chain.append(group) - - folder_chain.append(artifact) - folder_chain.append(version) - - parent_dir = dependency_dir - for folder in folder_chain: - child_dir = os.path.join(parent_dir, folder) - create_folder(child_dir) - parent_dir = child_dir - - return parent_dir - - -def download_dependencies(dependency_list): - """Creates the directory structure - and downloads the maven dependecies - and saves it in the same format - - Parameters - ----------- - dependency_list : list - list of dependencies in maven format - """ - for dependency in dependency_list: - download_dir = create_dependency_folder_structure(dependency) - relative_dir = os.path.relpath(download_dir, dependency_dir) - relative_url = relative_dir.replace("\\", "/") - download_url = maven_repo_url + relative_url - - group_id, artifact, version = dependency.split(":") - file_type = artifact + "-" + version + "." - dependency_pom_path = os.path.join(download_dir, file_type + "pom") - - try: - html_source = urllib2.urlopen(download_url).read() - except: - print "[ERROR downloading ] " + download_url - print "Attempting to pull from local sdk" - copy_deps_from_local_sdk(download_dir, relative_dir) - dependency_list.extend( - get_parent_node_dep_list_from_pom(dependency_pom_path) - ) - continue - - soup = BeautifulSoup(html_source, "html.parser") - for link in soup.find_all('a'): - if file_type in link['href']: - file_name = link['href'] - if not os.path.exists(os.path.join(download_dir, file_name)): - wget.download(download_url + "/" + file_name, download_dir) - print "Downloaded " + file_name - - dependency_list.extend( - get_parent_node_dep_list_from_pom(dependency_pom_path) - ) - - -def get_parent_node_dep_list_from_pom(pom_file_path): - """Reads a pom file and gets parent node deps. - Parent node deps are not resolved by gradle deps, - hence resolving them as well. - Parameters - --------------- - pom_file_path : str - pom file to be parsed - Returns - -------------- - parent_dependency_list : list - List of parent node dependencies - """ - namespace = "http://maven.apache.org/POM/4.0.0" - - if not os.path.exists(pom_file_path): - print "POM file " + pom_file_path + " does not exist" - print "Continuing..." - return [] - pom_file_content = open(pom_file_path, "r").read() - soup = BeautifulSoup(pom_file_content, "html.parser") - parents = soup.find_all("parent") - - parent_dependency_list = [] - for parent in parents: - groupId = artifactId = version = "" - if (parent.find("groupid") is None or - parent.find("artifactid") is None or - parent.find("version") is None): - continue - groupId = parent.find("groupid").text - artifactId = parent.find("artifactid").text - version = parent.find("version").text - parent_dependency_list.append(":".join([groupId, artifactId, version])) - - return parent_dependency_list - - -def copy_deps_from_local_sdk(target_dir, relative_dir): - """ Copies dependency files from nuget cache sdk - to target directory in this case download dependency directory - Parameters - -------------- - target_dir : str - directory created for download of dependency - relative_dir : str - maven directory structure of dependency - """ - - nugetcache_path = os.environ['NugetMachineInstallRoot'] - if not os.path.exists(nugetcache_path): - print "Nuget cache does not exist. Continuing." - return - desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) - if not os.path.exists(desired_sdk_path): - print "Desired android sdk " + desired_sdk + " not found in nuget cache. Continuing." - return - - source_dir = os.path.join( - desired_sdk_path, "extras", "android", "m2repository") - source_dir = os.path.join(source_dir, relative_dir) - if not os.path.exists(source_dir): - print "Dependecy not present in nuget cache android sdk. Continuing." - return - - src_files = os.listdir(source_dir) - for file_name in src_files: - src_file = os.path.join(source_dir, file_name) - if os.path.isfile(src_file): - if not os.path.exists(os.path.join(target_dir, file_name)): - shutil.copy(src_file, target_dir) - print "Copied file : " + file_name - else: - print file_name + " already present" - - -def parse_and_download_dependencies(filepath): - """ Parse and download gradle dependencies - - Parameters - ----------- - filepath : str - file containing gradle dependency list - """ - dependency_list = parse_dependencies(filepath) - download_dependencies(dependency_list) - - -def main(): - create_folder(dependency_dir) - set_env_variables() - list_dependencies() - parse_and_download_dependencies(dependency_list_file_path) - -if __name__ == '__main__': - main() diff --git a/android-patches/scripts/downloadDependencies.py b/android-patches/scripts/downloadDependencies.py new file mode 100644 index 00000000000000..dd036900583644 --- /dev/null +++ b/android-patches/scripts/downloadDependencies.py @@ -0,0 +1,540 @@ +from bs4 import BeautifulSoup +import os +import re +import shlex +import shutil +from subprocess import Popen, PIPE, STDOUT +import sys +import wget +from urllib.request import urlopen +import glob +import zipfile +import time +import sys +import logging +import xml.etree.ElementTree as ET +import json + +# Note: This list of repo needs to be kept current manually. +maven_repos = ["https://repo1.maven.org/maven2/", "https://jcenter.bintray.com/"] + +desired_sdk = os.getenv("ANDROID_SDK_ROOT") +if not desired_sdk: + logging.error("Envrionment variable ANDROID_SDK_ROOT must be set.") + exit(-1) + +if os.getenv("ANDROID_NDK"): + desired_ndk = os.getenv("ANDROID_NDK") +elif os.path.exists(os.path.join(desired_sdk, "ndk-bundle")): + desired_ndk = os.path.join(desired_sdk, "ndk-bundle") +elif os.path.exists(os.path.join(desired_sdk, "ndk")): + desired_ndk = os.path.join(desired_sdk, "ndk") +else: + logging.error("Envrionment variable ANDROID_NDK must be set.") + exit(-1) + +desired_jdk = os.getenv("JAVA_HOME") +if not desired_jdk: + logging.error("Envrionment variable JAVA_HOME must be set.") + exit(-1) + + +def create_folder(folder_path): + """Create folder if it does not exist + + Parameters + ---------- + folder_path : str + folder path to be checked + """ + if not os.path.exists(folder_path): + try: + os.makedirs(folder_path) + except Exception as inst: + logging.error("Error while creating directory: " + inst) + +def list_dependencies(react_native_dir, output_file_path): + """ Write all gradle dependencies to file + """ + os.chdir(react_native_dir) + env = dict(os.environ) + env['ANDROID_SDK_ROOT']=desired_sdk + env['ANDROID_NDK']=desired_ndk + env['JAVA_HOME']=desired_jdk + + logging.debug("desired_jdk:" + desired_jdk) + + gradle_command = "./gradlew :ReactAndroid:dependencies --configuration api" + with open(output_file_path, "w+") as output_file: + try: + process = Popen(shlex.split(gradle_command), stdout=output_file, stderr=PIPE, env=env) + output, err = process.communicate() + if err: + logging.error("Dependency enumeration failed !") + logging.error(err) + exit(1) + exit_code = process.wait() + if exit_code < 0: + logging.error("Dependency enumeration failed with error code: " + exit_code + " !") + exit(1) + except Exception as e: + logging.error("Dependency enumeration failed with exception: " + str(e)) + exit(1) + + +def parse_dependencies(filepath): + """ Parse gradle dependencies and return list + + Parameters + ----------- + filepath : str + file containing gradle dependency list + + Returns + ----------- + dependency_list : list + list of dependecies in maven format + """ + infile = open(filepath, "r") + dependency_list = [] + + dependency_regex = "[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+" + omit_dependency_delim = "(*)" + for line in infile: + if line.endswith(omit_dependency_delim): + continue + + regex_matches = re.search(dependency_regex, line) + if regex_matches != None: + dependency = regex_matches.group(0) + if dependency not in dependency_list: + dependency_list.append(dependency) + logging.info("Identified library: " + line) + else: + logging.info("Ignored entry: " + line) + + return dependency_list + + +def create_dependency_folder_structure(dependency_dir_maven, dependency): + """ Takes dependency in maven format and creates + folder structure required for download. + Returns the path where it should be downloaded + Parameters + ---------- + dependency : str + name in maven format + Returns + ---------- + path : str + folder depth path where dependencies + will be downloaded + """ + group_id, artifact, version = dependency.split(":") + + folder_chain = [] + for group in group_id.split("."): + folder_chain.append(group) + + folder_chain.append(artifact) + folder_chain.append(version) + + parent_dir = dependency_dir_maven + for folder in folder_chain: + child_dir = os.path.join(parent_dir, folder) + create_folder(child_dir) + parent_dir = child_dir + + return parent_dir + + +def try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url): + logging.debug("Attempting to download " + dependency) + download_url = repo_url + relative_url + + try: + html_source = urlopen(download_url).read() + soup = BeautifulSoup(html_source, "html.parser") + for link in soup.find_all('a'): + if file_type in link['href']: + file_name = link['href'] + if not os.path.exists(os.path.join(download_dir, file_name)): + wget.download(download_url + "/" + file_name, download_dir) + logging.info("Downloaded " + file_name) + + return True # either the file exists (previously downloaded) or the download succeeded (i.e. without exception). + + except Exception as inst: + logging.info("Exception while downloading: " + str(inst)) + return False + + return False + +def get_office_platform(platform): + switcher = {'arm64-v8a':'droidarm64', 'armeabi-v7a':'droidarm', 'x86':'droidx86','x86_64':'droidx64'} + return switcher.get(platform,"") + +def extract_so(original_file_root, native_dir, original_file_name): + logging.info("Attempting to extract native libraries from " + original_file_name) + archive_filename_without_ext, archive_file_extension = os.path.splitext(original_file_name) + original_file_path = os.path.join(original_file_root, original_file_name) + zip_filepath = os.path.join(original_file_root, original_file_name + ".zip") + shutil.move(original_file_path, zip_filepath) + + # Extract the archive + with zipfile.ZipFile(zip_filepath) as zip_file: + zip_target_folder = os.path.join(original_file_root, archive_filename_without_ext) + zip_file.extractall(zip_target_folder) + + # Extract native libraries. + for candidate_so_root, dirsi, candidate_so_files in os.walk(zip_target_folder): + for candidate_so_file in candidate_so_files: + if candidate_so_file.endswith(".so"): + logging.info("Found native library " + candidate_so_file) + so_path = os.path.join(candidate_so_root, candidate_so_file) + + lib_platform = os.path.basename(candidate_so_root) + lib_office_platform = get_office_platform(lib_platform) + if not lib_office_platform: + logging.error("Invalid platform for native library: " + candidate_so_file) + exit(1) + + so_target_dir = os.path.join(native_dir, lib_office_platform) + create_folder(so_target_dir) + shutil.move(so_path, so_target_dir) + + # Re-zip back to original file name. + new_zip_filepath = os.path.join(original_file_root, archive_filename_without_ext + "_rezipped.zip") + with zipfile.ZipFile(new_zip_filepath, 'w', zipfile.ZIP_DEFLATED) as zip_file: + for rootz, dirsz, filesz in os.walk(zip_target_folder): + for filez in filesz: + dest_path = os.path.join(rootz, filez) + # rel_path = os.path.relpath(dest_path, os.path.join(zip_target_folder, '..')) + rel_path = os.path.relpath(dest_path, zip_target_folder) + zip_file.write(dest_path, rel_path) + + # Rename the rezipped file to original file name. + shutil.move(new_zip_filepath, os.path.join(original_file_root, original_file_name)) + + # Remove the originally renamed archive and extracted folder. + shutil.rmtree(zip_target_folder) + os.remove(zip_filepath) + +def extract_sos(maven_dir, native_dir): + logging.debug("Attempting to extract native libraries") + + for original_file_root, dirs, original_files in os.walk(maven_dir): + for original_file_name in original_files: + archive_filename_without_ext, archive_file_extension = os.path.splitext(original_file_name) + if(archive_file_extension in ['.jar', '.aar']): + extract_so(original_file_root, native_dir, original_file_name) + + + +def download_dependencies(dependency_dir_maven, dependency_list): + """Creates the directory structure + and downloads the maven dependecies + and saves it in the same format + + Parameters + ----------- + dependency_list : list + list of dependencies in maven format + """ + parent_list = [] + for dependency in dependency_list: + download_dir = create_dependency_folder_structure(dependency_dir_maven, dependency) + relative_dir = os.path.relpath(download_dir, dependency_dir_maven) + relative_url = relative_dir.replace("\\", "/") + + group_id, artifact, version = dependency.split(":") + file_type = artifact + "-" + version + "." + dependency_pom_path = os.path.join(download_dir, file_type + "pom") + + succeeded = False + for repo_url in maven_repos: + succeeded = try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url) + if (succeeded): + break + + if not succeeded: + logging.error("[ERROR downloading ] " + relative_url + " from the listed maven repos.") + logging.error("Attempting to pull from local sdk") + succeeded = copy_deps_from_local_sdk(download_dir, relative_dir) + + if not succeeded: + logging.error("[Failed to download ] " + dependency) + else: + additional_dependency_list = get_dependency_node_dep_list_from_pom(dependency_pom_path) + for additional_dependency in additional_dependency_list: + if (additional_dependency not in dependency_list): + dependency_list.append(additional_dependency) + + parent_dependency_list = get_parent_node_dep_list_from_pom(dependency_pom_path) + for parent_dependency in parent_dependency_list: + if ((parent_dependency not in parent_list) and (parent_dependency not in dependency_list)): + parent_list.append(parent_dependency) + + for dependency in parent_list: + download_dir = create_dependency_folder_structure(dependency_dir_maven, dependency) + relative_dir = os.path.relpath(download_dir, dependency_dir_maven) + relative_url = relative_dir.replace("\\", "/") + + group_id, artifact, version = dependency.split(":") + file_type = artifact + "-" + version + "." + dependency_pom_path = os.path.join(download_dir, file_type + "pom") + + succeeded = False + for repo_url in maven_repos: + succeeded = try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url) + if (succeeded): + break + + if not succeeded: + logging.error("[ERROR downloading ] " + relative_url + " from the listed maven repos.") + logging.error("Attempting to pull from local sdk") + succeeded = copy_deps_from_local_sdk(download_dir, relative_dir) + + if not succeeded: + logging.error("[Failed to download ] " + dependency) + + # Don't recurse down for parent dependencies + +def get_dependency_node_dep_list_from_pom(pom_file_path): + """Reads a pom file and gets parent node deps. + Parent node deps are not resolved by gradle deps, + hence resolving them as well. + Parameters + --------------- + pom_file_path : str + pom file to be parsed + Returns + -------------- + parent_dependency_list : list + List of parent node dependencies + """ + namespace = "http://maven.apache.org/POM/4.0.0" + + if not os.path.exists(pom_file_path): + logging.info("POM file " + pom_file_path + " does not exist") + logging.info("Continuing...") + return [] + + dependency_dependency_list = [] + tree = ET.parse(pom_file_path) + for dependency in tree.getroot().findall('.//{http://maven.apache.org/POM/4.0.0}dependency'): + groupId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}groupId') + artifactId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}artifactId') + version = dependency.find('.//{http://maven.apache.org/POM/4.0.0}version') + scope = dependency.find('.//{http://maven.apache.org/POM/4.0.0}scope') + + if groupId is None or artifactId is None or version is None: + break + + if(scope is None or scope.text in ['compile', 'runtime']): + if scope is not None: + logging.info("[" + scope.text + "]") + logging.info(groupId.text + ":" + artifactId.text + ":" + version.text) + dependency_dependency_list.append(":".join([groupId.text, artifactId.text, version.text])) + + return dependency_dependency_list + + + +def get_parent_node_dep_list_from_pom(pom_file_path): + """Reads a pom file and gets parent node deps. + Parent node deps are not resolved by gradle deps, + hence resolving them as well. + Parameters + --------------- + pom_file_path : str + pom file to be parsed + Returns + -------------- + parent_dependency_list : list + List of parent node dependencies + """ + namespace = "http://maven.apache.org/POM/4.0.0" + + if not os.path.exists(pom_file_path): + logging.info("POM file " + pom_file_path + " does not exist") + logging.info("Continuing...") + return [] + + parent_dependency_list = [] + tree = ET.parse(pom_file_path) + # TODO: Share code with last block + for dependency in tree.getroot().findall('.//{http://maven.apache.org/POM/4.0.0}parent'): + groupId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}groupId') + artifactId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}artifactId') + version = dependency.find('.//{http://maven.apache.org/POM/4.0.0}version') + scope = dependency.find('.//{http://maven.apache.org/POM/4.0.0}scope') + + if groupId is None or artifactId is None or version is None: + break + + if(scope is None or scope.text in ['compile', 'runtime']): + if scope is not None: + logging.info("[" + scope.text + "]") + logging.info(groupId.text + ":" + artifactId.text + ":" + version.text) + parent_dependency_list.append(":".join([groupId.text, artifactId.text, version.text])) + + # pom_file_content = open(pom_file_path, "r").read() + # soup = BeautifulSoup(pom_file_content, "html.parser") + # parents = soup.find_all("parent") + + # parent_dependency_list = [] + # for parent in parents: + # groupId = artifactId = version = "" + # if (parent.find("groupid") is None or + # parent.find("artifactid") is None or + # parent.find("version") is None): + # continue + # groupId = parent.find("groupid").text + # artifactId = parent.find("artifactid").text + # version = parent.find("version").text + # parent_dependency_list.append(":".join([groupId, artifactId, version])) + + return parent_dependency_list + + +def copy_deps_from_local_sdk(target_dir, relative_dir): + """ Copies dependency files from nuget cache sdk + to target directory in this case download dependency directory + Parameters + -------------- + target_dir : str + directory created for download of dependency + relative_dir : str + maven directory structure of dependency + """ + +# nugetcache_path = os.environ['NugetMachineInstallRoot'] +# if not os.path.exists(nugetcache_path): +# logging.info("Nuget cache does not exist. Continuing.") +# return False + +# desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) +# if not os.path.exists(desired_sdk_path): +# logging.info("Desired android sdk " + desired_sdk + " not found in nuget cache. Continuing.") +# return False + + source_dir = os.path.join( + desired_sdk, "extras", "android", "m2repository") + source_dir = os.path.join(source_dir, relative_dir) + if not os.path.exists(source_dir): + logging.info("Dependecy not present in nuget cache android sdk. Continuing.") + return False + + src_files = os.listdir(source_dir) + for file_name in src_files: + src_file = os.path.join(source_dir, file_name) + if os.path.isfile(src_file): + if not os.path.exists(os.path.join(target_dir, file_name)): + shutil.copy(src_file, target_dir) + logging.info("Copied file : " + file_name) + else: + logging.info(file_name + " already present") + return True + + return False + + +def parse_and_download_dependencies(dependency_dir_maven, dependency_list_filepath): + """ Parse and download gradle dependencies + + Parameters + ----------- + filepath : str + file containing gradle dependency list + """ + dependency_list = parse_dependencies(dependency_list_filepath) + download_dependencies(dependency_dir_maven, dependency_list) + +def ensure_output_dir(output_dir_path): + # Move out if already exists. + if os.path.exists(output_dir_path): + logging.debug(output_dir_path + " exists ! Trying to move it.") + output_dir_path_copy = output_dir_path + '-' + time.strftime("%Y%m%d-%H%M%S") + shutil.move(output_dir_path, output_dir_path_copy ) + + # If it still exists, fail the execution. + if os.path.exists(output_dir_path): + logging.error("Unable to cleanup existing dependency directory: " + output_dir_path) + logging.error("Move it away manually and rerun the script.") + exit(1) + + # Create a fresh directory for output. + create_folder(output_dir_path) + +def main(): + if len(sys.argv) == 2: + react_native_dir = sys.argv[1] + else: + react_native_dir = os.getcwd() + + # Some smoke checks to ensure that we have a valid react-native checkout. + packageJsonFile = os.path.join(react_native_dir, "package.json") + with open(packageJsonFile) as packageJsonText: + packageJson = json.load(packageJsonText) + if(packageJson[u'name'] != u'react-native' and packageJson[u'name'] != u'react-native-macos'): + logging.info("Not a valid RN repo path!") + exit(-1) + + if (not os.path.join(react_native_dir, "ReactAndroid", "build.gradle")): + logging.info("Not a valid RN repo path!") + exit(-1) + + dependency_dir_root = os.path.join(react_native_dir, "android", "dependencies") + dependency_dir_maven = os.path.join(dependency_dir_root, "cross", "cross", "x-none", "maven") + dependency_dir_native = dependency_dir_root + dependency_dir_hermes = os.path.join(dependency_dir_root, "hermes") + dependency_list_file_path = os.path.join(dependency_dir_root, "gradle_dependencies.txt") + log_file_path = os.path.join(react_native_dir, "android", "log_" + time.strftime("%Y%m%d-%H%M%S") + ".txt" ) + + if(not os.path.exists(os.path.join(react_native_dir, "android"))): + os.mkdir(os.path.join(react_native_dir, "android")) + + logging.basicConfig(level = logging.DEBUG, filename = log_file_path) + logging.info("react_native_dir: " + react_native_dir) + logging.info("Maven dependency path: " + dependency_dir_maven) + logging.info("Native dependency path: " + dependency_dir_native) + logging.info("Dependency list file path: " + dependency_list_file_path) + + # Ensure we have an output directory + ensure_output_dir(dependency_dir_root) + + # List gradle dependencies to file. + list_dependencies(react_native_dir, dependency_list_file_path) + + # download dependencies to maven root + parse_and_download_dependencies(dependency_dir_maven, dependency_list_file_path) + + # Extract the native libraries from maven packages + extract_sos(dependency_dir_maven, dependency_dir_native) + + # Copy and extract hermes. + dependency_dir_hermes_android_aar_path = os.path.join(dependency_dir_hermes, "android") + hermes_engine_node_modules_path = os.path.join(react_native_dir, "node_modules", "hermes-engine") + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "android"), dependency_dir_hermes_android_aar_path) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "linux64-bin"), os.path.join(dependency_dir_hermes, "linux64-bin")) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "win64-bin"), os.path.join(dependency_dir_hermes, "win64-bin")) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "osx-bin"), os.path.join(dependency_dir_hermes, "osx-bin")) + shutil.copy(os.path.join(hermes_engine_node_modules_path, "package.json"), dependency_dir_hermes) + + dependency_dir_hermes_android_native_debug = os.path.join(dependency_dir_hermes_android_aar_path, "debug") + dependency_dir_hermes_android_native_release = os.path.join(dependency_dir_hermes_android_aar_path, "release") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_debug, "hermes-debug.aar") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_debug, "hermes-cppruntime-debug.aar") + + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_release, "hermes-release.aar") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_release, "hermes-cppruntime-release.aar") + + # Copy log file into the dependency root folder. + shutil.copy(log_file_path, os.path.join(dependency_dir_root)) + + with open(log_file_path, "r") as fin: + print(fin.read()) + +if __name__ == '__main__': + main() diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index bfd74ba17252fe..aa646a70b9313b 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -510,8 +510,8 @@ SPEC CHECKSUMS: CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: 0ea4559a49682230337df966e735d6cc7760108e - FBLazyVector: f3a2bccaa26e739c3ef011f4ca86c3ca5427eee6 - FBReactNativeSpec: 284873b891962e396668ece89aa3290221b560f6 + FBLazyVector: 3e1c4c346ec478750c07d0f1d89b424d96cac528 + FBReactNativeSpec: 49208bf2f791afd2253440847299776bdcdbc96f Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3 @@ -522,35 +522,35 @@ SPEC CHECKSUMS: glog: 0dc7efada961c0793012970b60faebbd58b0decb OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 RCT-Folly: 2f2111690f1e23490285c059ca53be22fe6d6bee - RCTRequired: 892b1fc61efc4f66a92b9c6ca85e2522e051f0e2 - RCTTypeSafety: 94bdbb3ebfd2fcc54174c5eb66486cbfac50fe60 - React: c6d1cfc7cb81cde55e07be8c1411fcdb14161562 - React-callinvoker: 577cf455f9e762be4e2b03e03fc0b267a2cff771 - React-Core: d8c133ae796db1854204a1f260ef6e3837f1285c - React-CoreModules: 23672f86dd25805b0a9096692b139e26116c1980 - React-cxxreact: 1f21c1a08237692657816d8092f3d1dc6f13fb41 - React-jsi: e42a0922ac3286bbfc1840aebba8e41fdfcc98d7 - React-jsiexecutor: 161f172db05ec4ae77be65940206ba29930355a4 - React-jsinspector: 680bd24100071d26698fef4e9c75cf69db027954 - React-perflogger: 3a28a552bc5c0be0e8cdcf9f2977aea59eba7380 - React-RCTActionSheet: 06144b4bb931c8f217afba1cd620a682cce980fa - React-RCTAnimation: 8b89532952beb474e0d2b3fbe1bdb3e107026551 - React-RCTBlob: c83099e47b7a9c1aeeb584b8696abc9f78adf3f1 - React-RCTImage: 69061c1547f728421a0aa09a2f1147f59c0d873c - React-RCTLinking: 341ac25287553e51b319266245ef03c36169c671 - React-RCTNetwork: 1ab7893ac9d21d03da65ac958271405def8fe43a - React-RCTPushNotification: e5353eb3f501048e032cda7f9491105cc70039a0 - React-RCTSettings: fa2839bad861f0d44c223938658e9e7782074c55 - React-RCTTest: ca048e75c0b296329201ea81b9f14d27ddd41823 - React-RCTText: d2c121533280c59313f002e6575118b877dd40fc - React-RCTVibration: c53993ba40851fc666c350da5269556b1c1470a4 - React-runtimeexecutor: 87ba843187b8bebb4111c8c54f199cd4785d2ee3 + RCTRequired: 6ef1ca4d8dc14cfdd1c37f14eb4137badd10e982 + RCTTypeSafety: 903e3df81eaa3809cd3593f10de14c4bdd29f500 + React: c49df3a16180bd95f195f359dd2e08555147b95d + React-callinvoker: aec8865b89dbb1cd8d6cbe782badf4d7495682c9 + React-Core: 27db1d573718bb6d53fef2f1dc93c1fdb0d5699d + React-CoreModules: 554ae8216e1963fcfc0ba8aa539a69ad0e0e64ab + React-cxxreact: 841ef739ed5009a9a2e034af90fd7c5157a44790 + React-jsi: 4b7f4a5733a77130579aa2b2af3c7963ea5f58c0 + React-jsiexecutor: 56d0bf876000abf04e757f3cbd6795d257466b6d + React-jsinspector: 6ddd209772e5b066824a030da0e81a949c8bc45b + React-perflogger: 112849bd1692d40371bcb528e6cd37f6e97da42e + React-RCTActionSheet: b2bedbbb047c24e34304e5e6332182c81fbde3c4 + React-RCTAnimation: 88a7a4272ba2142484d5310fa7450d2e65e58cea + React-RCTBlob: 19acefd489b5c3493a92c1f5c0e3d9eac8d05e46 + React-RCTImage: 723ec9d61d7f68e6be2e28fb7064d29902c534ac + React-RCTLinking: 2d7559d3c705da2474cd9c47351d029600a1f037 + React-RCTNetwork: 36c561fb46ebe56891a401fa6559fd6eae1fcf33 + React-RCTPushNotification: 993a3510ea377519306a04d69970ebc9867e25e2 + React-RCTSettings: f3e5ffe73ea7831d98b2d0a119102d9ba232774c + React-RCTTest: d56fa23c7ae8c29236cfb2cd7389337c81f6455b + React-RCTText: 627606cbb59d72a924eed4257ebae197b0570757 + React-RCTVibration: b212ea311c7b325cabd4d780cc337cff23d40f63 + React-runtimeexecutor: 04275caf6c4b2128dcbafcfa015def1782d84760 React-TurboModuleCxx-RNW: 12172bdbaaf052406ec571465243fad4b2eb2702 - React-TurboModuleCxx-WinRTPort: 32917c4b48bbe4bb20ce172c40c3cd6315354c3e - ReactCommon: f4a3480837fc8e5c73ffc38c057594b3a1ec7a43 - Yoga: 9defa6fd4bf71cdbba9b1389adb9deed6255f4b1 + React-TurboModuleCxx-WinRTPort: 9fbcbcbfed07bdacde7fde7f85773e705f2a9c1e + ReactCommon: 91962a733289a96984bc8c761b08ed23c0fbe5f8 + Yoga: 9cd54ce33d6f399a07a78172b0c8d7b89a9fc2c5 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: cb260f8f7765c910b68f8267cbd74709f6ae6e54 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.0 diff --git a/packages/rn-tester/js/examples/Pressable/PressableExample.js b/packages/rn-tester/js/examples/Pressable/PressableExample.js index f7a1e4dc33dd2c..6c8764654ea56e 100644 --- a/packages/rn-tester/js/examples/Pressable/PressableExample.js +++ b/packages/rn-tester/js/examples/Pressable/PressableExample.js @@ -99,6 +99,8 @@ function PressableFeedbackEvents() { testID="pressable_feedback_events_button" accessibilityLabel="pressable feedback events" accessibilityRole="button" + onMouseEnter={() => appendEvent('mouseEnter')} // [TODO(macOS GH#774) + onMouseLeave={() => appendEvent('mouseLeave')} // ]TODO(macOS GH#774) onPress={() => appendEvent('press')} onPressIn={() => appendEvent('pressIn')} onPressOut={() => appendEvent('pressOut')} From 61d88c3cfc6eb7293e951155802172d952638d21 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 24 Jun 2022 16:43:04 -0700 Subject: [PATCH 04/22] wip --- Libraries/Components/ScrollView/ScrollView.js | 25 ++++---- Libraries/Lists/FlatList.js | 1 + Libraries/Lists/VirtualizedList.js | 22 ++++++- React/Views/ScrollView/RCTScrollView.m | 33 ++++++---- packages/rn-tester/Podfile.lock | 62 +++++++++---------- 5 files changed, 88 insertions(+), 55 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index fe11526424deec..16ce6e4d99b47e 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1189,23 +1189,24 @@ class ScrollView extends React.Component { this.props.onScrollKeyDown(event); } else { if (Platform.OS === 'macos') { + console.log('ScrollView onScrollKeyDown'); const nativeEvent = event.nativeEvent; const key = nativeEvent.key; const kMinScrollOffset = 10; if (key === 'PAGE_UP') { - this._handleScrollByKeyDown(event, { - x: nativeEvent.contentOffset.x, - y: - nativeEvent.contentOffset.y + - -nativeEvent.layoutMeasurement.height, - }); + // this._handleScrollByKeyDown(event, { + // x: nativeEvent.contentOffset.x, + // y: + // nativeEvent.contentOffset.y + + // -nativeEvent.layoutMeasurement.height, + // }); } else if (key === 'PAGE_DOWN') { - this._handleScrollByKeyDown(event, { - x: nativeEvent.contentOffset.x, - y: - nativeEvent.contentOffset.y + - nativeEvent.layoutMeasurement.height, - }); + // this._handleScrollByKeyDown(event, { + // x: nativeEvent.contentOffset.x, + // y: + // nativeEvent.contentOffset.y + + // nativeEvent.layoutMeasurement.height, + // }); } else if (key === 'LEFT_ARROW') { this._handleScrollByKeyDown(event, { x: diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 14fb9e8fec6ecc..79eeb2d48e95bb 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -644,6 +644,7 @@ class FlatList extends React.PureComponent, void> { return ( { ? this._handleKeyDown : null; } + let validKeysDown = this.props.enableSelectionOnKeyPress + ? ['ArrowUp, ArrowDown'] + : [] const preferredScrollerStyleDidChangeHandler = this.props .onPreferredScrollerStyleDidChange; // ]TODO(macOS GH#774) const onRefresh = props.onRefresh; @@ -1536,6 +1539,7 @@ class VirtualizedList extends React.PureComponent { // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event const event = e.nativeEvent; const key = event.key; + console.log('Virtualized List, handleKeyDown: ' + key); let prevIndex = -1; let newIndex = -1; @@ -2247,11 +2251,27 @@ class CellRenderer extends React.Component< : horizontal ? [styles.row, inversionStyle] : inversionStyle; + + const cellStyleSelected = [ + cellStyle, + {backgroundColor: 'blue', padding: 10}, + ]; const result = !CellRendererComponent ? ( /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * To see the error, delete this comment and run Flow. */ - + { + // if (ev.nativeEvent.ArrowUp && ev.nativeEvent.altKey) { + // console.log('Option+Up'); + // } else if (ev.nativeEvent.ArrowDown && ev.nativeEvent.altKey) { + // console.log('Option+Down'); + // } + // }} + > {element} {itemSeparator} diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index 9ff6b14f66c3d3..ad2fd1f3aecdce 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -1265,11 +1265,11 @@ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode case 36: return @"ENTER"; - case 116: - return @"PAGE_UP"; - - case 121: - return @"PAGE_DOWN"; +// case 116: +// return @"PAGE_UP"; +// +// case 121: +// return @"PAGE_DOWN"; case 123: return @"LEFT_ARROW"; @@ -1289,12 +1289,14 @@ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode - (void)keyDown:(UIEvent*)theEvent { // Don't emit a scroll event if tab was pressed while the scrollview is first responder - if (self == [[self window] firstResponder] && - theEvent.keyCode != 48) { + if (!(self == [[self window] firstResponder] && theEvent.keyCode == 48)) { NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode]; - RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand})); - } else { - [super keyDown:theEvent]; + if (![keyCommand isEqual: @""]) { + RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand})); + } else { + [super keyDown:theEvent]; + } + } // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view, // automatically scroll to make the view visible to make it navigable via keyboard. @@ -1308,9 +1310,18 @@ - (void)keyDown:(UIEvent*)theEvent [[_scrollView documentView] scrollRectToVisible:visibleRect]; } } - } +// } } +//// Always send the event to JS +//- (void)keyDown:(UIEvent*)theEvent +//{ +// NSLog(self == [[self window] firstResponder] ? @"firstResponder YES": @"firstResponder NO"); +// NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode]; +// RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand})); +// [super keyDown:theEvent]; +//} + static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) { switch (scrollerStyle) { case NSScrollerStyleLegacy: diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index cb41aa01ec94c8..c1dc02d8049ad1 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -565,8 +565,8 @@ SPEC CHECKSUMS: boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8 - FBLazyVector: ec10667b9362fe06923f0fb73e524a414ef851d4 - FBReactNativeSpec: 68179f7b35a248ecdcf29be78e722c526fd9a307 + FBLazyVector: 6d825358d6fe8f3dd92b47d2b302e97cbdc095a8 + FBReactNativeSpec: 5cfae2ef61d0cfaa24c7e47c36e600f60330478a Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c @@ -581,39 +581,39 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 24c6da766832002a4a2aac5f79ee0ca50fbe8507 - RCTRequired: 4c555dbcc10d88003d66b483d85c34ac1b23a645 - RCTTypeSafety: 04b19d14bb83654635f514bd4c8bac851bc71d82 - React: 6a51965545e7a3f94e9e0238dfec90d4176c9550 - React-callinvoker: cb2c64e81d9836addc55771ddee20f187d424dd3 + RCTRequired: c72c09e7cfd801e596129a9e832ee42c68318c8b + RCTTypeSafety: 7120a97ad196019bbd85f6064d51cbf372bc200d + React: a7e0a4775754d6ed699a8468f3b62067f8856ed8 + React-callinvoker: ba4db8b140f4d7dc05f3ec7ef78613c1dd9dbe4a React-Codegen: b3fbef96f960cb15fc61250078b0700cfd4cd8a1 - React-Core: 1184601f3a637b24572a93d67672b68b83634076 - React-CoreModules: 4d146d79c1cce9c7075dff6e73249e2a31f56be3 - React-cxxreact: c0918d586a26e1c6dca1efbae983ca48295305aa - React-jsi: 811a2a540615bc4a0f00f35991a20e325e870892 - React-jsiexecutor: 9334187dacf8558d1d420f8e3f2f82291a51e91c - React-jsinspector: 27632c8a86cf672513c16008c41763d7c73d0111 - React-logger: 13d746e63d57ff1e3fdc60ce9b07e0ee3b3980c3 - React-perflogger: e4ae1de0fb2a289f7a094e9c795a5abf05aed31f - React-RCTActionSheet: ad86df97b33200de6375d0d9d5233b0730843dd9 - React-RCTAnimation: 79e019d55791effbc4dfebf7d73bbb2054f0bfb0 - React-RCTBlob: 1e1e71ddc9bd04d87bb25b446a0d984942b6d1b3 - React-RCTImage: 4da3ef0feadb4aea6a2b1775dd3afb3ddc671155 - React-RCTLinking: 07470ca02d8c6e19ddbd561082b3b81868193991 - React-RCTNetwork: 74759ee02eac9f29d40602f5e081ab8681f75ff7 - React-RCTPushNotification: cb60c065c043f9659d26749a017b32b72fa4995f - React-RCTSettings: f22464fbcef918aa24d74691a6de7cd8e86d1bd1 - React-RCTTest: 2e1d0edb7858509af4b2ced1c946edfde5b77b1f - React-RCTText: 63aabff17272ff9fd57018962ae3c1a2ea7c46be - React-RCTVibration: dc976a5b0a2b1bb86d404f95eaba93814349ad8c - React-runtimeexecutor: a39c1c7979d7163ef28089694643e602be807828 + React-Core: 6148f836b55429ccded290434264c5315584ee77 + React-CoreModules: 3f47025d08d3a1c2db81f64301eb254fde76f2bf + React-cxxreact: 20e246ae605cba06173446fce8fbe737b61de846 + React-jsi: 8ac17e6b95201f43802aa1a08dba0e5888bde3a0 + React-jsiexecutor: f4d1c93e0c8c771e5efb03f1fd61ad48ad617a4c + React-jsinspector: 5065a3445ccc25fcee8379f72c35935d51ad8ef7 + React-logger: f9cf41787ad75e0d379b220d8e44f29f58309310 + React-perflogger: 2d7ba254be033fa92342ed150c521f09911ea3c8 + React-RCTActionSheet: 912b2a46480da751b050d3cc84de7e495f582826 + React-RCTAnimation: b180c629443a0fa5643795e1515f6dcdf2016fab + React-RCTBlob: df9821863ad2a89c35714b0dc02d159ab2102739 + React-RCTImage: 3aff719fe6507f93a0205ad4d0fcccb24671e136 + React-RCTLinking: 15c64db2fa719261223114e52ea902ae0a6cb6d7 + React-RCTNetwork: aa95c55643a3b6b32154ebb5d8afcb80316a912c + React-RCTPushNotification: cc0ca9e645644b6d16745aba34e65e5fc4808de6 + React-RCTSettings: 2e7cb703d1f34d856e20f2c1f7b82054f065a1e9 + React-RCTTest: 7f25e3070f60d9a0751788e8f39789d5b9a792dd + React-RCTText: 14fdce3a3a23e9851d5421124b7b0aabc2eeee2a + React-RCTVibration: d1845f0cf516d82d24d103d4ccf50ceab09fbf07 + React-runtimeexecutor: 7c5cdf559c97ced5eb6ac9acba1765323aa78f4a React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a - React-TurboModuleCxx-WinRTPort: 9c108c4b3d1fd878aaa1fe224d1c68516a851aa5 - ReactCommon: 55912b5f910e8679328af50b5df4c7c015b57e3c - ScreenshotManager: db4b25867db6c0d6e5a42037e9c2990e6a558644 + React-TurboModuleCxx-WinRTPort: 24e0d30c937373db5f394494a41d96fc0f0aa036 + ReactCommon: b2973e81f3e1d60cb181772481bc75b0699d0c53 + ScreenshotManager: 1704bd762dccfafbdb1efa1fc0dab28d4f53e0c2 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: 8357e06bb4e46aca2b20b8d9c153ddc70cf36c38 + Yoga: 37f1ce83fba19025ffe97fc63c37eca80e4a1810 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: 1108cd29c1fc117ace6c72b171f31a4c268e5bd2 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 From 276eb275869e1a3cff5f09c8821b8d95e6cb8a2a Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 30 Jun 2022 10:28:22 -0700 Subject: [PATCH 05/22] wip --- Libraries/Lists/FlatList.js | 4 +- Libraries/Lists/VirtualizedList.js | 4 +- packages/rn-tester/Podfile.lock | 58 +++++++++---------- .../js/components/ListExampleShared.js | 27 ++++++++- .../examples/FlatList/BaseFlatListExample.js | 14 ++++- .../js/examples/FlatList/FlatList-basic.js | 3 + 6 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 79eeb2d48e95bb..ee371b3da6241f 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -579,7 +579,7 @@ class FlatList extends React.PureComponent, void> { } _renderer = () => { - const {ListItemComponent, renderItem, columnWrapperStyle} = this.props; + const {ListItemComponent, renderItem, columnWrapperStyle,} = this.props; const numColumns = numColumnsOrDefault(this.props.numColumns); let virtualizedListRenderKey = ListItemComponent @@ -587,6 +587,7 @@ class FlatList extends React.PureComponent, void> { : 'renderItem'; const renderer = (props): React.Node => { + console.log('Flatlist renderer props: ' + props.isSelected); if (ListItemComponent) { // $FlowFixMe[not-a-component] Component isn't valid // $FlowFixMe[incompatible-type-arg] Component isn't valid @@ -594,6 +595,7 @@ class FlatList extends React.PureComponent, void> { return ; } else if (renderItem) { // $FlowFixMe[incompatible-call] + console.log('Flatlist renderItem: ' + props.isSelected); return renderItem(props); } else { return null; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 7cb7b7ac320224..52b93672b8869d 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -2192,6 +2192,7 @@ class CellRenderer extends React.Component< return React.createElement(ListItemComponent, { item, index, + isSelected, separators: this._separators, }); } @@ -2224,6 +2225,7 @@ class CellRenderer extends React.Component< parentProps, } = this.props; const {renderItem, getItemLayout, ListItemComponent} = parentProps; + // console.log('CellRenderer render, isSelected: ' + isSelected); const element = this._renderElement( renderItem, ListItemComponent, @@ -2278,7 +2280,7 @@ class CellRenderer extends React.Component< ) : ( {element} diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index c1dc02d8049ad1..4d00a876a96f78 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -565,8 +565,8 @@ SPEC CHECKSUMS: boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8 - FBLazyVector: 6d825358d6fe8f3dd92b47d2b302e97cbdc095a8 - FBReactNativeSpec: 5cfae2ef61d0cfaa24c7e47c36e600f60330478a + FBLazyVector: 423a09e650707aa73e9f3a6846ced3f62d43337e + FBReactNativeSpec: 3430a649d581bf68ceea4a60a2933470e79a6bd5 Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c @@ -581,37 +581,37 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 24c6da766832002a4a2aac5f79ee0ca50fbe8507 - RCTRequired: c72c09e7cfd801e596129a9e832ee42c68318c8b - RCTTypeSafety: 7120a97ad196019bbd85f6064d51cbf372bc200d - React: a7e0a4775754d6ed699a8468f3b62067f8856ed8 - React-callinvoker: ba4db8b140f4d7dc05f3ec7ef78613c1dd9dbe4a + RCTRequired: fcbb54f2f6745f93133fe70ee1c752dd8d60d827 + RCTTypeSafety: d41d1f20929f3675899bcdd54a30d6cca86d9092 + React: 16a7375a402ae2ed85ded7863047a60b489fad87 + React-callinvoker: 6417164ad9683c7530470242775fc253ff666d7f React-Codegen: b3fbef96f960cb15fc61250078b0700cfd4cd8a1 - React-Core: 6148f836b55429ccded290434264c5315584ee77 - React-CoreModules: 3f47025d08d3a1c2db81f64301eb254fde76f2bf - React-cxxreact: 20e246ae605cba06173446fce8fbe737b61de846 - React-jsi: 8ac17e6b95201f43802aa1a08dba0e5888bde3a0 - React-jsiexecutor: f4d1c93e0c8c771e5efb03f1fd61ad48ad617a4c - React-jsinspector: 5065a3445ccc25fcee8379f72c35935d51ad8ef7 - React-logger: f9cf41787ad75e0d379b220d8e44f29f58309310 - React-perflogger: 2d7ba254be033fa92342ed150c521f09911ea3c8 - React-RCTActionSheet: 912b2a46480da751b050d3cc84de7e495f582826 - React-RCTAnimation: b180c629443a0fa5643795e1515f6dcdf2016fab - React-RCTBlob: df9821863ad2a89c35714b0dc02d159ab2102739 - React-RCTImage: 3aff719fe6507f93a0205ad4d0fcccb24671e136 - React-RCTLinking: 15c64db2fa719261223114e52ea902ae0a6cb6d7 - React-RCTNetwork: aa95c55643a3b6b32154ebb5d8afcb80316a912c - React-RCTPushNotification: cc0ca9e645644b6d16745aba34e65e5fc4808de6 - React-RCTSettings: 2e7cb703d1f34d856e20f2c1f7b82054f065a1e9 - React-RCTTest: 7f25e3070f60d9a0751788e8f39789d5b9a792dd - React-RCTText: 14fdce3a3a23e9851d5421124b7b0aabc2eeee2a - React-RCTVibration: d1845f0cf516d82d24d103d4ccf50ceab09fbf07 - React-runtimeexecutor: 7c5cdf559c97ced5eb6ac9acba1765323aa78f4a + React-Core: d841f4baf693aae1c302d337a6dd64df6cfaaf45 + React-CoreModules: 7b992f9d90fb9524020bb479a4a1958c8d9545cc + React-cxxreact: 07190c3d7c9fbb8b7584231a0e06a967c2626b7c + React-jsi: 1551066338bd49c7f884543e1fe7427d48c2c3ca + React-jsiexecutor: 37542ba5b0f23797f25ea0a0a23db4a01bba9cfd + React-jsinspector: c9d37b4476295eece9925d730bca607e79a55d12 + React-logger: 1a05abff5b5fe2ad1383fae59543840d7e589d01 + React-perflogger: 7b39cca981264c23281d8e52b1564062eeb244d1 + React-RCTActionSheet: 86700e260a947cc5f11ab6791631f8b04eeed0c5 + React-RCTAnimation: 947f46c419a8b3f0764bc0b674e69eb3e417cc0b + React-RCTBlob: 0044c3d510fd845dceb0d2c81f9fa61ae0fa0949 + React-RCTImage: 8ff8b5567a8b56228c155c47483551fe5e10aa55 + React-RCTLinking: a93ef410a21a6368a1c62bacdd48b22302eece08 + React-RCTNetwork: 55d42a5291e883c9b7003f13d72ad07758d13626 + React-RCTPushNotification: 3b1eb0d8589ea472dae29801078d697f8fd9dc4f + React-RCTSettings: 2133f61ec03d595ee7c7bcb97e37ef0f96b5fe7c + React-RCTTest: da36847475b43aa90ab8fabd1659a6f3af1780bc + React-RCTText: 0aac361c404dcd7d1435d35502eefa3bad044763 + React-RCTVibration: e985e6e1a5c35b40c4cc9953b4c77cb50d271c36 + React-runtimeexecutor: 61e23009ca3cdb4077970a6e355720f656f39c3b React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a - React-TurboModuleCxx-WinRTPort: 24e0d30c937373db5f394494a41d96fc0f0aa036 - ReactCommon: b2973e81f3e1d60cb181772481bc75b0699d0c53 + React-TurboModuleCxx-WinRTPort: dba6c16c056c534c076c72d3b45eb0e663cc6759 + ReactCommon: 5c894c4368588a1a86c923997030ea82a179df25 ScreenshotManager: 1704bd762dccfafbdb1efa1fc0dab28d4f53e0c2 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: 37f1ce83fba19025ffe97fc63c37eca80e4a1810 + Yoga: 4f1a9f6b0ec5573ee6273f53953f085bfaec4fce YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: 1108cd29c1fc117ace6c72b171f31a4c268e5bd2 diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 4d25f17137c370..4d33105a84c67b 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -58,27 +58,50 @@ class ItemComponent extends React.PureComponent<{ onShowUnderlay?: () => void, onHideUnderlay?: () => void, textSelectable?: ?boolean, + isSelected: ?Boolean, // TODO ... }> { + + constructor(props) { + super(props); + console.log('Saad Constructor called'); + this.itemRef = React.createRef(); + } _onPress = () => { this.props.onPress(this.props.item.key); }; + render(): React.Node { - const {fixedHeight, horizontal, item, textSelectable} = this.props; + const { + fixedHeight, + horizontal, + item, + textSelectable, + isSelected, + } = this.props; const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; + + console.log('ListExampleShared ListItemComponent: ' + isSelected); + if (this.props.isSelected) { + console.log('I am selected'); + this.itemRef.current.focus(); + } + return ( {!item.noImage && } @@ -87,7 +110,7 @@ class ItemComponent extends React.PureComponent<{ selectable={textSelectable} numberOfLines={horizontal || fixedHeight ? 3 : undefined} > - {item.title} - {item.text} + {item.title} - {'Saad'} - {item.text} diff --git a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js index 6149669d5923f6..08783319eda659 100644 --- a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js +++ b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js @@ -19,6 +19,7 @@ import { } from 'react-native'; import * as React from 'react'; +import {reduce} from '../../../../../Libraries/ReactNative/UIManagerProperties'; const DATA = [ 'Pizza', @@ -34,9 +35,20 @@ const DATA = [ 'Ice Cream', ]; -const Item = ({item, separators}: RenderItemProps) => { +const Item = ({item, selected, separators}: RenderItemProps) => { + const itemRef = React.useRef(null); + console.log('Saad RenderItem'); + + React.useEffect(() => { + console.log('Saad useEffect called'); + if (selected) { + itemRef.current.focus(); + } + }, [selected]); + return ( { separators.highlight(); }} diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 0f59708ac94410..0f4060cf86248d 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -272,6 +272,8 @@ class FlatListExample extends React.PureComponent { ? 'ListItemComponent' : 'renderItem'; + console.log('Saad flatlist, which: ' + flatListPropKey); + return { renderItem: undefined, /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) @@ -287,6 +289,7 @@ class FlatListExample extends React.PureComponent { onShowUnderlay={separators.highlight} onHideUnderlay={separators.unhighlight} textSelectable={this.state.textSelectable} + isSelected={this.state.isSelected} /> ); }, From 02849d2250f1bb31d5f78e3293dbd5a7bb03cb96 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 7 Jul 2022 17:16:07 -0700 Subject: [PATCH 06/22] more wip --- Libraries/Lists/FlatList.js | 14 ++- packages/rn-tester/Podfile | 4 +- packages/rn-tester/Podfile.lock | 86 +++++++++++------ .../RNTesterPods.xcodeproj/project.pbxproj | 94 ++++++++++++++++++- .../js/components/ListExampleShared.js | 6 +- .../js/examples/FlatList/FlatList-basic.js | 23 ++++- 6 files changed, 184 insertions(+), 43 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index ee371b3da6241f..fce2127eb180d2 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -579,7 +579,7 @@ class FlatList extends React.PureComponent, void> { } _renderer = () => { - const {ListItemComponent, renderItem, columnWrapperStyle,} = this.props; + const {ListItemComponent, renderItem, columnWrapperStyle} = this.props; const numColumns = numColumnsOrDefault(this.props.numColumns); let virtualizedListRenderKey = ListItemComponent @@ -587,7 +587,9 @@ class FlatList extends React.PureComponent, void> { : 'renderItem'; const renderer = (props): React.Node => { - console.log('Flatlist renderer props: ' + props.isSelected); + if (props.isSelected) { + console.log('Flatlist renderer props: ' + props.isSelected); + } if (ListItemComponent) { // $FlowFixMe[not-a-component] Component isn't valid // $FlowFixMe[incompatible-type-arg] Component isn't valid @@ -595,7 +597,12 @@ class FlatList extends React.PureComponent, void> { return ; } else if (renderItem) { // $FlowFixMe[incompatible-call] - console.log('Flatlist renderItem: ' + props.isSelected); + if (props.isSelected) { + console.log( + 'Flatlist renderItem: ' + props.index + ', ' + props.isSelected, + ); + } + console.log('Flatlist, props sent to renderItem: ' + JSON.stringify(props, null, 2)); return renderItem(props); } else { return null; @@ -606,6 +613,7 @@ class FlatList extends React.PureComponent, void> { /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.111 was deployed. * To see the error, delete this comment and run Flow. */ + // eslint-disable-next-line react/no-unstable-nested-components [virtualizedListRenderKey]: (info: RenderItemProps) => { if (numColumns > 1) { const {item, index} = info; diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index e7c4645cece9c1..b2d386e9752e7e 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -49,7 +49,7 @@ def pods(options = {}) use_react_native!( path: prefix_path, fabric_enabled: fabric_enabled, - hermes_enabled: ENV['USE_HERMES'] == '1', + hermes_enabled: true, app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", ) @@ -85,7 +85,7 @@ end target 'RNTester-macOS' do platform :osx, '10.15' - pods(:hermes_enabled => false) + pods(:hermes_enabled => true) end target 'RNTester-macOSUnitTests' do diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 4d00a876a96f78..b335e811d94503 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -74,6 +74,7 @@ PODS: - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) + - hermes-engine (0.11.0) - libevent (2.1.12) - OpenSSL-Universal (1.1.1100) - RCT-Folly (2021.06.28.00-v2): @@ -87,6 +88,12 @@ PODS: - DoubleConversion - fmt (~> 6.2.1) - glog + - RCT-Folly/Futures (2021.06.28.00-v2): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - libevent - RCTRequired (1000.0.0) - RCTTypeSafety (1000.0.0): - FBLazyVector (= 1000.0.0) @@ -271,6 +278,17 @@ PODS: - React-logger (= 1000.0.0) - React-perflogger (= 1000.0.0) - React-runtimeexecutor (= 1000.0.0) + - React-hermes (1000.0.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly/Futures (= 2021.06.28.00-v2) + - React-cxxreact (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - React-jsinspector (= 1000.0.0) + - React-perflogger (= 1000.0.0) - React-jsi (1000.0.0): - boost (= 1.76.0) - DoubleConversion @@ -430,6 +448,8 @@ DEPENDENCIES: - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) - glog (from `../../third-party-podspecs/glog.podspec`) + - hermes-engine (~> 0.11.0) + - libevent (~> 2.1.12) - OpenSSL-Universal (= 1.1.1100) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) @@ -442,6 +462,7 @@ DEPENDENCIES: - React-Core/RCTWebSocket (from `../../`) - React-CoreModules (from `../../React/CoreModules`) - React-cxxreact (from `../../ReactCommon/cxxreact`) + - React-hermes (from `../../ReactCommon/hermes`) - React-jsi (from `../../ReactCommon/jsi`) - React-jsiexecutor (from `../../ReactCommon/jsiexecutor`) - React-jsinspector (from `../../ReactCommon/jsinspector`) @@ -479,6 +500,7 @@ SPEC REPOS: - Flipper-RSocket - FlipperKit - fmt + - hermes-engine - libevent - OpenSSL-Universal - SocketRocket @@ -515,6 +537,8 @@ EXTERNAL SOURCES: :path: "../../React/CoreModules" React-cxxreact: :path: "../../ReactCommon/cxxreact" + React-hermes: + :path: "../../ReactCommon/hermes" React-jsi: :path: "../../ReactCommon/jsi" React-jsiexecutor: @@ -565,8 +589,8 @@ SPEC CHECKSUMS: boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8 - FBLazyVector: 423a09e650707aa73e9f3a6846ced3f62d43337e - FBReactNativeSpec: 3430a649d581bf68ceea4a60a2933470e79a6bd5 + FBLazyVector: d644c1c50b0f61a721faedf8598f899e34990bcc + FBReactNativeSpec: 1469616f03afa47cfacdf2f507a064fa5244ff7f Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c @@ -578,42 +602,44 @@ SPEC CHECKSUMS: FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 20113a0d46931b6f096cf8302c68691d75a456ff + hermes-engine: 84e3af1ea01dd7351ac5d8689cbbea1f9903ffc3 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 24c6da766832002a4a2aac5f79ee0ca50fbe8507 - RCTRequired: fcbb54f2f6745f93133fe70ee1c752dd8d60d827 - RCTTypeSafety: d41d1f20929f3675899bcdd54a30d6cca86d9092 - React: 16a7375a402ae2ed85ded7863047a60b489fad87 - React-callinvoker: 6417164ad9683c7530470242775fc253ff666d7f + RCTRequired: d31ab453765e2e38ebcbc43970205a0eb06fa4e1 + RCTTypeSafety: 29900ad454da8b3677716e19eb154c8734c7656e + React: 4803c498d930cd9e1b5408b5f1bf66dd974f3fc5 + React-callinvoker: a514ab93a7d816c3eaa302f45117dbc9ed40db46 React-Codegen: b3fbef96f960cb15fc61250078b0700cfd4cd8a1 - React-Core: d841f4baf693aae1c302d337a6dd64df6cfaaf45 - React-CoreModules: 7b992f9d90fb9524020bb479a4a1958c8d9545cc - React-cxxreact: 07190c3d7c9fbb8b7584231a0e06a967c2626b7c - React-jsi: 1551066338bd49c7f884543e1fe7427d48c2c3ca - React-jsiexecutor: 37542ba5b0f23797f25ea0a0a23db4a01bba9cfd - React-jsinspector: c9d37b4476295eece9925d730bca607e79a55d12 - React-logger: 1a05abff5b5fe2ad1383fae59543840d7e589d01 - React-perflogger: 7b39cca981264c23281d8e52b1564062eeb244d1 - React-RCTActionSheet: 86700e260a947cc5f11ab6791631f8b04eeed0c5 - React-RCTAnimation: 947f46c419a8b3f0764bc0b674e69eb3e417cc0b - React-RCTBlob: 0044c3d510fd845dceb0d2c81f9fa61ae0fa0949 - React-RCTImage: 8ff8b5567a8b56228c155c47483551fe5e10aa55 - React-RCTLinking: a93ef410a21a6368a1c62bacdd48b22302eece08 - React-RCTNetwork: 55d42a5291e883c9b7003f13d72ad07758d13626 - React-RCTPushNotification: 3b1eb0d8589ea472dae29801078d697f8fd9dc4f - React-RCTSettings: 2133f61ec03d595ee7c7bcb97e37ef0f96b5fe7c - React-RCTTest: da36847475b43aa90ab8fabd1659a6f3af1780bc - React-RCTText: 0aac361c404dcd7d1435d35502eefa3bad044763 - React-RCTVibration: e985e6e1a5c35b40c4cc9953b4c77cb50d271c36 - React-runtimeexecutor: 61e23009ca3cdb4077970a6e355720f656f39c3b + React-Core: cebf3a39467a6327eb207bb8cc920771d6e18acd + React-CoreModules: fd58dd14f86426c0483a2f9ea25034b343fb9237 + React-cxxreact: f971333d6e29eb5f2265bcceaf9d13a347c18e7f + React-hermes: cf3e4b9461119ddb258effa6a6436538061eda01 + React-jsi: a3208ae912db1d80b8b423b925a7ac747bcbc6f6 + React-jsiexecutor: 8ca370c2495368a3701856a8430acaee4e1e3dd4 + React-jsinspector: 5af73f6b07c8aa4bf355a865c905b14fa31bbf73 + React-logger: ca122065a3beca69bfec77d1a905e98874fd92ac + React-perflogger: 83c838b1f5f268c448ed24868c0a25d6eee88204 + React-RCTActionSheet: c96d3f86f7a719ec2f62e7370d4fd21eeecc8081 + React-RCTAnimation: a2a374235acb430ce21d9664871a68e6c7b30a8a + React-RCTBlob: d77b8ce1d1212bd0a58c68bcae39d8279493153d + React-RCTImage: 1bbd586019e53ad7c83b988605e827fe9c5788be + React-RCTLinking: 40b057b243747526297c5ada785e956528b6638c + React-RCTNetwork: 789b6abd97e1ff909ab87a1314ac871605ca0f4b + React-RCTPushNotification: 3d1d31f255a1689ad99bd6ac07cee836e84dde3b + React-RCTSettings: 69552c883d2efad1183099ebc4d8ee88e881e93d + React-RCTTest: 61a0ad41d88b8217a5d06d72987aaa0bd63c32aa + React-RCTText: 99dd529f5765f69e6430858d706d798d536f41ff + React-RCTVibration: 88aa6d5060e74d7c47fef121fe3b126d7b41733f + React-runtimeexecutor: dd31c90dec581d259621aa0e37887e36371a1fc4 React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a - React-TurboModuleCxx-WinRTPort: dba6c16c056c534c076c72d3b45eb0e663cc6759 - ReactCommon: 5c894c4368588a1a86c923997030ea82a179df25 + React-TurboModuleCxx-WinRTPort: dcbb92edc2827b77de1e00fbadaf7a819cbac8fc + ReactCommon: f473bf87fe17a2520b9e56fb4ab02d15d3960f6e ScreenshotManager: 1704bd762dccfafbdb1efa1fc0dab28d4f53e0c2 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: 4f1a9f6b0ec5573ee6273f53953f085bfaec4fce + Yoga: 7122d5c50ee2c3e8ca04940a7dbe0d7c3ac64e0b YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 1108cd29c1fc117ace6c72b171f31a4c268e5bd2 +PODFILE CHECKSUM: 4cd07cd0a8a67699649185ab8029b2a7a2d53031 COCOAPODS: 1.11.3 diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index e8c7e594764c36..f4ebcf0eb957da 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -800,6 +800,7 @@ 38C8132424577FB500BFFA62 /* Build JS Bundle */, 51B9D81723C4D5A4002B30E1 /* Start Metro */, 170C222AF602946553790BB0 /* [CP] Copy Pods Resources */, + D8ECE44817075AE5CB748048 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -820,6 +821,7 @@ 9F15346B233AB2C7006DFE44 /* Resources */, 3882C0E12445655100E92FB9 /* Copy Files (1 item) */, 6AFB016C9B7463C62B44F318 /* [CP] Copy Pods Resources */, + D2121FF45BC194E0BEBEDA9E /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -840,6 +842,7 @@ 9F153475233AB2C7006DFE44 /* Frameworks */, 9F153476233AB2C7006DFE44 /* Resources */, 90DA0640700ADDD73F8842BD /* [CP] Copy Pods Resources */, + C3937509D0AFB067AFEA4384 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -861,6 +864,7 @@ E7DB209C22B2BA84005AC45F /* Frameworks */, E7DB209D22B2BA84005AC45F /* Resources */, 66536E8DF39B47627A510DF1 /* [CP] Copy Pods Resources */, + 35BAFBFC5537E92CAD87BFB3 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -881,6 +885,7 @@ E7DB215022B2F332005AC45F /* Frameworks */, E7DB215122B2F332005AC45F /* Resources */, A0F82A7ABB9969342057CBE1 /* [CP] Copy Pods Resources */, + CF02C40D1CCDDFEFBC71DB8C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1112,6 +1117,23 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 35BAFBFC5537E92CAD87BFB3 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 38C8132424577FB500BFFA62 /* Build JS Bundle */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1390,6 +1412,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + C3937509D0AFB067AFEA4384 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; C55342180F72D0025E2DD28C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1412,6 +1451,57 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + CF02C40D1CCDDFEFBC71DB8C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + D2121FF45BC194E0BEBEDA9E /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + D8ECE44817075AE5CB748048 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; D9BE43355C8C29497EED268E /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1881,7 +1971,7 @@ ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1965,7 +2055,7 @@ ENABLE_BITCODE = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 4d33105a84c67b..38d41c091afe45 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -64,7 +64,7 @@ class ItemComponent extends React.PureComponent<{ constructor(props) { super(props); - console.log('Saad Constructor called'); + // console.log('Saad Constructor called'); this.itemRef = React.createRef(); } _onPress = () => { @@ -82,8 +82,8 @@ class ItemComponent extends React.PureComponent<{ const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; - console.log('ListExampleShared ListItemComponent: ' + isSelected); - if (this.props.isSelected) { + if (isSelected) { + console.log('ListExampleShared ListItemComponent: ' + isSelected); console.log('I am selected'); this.itemRef.current.focus(); } diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 0f4060cf86248d..38faf8cfc2b7b4 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -233,7 +233,23 @@ class FlatListExample extends React.PureComponent { refreshing={false} contentContainerStyle={styles.list} viewabilityConfig={VIEWABILITY_CONFIG} - {...flatListItemRendererProps} + renderItem={props => { + const ref = React.createRef(null); + if (props.isSelected) { + ref?.current?.focus(); + } + return ( + + ); + }} + // {...flatListItemRendererProps} /> @@ -267,12 +283,13 @@ class FlatListExample extends React.PureComponent { return onPressAction; }; _onRefresh = () => Alert.alert('onRefresh: nothing to refresh :P'); - _renderItemComponent = () => { + _renderItemComponent = props => { const flatListPropKey = this.state.useFlatListItemComponent ? 'ListItemComponent' : 'renderItem'; - console.log('Saad flatlist, which: ' + flatListPropKey); + console.log('Saad flatlist, which: ' + flatListPropKey); + console.log(JSON.stringify(this.props, null, 2)); return { renderItem: undefined, From d7f28143f2f9c1eb9c548c2fb6936233957fc2e4 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 11 Jul 2022 15:56:21 -0700 Subject: [PATCH 07/22] Home/End/OptionUp/OptionDown work --- Libraries/Lists/FlatList.js | 1 - Libraries/Lists/VirtualizedList.js | 65 +++++++++++++++++-- React/Views/ScrollView/RCTScrollView.m | 34 +++++++--- React/Views/UIView+React.m | 28 +++++--- .../js/components/ListExampleShared.js | 5 +- .../js/examples/FlatList/FlatList-basic.js | 39 +++++------ 6 files changed, 123 insertions(+), 49 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index fce2127eb180d2..09379efff2b42c 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -602,7 +602,6 @@ class FlatList extends React.PureComponent, void> { 'Flatlist renderItem: ' + props.index + ', ' + props.isSelected, ); } - console.log('Flatlist, props sent to renderItem: ' + JSON.stringify(props, null, 2)); return renderItem(props); } else { return null; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 52b93672b8869d..62e6772148b136 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1517,6 +1517,13 @@ class VirtualizedList extends React.PureComponent { return rowAbove; }; + _selectRowAtIndex = rowIndex => { + this.setState(state => { + return {selectedRowIndex: rowIndex}; + }); + return rowIndex; + }; + _selectRowBelowIndex = rowIndex => { if (this.props.getItemCount) { const {data} = this.props; @@ -1576,6 +1583,46 @@ class VirtualizedList extends React.PureComponent { }); } } + } else if (key === 'OPTION_DOWN') { + console.log(this.state.last); + newIndex = this._selectRowAtIndex(this.state.last); + this.ensureItemAtIndexIsVisible(newIndex); + + if (prevIndex !== newIndex) { + const item = getItem(data, newIndex); + if (this.props.onSelectionChanged) { + this.props.onSelectionChanged({ + previousSelection: prevIndex, + newSelection: newIndex, + item: item, + }); + } + } + } else if (key === 'OPTION_UP') { + this.scrollToIndex({ + animated: false, + index: 0, + }); + newIndex = this._selectRowAtIndex(0); + // this.ensureItemAtIndexIsVisible(newIndex); + + if (prevIndex !== newIndex) { + const item = getItem(data, newIndex); + if (this.props.onSelectionChanged) { + this.props.onSelectionChanged({ + previousSelection: prevIndex, + newSelection: newIndex, + item: item, + }); + } + } + } else if (key === 'HOME') { + this.scrollToIndex({ + animated: false, + index: 0, + }); + } else if (key === 'END') { + this.scrollToEnd(); } else if (key === 'ENTER') { if (this.props.onSelectionEntered) { const item = getItem(data, prevIndex); @@ -2121,6 +2168,10 @@ class CellRenderer extends React.Component< leadingItem: this.props.item, }, }; + constructor(props) { + super(props); + this.ref = React.createRef(); + } static getDerivedStateFromProps( props: CellRendererProps, @@ -2254,16 +2305,17 @@ class CellRenderer extends React.Component< ? [styles.row, inversionStyle] : inversionStyle; - const cellStyleSelected = [ - cellStyle, - {backgroundColor: 'blue', padding: 10}, - ]; + // const cellStyleSelected = [ + // cellStyle, + // {backgroundColor: 'blue', padding: 10}, + // ]; const result = !CellRendererComponent ? ( /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * To see the error, delete this comment and run Flow. */ { @@ -2280,7 +2332,8 @@ class CellRenderer extends React.Component< ) : ( {element} diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index ad2fd1f3aecdce..1aeee0b06591e6 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -1258,18 +1258,26 @@ - (void)uiManagerWillPerformMounting:(RCTUIManager *)manager #if TARGET_OS_OSX // [TODO(macOS GH#774) -- (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode +- (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags { + //115 = Home + //119 = End switch (keyCode) { case 36: return @"ENTER"; -// case 116: -// return @"PAGE_UP"; -// -// case 121: -// return @"PAGE_DOWN"; + case 115: + return @"HOME"; + + case 116: + return @"PAGE_UP"; + + case 119: + return @"END"; + + case 121: + return @"PAGE_DOWN"; case 123: return @"LEFT_ARROW"; @@ -1278,10 +1286,18 @@ - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode return @"RIGHT_ARROW"; case 125: - return @"DOWN_ARROW"; + if (modifierFlags & NSEventModifierFlagOption) { + return @"OPTION_DOWN"; + } else { + return @"DOWN_ARROW"; + } case 126: - return @"UP_ARROW"; + if (modifierFlags & NSEventModifierFlagOption) { + return @"OPTION_UP"; + } else { + return @"UP_ARROW"; + } } return @""; } @@ -1290,7 +1306,7 @@ - (void)keyDown:(UIEvent*)theEvent { // Don't emit a scroll event if tab was pressed while the scrollview is first responder if (!(self == [[self window] firstResponder] && theEvent.keyCode == 48)) { - NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode]; + NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode modifierFlags:theEvent.modifierFlags]; if (![keyCommand isEqual: @""]) { RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand})); } else { diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m index 33d53bc4f7b617..6b6173c90b4411 100644 --- a/React/Views/UIView+React.m +++ b/React/Views/UIView+React.m @@ -282,29 +282,37 @@ - (void)setReactIsFocusNeeded:(BOOL)isFocusNeeded - (void)reactFocus { - if (![self becomeFirstResponder]) { - self.reactIsFocusNeeded = YES; - } +#if TARGET_OS_OSX // [TODO(macOS GH#774) + if (![[self window] makeFirstResponder:self]) { +#else + if (![self becomeFirstResponder]) { +#endif //// TODO(macOS GH#774)] + self.reactIsFocusNeeded = YES; + } } - (void)reactFocusIfNeeded { - if (self.reactIsFocusNeeded) { - if ([self becomeFirstResponder]) { - self.reactIsFocusNeeded = NO; - } - } + if (self.reactIsFocusNeeded) { +#if TARGET_OS_OSX // [TODO(macOS GH#774) + if ([[self window] makeFirstResponder:self]) { +#else + if ([self becomeFirstResponder]) { +#endif // TODO(macOS GH#774)] + self.reactIsFocusNeeded = NO; + } + } } - (void)reactBlur { -#if TARGET_OS_OSX // TODO(macOS GH#774) +#if TARGET_OS_OSX // [TODO(macOS GH#774) if (self == [[self window] firstResponder]) { [[self window] makeFirstResponder:[[self window] nextResponder]]; } #else [self resignFirstResponder]; -#endif +#endif // TODO(macOS GH#774)] } #pragma mark - Layout diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 38d41c091afe45..69c23da2e088f7 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -61,7 +61,6 @@ class ItemComponent extends React.PureComponent<{ isSelected: ?Boolean, // TODO ... }> { - constructor(props) { super(props); // console.log('Saad Constructor called'); @@ -84,8 +83,7 @@ class ItemComponent extends React.PureComponent<{ if (isSelected) { console.log('ListExampleShared ListItemComponent: ' + isSelected); - console.log('I am selected'); - this.itemRef.current.focus(); + this.itemRef?.current?.focus(); } return ( @@ -101,7 +99,6 @@ class ItemComponent extends React.PureComponent<{ styles.row, horizontal && {width: HORIZ_WIDTH}, fixedHeight && {height: ITEM_HEIGHT}, - isSelected && {backgroundColor: 'blue'}, ]} > {!item.noImage && } diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 38faf8cfc2b7b4..a001c202a713cf 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -233,23 +233,23 @@ class FlatListExample extends React.PureComponent { refreshing={false} contentContainerStyle={styles.list} viewabilityConfig={VIEWABILITY_CONFIG} - renderItem={props => { - const ref = React.createRef(null); - if (props.isSelected) { - ref?.current?.focus(); - } - return ( - - ); - }} - // {...flatListItemRendererProps} + // renderItem={props => { + // const ref = React.createRef(null); + // if (props.isSelected) { + // ref?.current?.focus(); + // } + // return ( + // + // ); + // }} + {...flatListItemRendererProps} /> @@ -296,7 +296,8 @@ class FlatListExample extends React.PureComponent { /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.111 was deployed. * To see the error, delete this comment and run Flow. */ - [flatListPropKey]: ({item, separators}) => { + [flatListPropKey]: (props) => { + const {item, separators, isSelected} = props; return ( { onShowUnderlay={separators.highlight} onHideUnderlay={separators.unhighlight} textSelectable={this.state.textSelectable} - isSelected={this.state.isSelected} + isSelected={isSelected} /> ); }, From 85fd82b5daafe7a14e7978296186cbb76947d5f4 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Tue, 12 Jul 2022 17:01:24 -0700 Subject: [PATCH 08/22] ensureItemAtIndexIsVisible works --- Libraries/Lists/FlatList.js | 18 ++++----- Libraries/Lists/VirtualizedList.js | 24 ++++++------ packages/rn-tester/Podfile.lock | 60 +++++++++++++++--------------- 3 files changed, 52 insertions(+), 50 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 09379efff2b42c..e7602a0a986288 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -587,21 +587,21 @@ class FlatList extends React.PureComponent, void> { : 'renderItem'; const renderer = (props): React.Node => { - if (props.isSelected) { - console.log('Flatlist renderer props: ' + props.isSelected); - } + // if (props.isSelected) { + // console.log('Flatlist renderer props: ' + props.isSelected); + // } if (ListItemComponent) { // $FlowFixMe[not-a-component] Component isn't valid // $FlowFixMe[incompatible-type-arg] Component isn't valid // $FlowFixMe[incompatible-return] Component isn't valid return ; } else if (renderItem) { - // $FlowFixMe[incompatible-call] - if (props.isSelected) { - console.log( - 'Flatlist renderItem: ' + props.index + ', ' + props.isSelected, - ); - } + // // $FlowFixMe[incompatible-call] + // if (props.isSelected) { + // console.log( + // 'Flatlist renderItem: ' + props.index + ', ' + props.isSelected, + // ); + // } return renderItem(props); } else { return null; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 62e6772148b136..890e98c65bbf44 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -586,9 +586,16 @@ class VirtualizedList extends React.PureComponent { if (frameEnd > visEnd) { const newOffset = Math.min(contentLength, visTop + (frameEnd - visEnd)); + // console.log( + // `ensureItemAtIndexIsVisible, frameEnd: ${frameEnd} > visEnd ${visEnd}, newOffset: ${newOffset}`, + // ); this.scrollToOffset({offset: newOffset}); } else if (frame.offset < visTop) { - const newOffset = Math.max(0, visTop - frame.length); + const newOffset = Math.min(frame.offset, visTop - frame.length); + // console.log( + // `ensureItemAtIndexIsVisible, frame.offset: ${frame.offset} < visTop: ${visTop}, newOffset: ${newOffset}`, + // ); + this.scrollToOffset({offset: newOffset}); } } @@ -1314,8 +1321,8 @@ class VirtualizedList extends React.PureComponent { : null; } let validKeysDown = this.props.enableSelectionOnKeyPress - ? ['ArrowUp, ArrowDown'] - : [] + ? ['ArrowUp, ArrowDown'] + : []; const preferredScrollerStyleDidChangeHandler = this.props .onPreferredScrollerStyleDidChange; // ]TODO(macOS GH#774) const onRefresh = props.onRefresh; @@ -1584,7 +1591,6 @@ class VirtualizedList extends React.PureComponent { } } } else if (key === 'OPTION_DOWN') { - console.log(this.state.last); newIndex = this._selectRowAtIndex(this.state.last); this.ensureItemAtIndexIsVisible(newIndex); @@ -1599,12 +1605,8 @@ class VirtualizedList extends React.PureComponent { } } } else if (key === 'OPTION_UP') { - this.scrollToIndex({ - animated: false, - index: 0, - }); newIndex = this._selectRowAtIndex(0); - // this.ensureItemAtIndexIsVisible(newIndex); + this.ensureItemAtIndexIsVisible(newIndex); if (prevIndex !== newIndex) { const item = getItem(data, newIndex); @@ -1618,11 +1620,11 @@ class VirtualizedList extends React.PureComponent { } } else if (key === 'HOME') { this.scrollToIndex({ - animated: false, + animated: true, index: 0, }); } else if (key === 'END') { - this.scrollToEnd(); + this.scrollToEnd({animated: true}); } else if (key === 'ENTER') { if (this.props.onSelectionEntered) { const item = getItem(data, prevIndex); diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index b335e811d94503..c3d130e3183cb9 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -589,8 +589,8 @@ SPEC CHECKSUMS: boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8 - FBLazyVector: d644c1c50b0f61a721faedf8598f899e34990bcc - FBReactNativeSpec: 1469616f03afa47cfacdf2f507a064fa5244ff7f + FBLazyVector: 5b0e98c296131b98e170a4f07ee486003d73ffb9 + FBReactNativeSpec: 5711a22173edbfedcf7cbaa45a2f0b6f17b732ed Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c @@ -606,38 +606,38 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 24c6da766832002a4a2aac5f79ee0ca50fbe8507 - RCTRequired: d31ab453765e2e38ebcbc43970205a0eb06fa4e1 - RCTTypeSafety: 29900ad454da8b3677716e19eb154c8734c7656e - React: 4803c498d930cd9e1b5408b5f1bf66dd974f3fc5 - React-callinvoker: a514ab93a7d816c3eaa302f45117dbc9ed40db46 + RCTRequired: a33563c90e163a43378dc58ecbcdc2533ea21243 + RCTTypeSafety: bb7a5ce1e71cc7411350126eed63666c6e479210 + React: 91b8dd712d544fb1c3b4de091923bacf40aa9961 + React-callinvoker: 8ceda013de6b6ea6e91cd7e1cba010b81a6407bb React-Codegen: b3fbef96f960cb15fc61250078b0700cfd4cd8a1 - React-Core: cebf3a39467a6327eb207bb8cc920771d6e18acd - React-CoreModules: fd58dd14f86426c0483a2f9ea25034b343fb9237 - React-cxxreact: f971333d6e29eb5f2265bcceaf9d13a347c18e7f - React-hermes: cf3e4b9461119ddb258effa6a6436538061eda01 - React-jsi: a3208ae912db1d80b8b423b925a7ac747bcbc6f6 - React-jsiexecutor: 8ca370c2495368a3701856a8430acaee4e1e3dd4 - React-jsinspector: 5af73f6b07c8aa4bf355a865c905b14fa31bbf73 - React-logger: ca122065a3beca69bfec77d1a905e98874fd92ac - React-perflogger: 83c838b1f5f268c448ed24868c0a25d6eee88204 - React-RCTActionSheet: c96d3f86f7a719ec2f62e7370d4fd21eeecc8081 - React-RCTAnimation: a2a374235acb430ce21d9664871a68e6c7b30a8a - React-RCTBlob: d77b8ce1d1212bd0a58c68bcae39d8279493153d - React-RCTImage: 1bbd586019e53ad7c83b988605e827fe9c5788be - React-RCTLinking: 40b057b243747526297c5ada785e956528b6638c - React-RCTNetwork: 789b6abd97e1ff909ab87a1314ac871605ca0f4b - React-RCTPushNotification: 3d1d31f255a1689ad99bd6ac07cee836e84dde3b - React-RCTSettings: 69552c883d2efad1183099ebc4d8ee88e881e93d - React-RCTTest: 61a0ad41d88b8217a5d06d72987aaa0bd63c32aa - React-RCTText: 99dd529f5765f69e6430858d706d798d536f41ff - React-RCTVibration: 88aa6d5060e74d7c47fef121fe3b126d7b41733f - React-runtimeexecutor: dd31c90dec581d259621aa0e37887e36371a1fc4 + React-Core: 5bfb274b435ee1dfa7d2a85ab3d49c7d65f238b8 + React-CoreModules: f95df6fbde7d0c25c451fc1e1937e37d60a6067b + React-cxxreact: 7b62d4d2df871d3a25dd1bad09936854330f9f4a + React-hermes: 0a661dae626802abf87d6f8106f111333e3ea29e + React-jsi: 5492af5e933653c9981409adb8f4dd07865119d8 + React-jsiexecutor: c0f1fb30cb5bd666b41c1235266e4ff6c5afc022 + React-jsinspector: dfc12affc0e5fe479142adee98cdfb2d2509fc45 + React-logger: 402cfb34873f85a8325181a763a7379c59e4ad3e + React-perflogger: 68c9abeb9f2497baae9232b4bfa55e911f3a8b63 + React-RCTActionSheet: 48fb55c94fe390140d41eaa1b9a0fbc40864df06 + React-RCTAnimation: 2b0759affcfba5343f70456c129d9b0a0cea1391 + React-RCTBlob: 2b339e13a3f9c3ce72499f409aa8c3c1e755e6c1 + React-RCTImage: 33999326f9f6c0c05359b740782ddd5cff244b7d + React-RCTLinking: 0980fff1c667f256adf7cff729d64f47595433e3 + React-RCTNetwork: 94d1db17c9ac9c5590893ce2c8f673e39c079020 + React-RCTPushNotification: edba570bcae0ad5ee97e6c3a58aa4b20dd238757 + React-RCTSettings: 88b80bbe7a30b0511006a0ad51ea00e312d245ba + React-RCTTest: e4f71562e03842b18e4d2d637851f8e01311d322 + React-RCTText: 7b420a5ba9e19324af8b8d1e98fa172552d1f4e4 + React-RCTVibration: a8150a540f97494473081cab6822c4cfc45a51b1 + React-runtimeexecutor: 3570105a50dde3c0b1f2f0fb84ee21b45db67f6d React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a - React-TurboModuleCxx-WinRTPort: dcbb92edc2827b77de1e00fbadaf7a819cbac8fc - ReactCommon: f473bf87fe17a2520b9e56fb4ab02d15d3960f6e + React-TurboModuleCxx-WinRTPort: f98dc89133d44182955d076f3723bc4a0f95f925 + ReactCommon: bbacb646eddbffc44d97743effbbc854cd0aac91 ScreenshotManager: 1704bd762dccfafbdb1efa1fc0dab28d4f53e0c2 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: 7122d5c50ee2c3e8ca04940a7dbe0d7c3ac64e0b + Yoga: 325419999b3249ee927a3ca930463dfc29529782 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: 4cd07cd0a8a67699649185ab8029b2a7a2d53031 From 747ce4d4f672cfa69a4ce44e82cc147a2bf3a214 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 13 Jul 2022 14:11:45 -0700 Subject: [PATCH 09/22] Home/End work --- Libraries/Components/ScrollView/ScrollView.js | 48 ++++--------------- Libraries/Lists/VirtualizedList.js | 5 +- React/Views/ScrollView/RCTScrollView.m | 2 - 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 16ce6e4d99b47e..6dd21023a4f61f 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1194,58 +1194,26 @@ class ScrollView extends React.Component { const key = nativeEvent.key; const kMinScrollOffset = 10; if (key === 'PAGE_UP') { - // this._handleScrollByKeyDown(event, { - // x: nativeEvent.contentOffset.x, - // y: - // nativeEvent.contentOffset.y + - // -nativeEvent.layoutMeasurement.height, - // }); - } else if (key === 'PAGE_DOWN') { - // this._handleScrollByKeyDown(event, { - // x: nativeEvent.contentOffset.x, - // y: - // nativeEvent.contentOffset.y + - // nativeEvent.layoutMeasurement.height, - // }); - } else if (key === 'LEFT_ARROW') { - this._handleScrollByKeyDown(event, { - x: - nativeEvent.contentOffset.x + - -(this.props.horizontalLineScroll !== undefined - ? this.props.horizontalLineScroll - : kMinScrollOffset), - y: nativeEvent.contentOffset.y, - }); - } else if (key === 'RIGHT_ARROW') { - this._handleScrollByKeyDown(event, { - x: - nativeEvent.contentOffset.x + - (this.props.horizontalLineScroll !== undefined - ? this.props.horizontalLineScroll - : kMinScrollOffset), - y: nativeEvent.contentOffset.y, - }); - } else if (key === 'DOWN_ARROW') { this._handleScrollByKeyDown(event, { x: nativeEvent.contentOffset.x, y: nativeEvent.contentOffset.y + - (this.props.verticalLineScroll !== undefined - ? this.props.verticalLineScroll - : kMinScrollOffset), + -nativeEvent.layoutMeasurement.height, }); - } else if (key === 'UP_ARROW') { + } else if (key === 'PAGE_DOWN') { this._handleScrollByKeyDown(event, { x: nativeEvent.contentOffset.x, y: nativeEvent.contentOffset.y + - -(this.props.verticalLineScroll !== undefined - ? this.props.verticalLineScroll - : kMinScrollOffset), + nativeEvent.layoutMeasurement.height, }); + } else if (key === 'HOME') { + this.scrollTo({x: 0, y: 0}); + } else if (key === 'END') { + this.scrollToEnd({animated: true}); } } - } + } }; _handleScrollByKeyDown = (event: ScrollEvent, newOffset) => { diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 890e98c65bbf44..198b8c84e90583 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1619,10 +1619,7 @@ class VirtualizedList extends React.PureComponent { } } } else if (key === 'HOME') { - this.scrollToIndex({ - animated: true, - index: 0, - }); + this._scrollRef.scrollTo({x: 0, y: 0}); } else if (key === 'END') { this.scrollToEnd({animated: true}); } else if (key === 'ENTER') { diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index 1aeee0b06591e6..921290a1c0fe97 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -1260,8 +1260,6 @@ - (void)uiManagerWillPerformMounting:(RCTUIManager *)manager - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags { - //115 = Home - //119 = End switch (keyCode) { case 36: From 9d631f7c3f61babbcba59e091be604563c8bc57c Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 13 Jul 2022 14:32:21 -0700 Subject: [PATCH 10/22] Initial cleanup for PR --- .github/pull.yml | 17 ---------- Libraries/Components/ScrollView/ScrollView.js | 1 - Libraries/Lists/FlatList.js | 11 +------ Libraries/Lists/VirtualizedList.js | 27 +--------------- React/Views/ScrollView/RCTScrollView.m | 32 +++++++------------ packages/rn-tester/Podfile | 4 +-- .../js/components/ListExampleShared.js | 2 +- .../examples/FlatList/BaseFlatListExample.js | 1 - .../js/examples/FlatList/FlatList-basic.js | 16 ---------- 9 files changed, 16 insertions(+), 95 deletions(-) delete mode 100644 .github/pull.yml diff --git a/.github/pull.yml b/.github/pull.yml deleted file mode 100644 index 0232035eb0f013..00000000000000 --- a/.github/pull.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "1" -rules: # Array of rules - - base: master # Required. Target branch - upstream: microsoft:master # Required. Must be in the same fork network. - mergeMethod: squash # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. - mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false - assignees: # Optional - - HeyImChris - - saadnajmi - reviewers: # Optional - - HeyImChris - - saadnajmi - conflictReviewers: # Optional, on merge conflict assign a reviewer - - HeyImChris - - saadnajmi -label: ":arrow_heading_down: pull" # Optional -conflictLabel: "merge-conflict" # Optional, on merge conflict assign a custom label, Default: merge-conflict \ No newline at end of file diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 6dd21023a4f61f..b1350be363b9df 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1189,7 +1189,6 @@ class ScrollView extends React.Component { this.props.onScrollKeyDown(event); } else { if (Platform.OS === 'macos') { - console.log('ScrollView onScrollKeyDown'); const nativeEvent = event.nativeEvent; const key = nativeEvent.key; const kMinScrollOffset = 10; diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index e7602a0a986288..79eeb2d48e95bb 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -587,21 +587,13 @@ class FlatList extends React.PureComponent, void> { : 'renderItem'; const renderer = (props): React.Node => { - // if (props.isSelected) { - // console.log('Flatlist renderer props: ' + props.isSelected); - // } if (ListItemComponent) { // $FlowFixMe[not-a-component] Component isn't valid // $FlowFixMe[incompatible-type-arg] Component isn't valid // $FlowFixMe[incompatible-return] Component isn't valid return ; } else if (renderItem) { - // // $FlowFixMe[incompatible-call] - // if (props.isSelected) { - // console.log( - // 'Flatlist renderItem: ' + props.index + ', ' + props.isSelected, - // ); - // } + // $FlowFixMe[incompatible-call] return renderItem(props); } else { return null; @@ -612,7 +604,6 @@ class FlatList extends React.PureComponent, void> { /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.111 was deployed. * To see the error, delete this comment and run Flow. */ - // eslint-disable-next-line react/no-unstable-nested-components [virtualizedListRenderKey]: (info: RenderItemProps) => { if (numColumns > 1) { const {item, index} = info; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 198b8c84e90583..b84da798220a7c 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -586,16 +586,9 @@ class VirtualizedList extends React.PureComponent { if (frameEnd > visEnd) { const newOffset = Math.min(contentLength, visTop + (frameEnd - visEnd)); - // console.log( - // `ensureItemAtIndexIsVisible, frameEnd: ${frameEnd} > visEnd ${visEnd}, newOffset: ${newOffset}`, - // ); this.scrollToOffset({offset: newOffset}); } else if (frame.offset < visTop) { const newOffset = Math.min(frame.offset, visTop - frame.length); - // console.log( - // `ensureItemAtIndexIsVisible, frame.offset: ${frame.offset} < visTop: ${visTop}, newOffset: ${newOffset}`, - // ); - this.scrollToOffset({offset: newOffset}); } } @@ -1320,9 +1313,6 @@ class VirtualizedList extends React.PureComponent { ? this._handleKeyDown : null; } - let validKeysDown = this.props.enableSelectionOnKeyPress - ? ['ArrowUp, ArrowDown'] - : []; const preferredScrollerStyleDidChangeHandler = this.props .onPreferredScrollerStyleDidChange; // ]TODO(macOS GH#774) const onRefresh = props.onRefresh; @@ -1553,7 +1543,6 @@ class VirtualizedList extends React.PureComponent { // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event const event = e.nativeEvent; const key = event.key; - console.log('Virtualized List, handleKeyDown: ' + key); let prevIndex = -1; let newIndex = -1; @@ -2275,7 +2264,6 @@ class CellRenderer extends React.Component< parentProps, } = this.props; const {renderItem, getItemLayout, ListItemComponent} = parentProps; - // console.log('CellRenderer render, isSelected: ' + isSelected); const element = this._renderElement( renderItem, ListItemComponent, @@ -2312,26 +2300,13 @@ class CellRenderer extends React.Component< /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * To see the error, delete this comment and run Flow. */ - { - // if (ev.nativeEvent.ArrowUp && ev.nativeEvent.altKey) { - // console.log('Option+Up'); - // } else if (ev.nativeEvent.ArrowDown && ev.nativeEvent.altKey) { - // console.log('Option+Down'); - // } - // }} - > + {element} {itemSeparator} ) : ( diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index 921290a1c0fe97..19ec9dca0f8acf 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -1312,30 +1312,20 @@ - (void)keyDown:(UIEvent*)theEvent } } - // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view, - // automatically scroll to make the view visible to make it navigable via keyboard. - if ([theEvent keyCode] == 48) { //tab key - id firstResponder = [[self window] firstResponder]; - if ([firstResponder isKindOfClass:[NSView class]] && - [firstResponder isDescendantOf:[_scrollView documentView]]) { - NSView *view = (NSView*)firstResponder; - NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) : - [view convertRect:view.frame toView:_scrollView.documentView]; - [[_scrollView documentView] scrollRectToVisible:visibleRect]; - } + // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view, + // automatically scroll to make the view visible to make it navigable via keyboard. + if ([theEvent keyCode] == 48) { //tab key + id firstResponder = [[self window] firstResponder]; + if ([firstResponder isKindOfClass:[NSView class]] && + [firstResponder isDescendantOf:[_scrollView documentView]]) { + NSView *view = (NSView*)firstResponder; + NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) : + [view convertRect:view.frame toView:_scrollView.documentView]; + [[_scrollView documentView] scrollRectToVisible:visibleRect]; } -// } + } } -//// Always send the event to JS -//- (void)keyDown:(UIEvent*)theEvent -//{ -// NSLog(self == [[self window] firstResponder] ? @"firstResponder YES": @"firstResponder NO"); -// NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode]; -// RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand})); -// [super keyDown:theEvent]; -//} - static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) { switch (scrollerStyle) { case NSScrollerStyleLegacy: diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index b2d386e9752e7e..65b74e11f9e45b 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -49,7 +49,7 @@ def pods(options = {}) use_react_native!( path: prefix_path, fabric_enabled: fabric_enabled, - hermes_enabled: true, + hermes_enabled: ENV['USE_HERMES'] == '1', app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", ) @@ -85,7 +85,7 @@ end target 'RNTester-macOS' do platform :osx, '10.15' - pods(:hermes_enabled => true) + pods(:hermes_enabled => false) end target 'RNTester-macOSUnitTests' do diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 69c23da2e088f7..34d22a8fe2e65b 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -107,7 +107,7 @@ class ItemComponent extends React.PureComponent<{ selectable={textSelectable} numberOfLines={horizontal || fixedHeight ? 3 : undefined} > - {item.title} - {'Saad'} - {item.text} + {item.title} - {item.text} diff --git a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js index 08783319eda659..03ba3d4f8a9d83 100644 --- a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js +++ b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js @@ -19,7 +19,6 @@ import { } from 'react-native'; import * as React from 'react'; -import {reduce} from '../../../../../Libraries/ReactNative/UIManagerProperties'; const DATA = [ 'Pizza', diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index a001c202a713cf..6a2e8ad06c3eb8 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -233,22 +233,6 @@ class FlatListExample extends React.PureComponent { refreshing={false} contentContainerStyle={styles.list} viewabilityConfig={VIEWABILITY_CONFIG} - // renderItem={props => { - // const ref = React.createRef(null); - // if (props.isSelected) { - // ref?.current?.focus(); - // } - // return ( - // - // ); - // }} {...flatListItemRendererProps} /> From 37c61b4503ddb73cdb10448b27454637c852839c Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 13 Jul 2022 14:38:52 -0700 Subject: [PATCH 11/22] More cleanup --- packages/rn-tester/Podfile | 2 +- packages/rn-tester/Podfile.lock | 90 +++++++----------- .../RNTesterPods.xcodeproj/project.pbxproj | 94 +------------------ 3 files changed, 35 insertions(+), 151 deletions(-) diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 65b74e11f9e45b..e7c4645cece9c1 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -49,7 +49,7 @@ def pods(options = {}) use_react_native!( path: prefix_path, fabric_enabled: fabric_enabled, - hermes_enabled: ENV['USE_HERMES'] == '1', + hermes_enabled: ENV['USE_HERMES'] == '1', app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", ) diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index c3d130e3183cb9..cb41aa01ec94c8 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -74,7 +74,6 @@ PODS: - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - - hermes-engine (0.11.0) - libevent (2.1.12) - OpenSSL-Universal (1.1.1100) - RCT-Folly (2021.06.28.00-v2): @@ -88,12 +87,6 @@ PODS: - DoubleConversion - fmt (~> 6.2.1) - glog - - RCT-Folly/Futures (2021.06.28.00-v2): - - boost - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - libevent - RCTRequired (1000.0.0) - RCTTypeSafety (1000.0.0): - FBLazyVector (= 1000.0.0) @@ -278,17 +271,6 @@ PODS: - React-logger (= 1000.0.0) - React-perflogger (= 1000.0.0) - React-runtimeexecutor (= 1000.0.0) - - React-hermes (1000.0.0): - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.06.28.00-v2) - - RCT-Folly/Futures (= 2021.06.28.00-v2) - - React-cxxreact (= 1000.0.0) - - React-jsi (= 1000.0.0) - - React-jsiexecutor (= 1000.0.0) - - React-jsinspector (= 1000.0.0) - - React-perflogger (= 1000.0.0) - React-jsi (1000.0.0): - boost (= 1.76.0) - DoubleConversion @@ -448,8 +430,6 @@ DEPENDENCIES: - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) - glog (from `../../third-party-podspecs/glog.podspec`) - - hermes-engine (~> 0.11.0) - - libevent (~> 2.1.12) - OpenSSL-Universal (= 1.1.1100) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) @@ -462,7 +442,6 @@ DEPENDENCIES: - React-Core/RCTWebSocket (from `../../`) - React-CoreModules (from `../../React/CoreModules`) - React-cxxreact (from `../../ReactCommon/cxxreact`) - - React-hermes (from `../../ReactCommon/hermes`) - React-jsi (from `../../ReactCommon/jsi`) - React-jsiexecutor (from `../../ReactCommon/jsiexecutor`) - React-jsinspector (from `../../ReactCommon/jsinspector`) @@ -500,7 +479,6 @@ SPEC REPOS: - Flipper-RSocket - FlipperKit - fmt - - hermes-engine - libevent - OpenSSL-Universal - SocketRocket @@ -537,8 +515,6 @@ EXTERNAL SOURCES: :path: "../../React/CoreModules" React-cxxreact: :path: "../../ReactCommon/cxxreact" - React-hermes: - :path: "../../ReactCommon/hermes" React-jsi: :path: "../../ReactCommon/jsi" React-jsiexecutor: @@ -589,8 +565,8 @@ SPEC CHECKSUMS: boost-for-react-native: 8f7c9ecfe357664c072ffbe2432569667cbf1f1b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: ed15e075aa758ac0e4c1f8b830bd4e4d40d669e8 - FBLazyVector: 5b0e98c296131b98e170a4f07ee486003d73ffb9 - FBReactNativeSpec: 5711a22173edbfedcf7cbaa45a2f0b6f17b732ed + FBLazyVector: ec10667b9362fe06923f0fb73e524a414ef851d4 + FBReactNativeSpec: 68179f7b35a248ecdcf29be78e722c526fd9a307 Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c @@ -602,44 +578,42 @@ SPEC CHECKSUMS: FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 20113a0d46931b6f096cf8302c68691d75a456ff - hermes-engine: 84e3af1ea01dd7351ac5d8689cbbea1f9903ffc3 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 24c6da766832002a4a2aac5f79ee0ca50fbe8507 - RCTRequired: a33563c90e163a43378dc58ecbcdc2533ea21243 - RCTTypeSafety: bb7a5ce1e71cc7411350126eed63666c6e479210 - React: 91b8dd712d544fb1c3b4de091923bacf40aa9961 - React-callinvoker: 8ceda013de6b6ea6e91cd7e1cba010b81a6407bb + RCTRequired: 4c555dbcc10d88003d66b483d85c34ac1b23a645 + RCTTypeSafety: 04b19d14bb83654635f514bd4c8bac851bc71d82 + React: 6a51965545e7a3f94e9e0238dfec90d4176c9550 + React-callinvoker: cb2c64e81d9836addc55771ddee20f187d424dd3 React-Codegen: b3fbef96f960cb15fc61250078b0700cfd4cd8a1 - React-Core: 5bfb274b435ee1dfa7d2a85ab3d49c7d65f238b8 - React-CoreModules: f95df6fbde7d0c25c451fc1e1937e37d60a6067b - React-cxxreact: 7b62d4d2df871d3a25dd1bad09936854330f9f4a - React-hermes: 0a661dae626802abf87d6f8106f111333e3ea29e - React-jsi: 5492af5e933653c9981409adb8f4dd07865119d8 - React-jsiexecutor: c0f1fb30cb5bd666b41c1235266e4ff6c5afc022 - React-jsinspector: dfc12affc0e5fe479142adee98cdfb2d2509fc45 - React-logger: 402cfb34873f85a8325181a763a7379c59e4ad3e - React-perflogger: 68c9abeb9f2497baae9232b4bfa55e911f3a8b63 - React-RCTActionSheet: 48fb55c94fe390140d41eaa1b9a0fbc40864df06 - React-RCTAnimation: 2b0759affcfba5343f70456c129d9b0a0cea1391 - React-RCTBlob: 2b339e13a3f9c3ce72499f409aa8c3c1e755e6c1 - React-RCTImage: 33999326f9f6c0c05359b740782ddd5cff244b7d - React-RCTLinking: 0980fff1c667f256adf7cff729d64f47595433e3 - React-RCTNetwork: 94d1db17c9ac9c5590893ce2c8f673e39c079020 - React-RCTPushNotification: edba570bcae0ad5ee97e6c3a58aa4b20dd238757 - React-RCTSettings: 88b80bbe7a30b0511006a0ad51ea00e312d245ba - React-RCTTest: e4f71562e03842b18e4d2d637851f8e01311d322 - React-RCTText: 7b420a5ba9e19324af8b8d1e98fa172552d1f4e4 - React-RCTVibration: a8150a540f97494473081cab6822c4cfc45a51b1 - React-runtimeexecutor: 3570105a50dde3c0b1f2f0fb84ee21b45db67f6d + React-Core: 1184601f3a637b24572a93d67672b68b83634076 + React-CoreModules: 4d146d79c1cce9c7075dff6e73249e2a31f56be3 + React-cxxreact: c0918d586a26e1c6dca1efbae983ca48295305aa + React-jsi: 811a2a540615bc4a0f00f35991a20e325e870892 + React-jsiexecutor: 9334187dacf8558d1d420f8e3f2f82291a51e91c + React-jsinspector: 27632c8a86cf672513c16008c41763d7c73d0111 + React-logger: 13d746e63d57ff1e3fdc60ce9b07e0ee3b3980c3 + React-perflogger: e4ae1de0fb2a289f7a094e9c795a5abf05aed31f + React-RCTActionSheet: ad86df97b33200de6375d0d9d5233b0730843dd9 + React-RCTAnimation: 79e019d55791effbc4dfebf7d73bbb2054f0bfb0 + React-RCTBlob: 1e1e71ddc9bd04d87bb25b446a0d984942b6d1b3 + React-RCTImage: 4da3ef0feadb4aea6a2b1775dd3afb3ddc671155 + React-RCTLinking: 07470ca02d8c6e19ddbd561082b3b81868193991 + React-RCTNetwork: 74759ee02eac9f29d40602f5e081ab8681f75ff7 + React-RCTPushNotification: cb60c065c043f9659d26749a017b32b72fa4995f + React-RCTSettings: f22464fbcef918aa24d74691a6de7cd8e86d1bd1 + React-RCTTest: 2e1d0edb7858509af4b2ced1c946edfde5b77b1f + React-RCTText: 63aabff17272ff9fd57018962ae3c1a2ea7c46be + React-RCTVibration: dc976a5b0a2b1bb86d404f95eaba93814349ad8c + React-runtimeexecutor: a39c1c7979d7163ef28089694643e602be807828 React-TurboModuleCxx-RNW: f2e32cbfced49190a61d66c993a8975de79a158a - React-TurboModuleCxx-WinRTPort: f98dc89133d44182955d076f3723bc4a0f95f925 - ReactCommon: bbacb646eddbffc44d97743effbbc854cd0aac91 - ScreenshotManager: 1704bd762dccfafbdb1efa1fc0dab28d4f53e0c2 + React-TurboModuleCxx-WinRTPort: 9c108c4b3d1fd878aaa1fe224d1c68516a851aa5 + ReactCommon: 55912b5f910e8679328af50b5df4c7c015b57e3c + ScreenshotManager: db4b25867db6c0d6e5a42037e9c2990e6a558644 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: 325419999b3249ee927a3ca930463dfc29529782 + Yoga: 8357e06bb4e46aca2b20b8d9c153ddc70cf36c38 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 4cd07cd0a8a67699649185ab8029b2a7a2d53031 +PODFILE CHECKSUM: 1108cd29c1fc117ace6c72b171f31a4c268e5bd2 -COCOAPODS: 1.11.3 +COCOAPODS: 1.11.2 diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index f4ebcf0eb957da..e8c7e594764c36 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -800,7 +800,6 @@ 38C8132424577FB500BFFA62 /* Build JS Bundle */, 51B9D81723C4D5A4002B30E1 /* Start Metro */, 170C222AF602946553790BB0 /* [CP] Copy Pods Resources */, - D8ECE44817075AE5CB748048 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -821,7 +820,6 @@ 9F15346B233AB2C7006DFE44 /* Resources */, 3882C0E12445655100E92FB9 /* Copy Files (1 item) */, 6AFB016C9B7463C62B44F318 /* [CP] Copy Pods Resources */, - D2121FF45BC194E0BEBEDA9E /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -842,7 +840,6 @@ 9F153475233AB2C7006DFE44 /* Frameworks */, 9F153476233AB2C7006DFE44 /* Resources */, 90DA0640700ADDD73F8842BD /* [CP] Copy Pods Resources */, - C3937509D0AFB067AFEA4384 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -864,7 +861,6 @@ E7DB209C22B2BA84005AC45F /* Frameworks */, E7DB209D22B2BA84005AC45F /* Resources */, 66536E8DF39B47627A510DF1 /* [CP] Copy Pods Resources */, - 35BAFBFC5537E92CAD87BFB3 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -885,7 +881,6 @@ E7DB215022B2F332005AC45F /* Frameworks */, E7DB215122B2F332005AC45F /* Resources */, A0F82A7ABB9969342057CBE1 /* [CP] Copy Pods Resources */, - CF02C40D1CCDDFEFBC71DB8C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1117,23 +1112,6 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 35BAFBFC5537E92CAD87BFB3 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 38C8132424577FB500BFFA62 /* Build JS Bundle */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1412,23 +1390,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - C3937509D0AFB067AFEA4384 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSIntegrationTests/Pods-RNTester-macOSIntegrationTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; C55342180F72D0025E2DD28C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1451,57 +1412,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - CF02C40D1CCDDFEFBC71DB8C /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - D2121FF45BC194E0BEBEDA9E /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - D8ECE44817075AE5CB748048 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester-macOS/Pods-RNTester-macOS-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; D9BE43355C8C29497EED268E /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1971,7 +1881,7 @@ ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -2055,7 +1965,7 @@ ENABLE_BITCODE = NO; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; From f3858869cd1369aa38f2a6c7f9ce6f9cffaa434b Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 13 Jul 2022 16:21:00 -0700 Subject: [PATCH 12/22] More cleanup --- Libraries/Lists/VirtualizedList.js | 8 -------- .../rn-tester/js/components/ListExampleShared.js | 4 +--- .../js/examples/FlatList/BaseFlatListExample.js | 13 +------------ 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index b84da798220a7c..6a4f8873e67f74 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -2156,10 +2156,6 @@ class CellRenderer extends React.Component< leadingItem: this.props.item, }, }; - constructor(props) { - super(props); - this.ref = React.createRef(); - } static getDerivedStateFromProps( props: CellRendererProps, @@ -2292,10 +2288,6 @@ class CellRenderer extends React.Component< ? [styles.row, inversionStyle] : inversionStyle; - // const cellStyleSelected = [ - // cellStyle, - // {backgroundColor: 'blue', padding: 10}, - // ]; const result = !CellRendererComponent ? ( /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 34d22a8fe2e65b..6c3fc118a547a3 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -62,8 +62,7 @@ class ItemComponent extends React.PureComponent<{ ... }> { constructor(props) { - super(props); - // console.log('Saad Constructor called'); + super(props); this.itemRef = React.createRef(); } _onPress = () => { @@ -82,7 +81,6 @@ class ItemComponent extends React.PureComponent<{ const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; if (isSelected) { - console.log('ListExampleShared ListItemComponent: ' + isSelected); this.itemRef?.current?.focus(); } diff --git a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js index 03ba3d4f8a9d83..6149669d5923f6 100644 --- a/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js +++ b/packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js @@ -34,20 +34,9 @@ const DATA = [ 'Ice Cream', ]; -const Item = ({item, selected, separators}: RenderItemProps) => { - const itemRef = React.useRef(null); - console.log('Saad RenderItem'); - - React.useEffect(() => { - console.log('Saad useEffect called'); - if (selected) { - itemRef.current.focus(); - } - }, [selected]); - +const Item = ({item, separators}: RenderItemProps) => { return ( { separators.highlight(); }} From 8fc9621b385083c0e9cab4545c15e424c4a3ba01 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 14 Jul 2022 11:50:53 -0700 Subject: [PATCH 13/22] Make it a real prop --- Libraries/Lists/FlatList.js | 1 - packages/rn-tester/js/examples/FlatList/FlatList-basic.js | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 79eeb2d48e95bb..14fb9e8fec6ecc 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -644,7 +644,6 @@ class FlatList extends React.PureComponent, void> { return ( { this.state.useFlatListItemComponent, this._setBooleanValue('useFlatListItemComponent'), )} + {/* [TODO(macOS GH#774) */} + {renderSmallSwitchOption( + 'Keyboard Navigation', + this.state.enableSelectionOnKeyPress, + this._setBooleanValue('enableSelectionOnKeyPress'), + )} + {/* TODO(macOS GH#774)] */} {Platform.OS === 'android' && ( { } From b11f135d9597a1e342e4e2da8166615e0953c37f Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 14 Jul 2022 19:00:35 -0700 Subject: [PATCH 14/22] No need for client code --- Libraries/Lists/VirtualizedList.js | 20 ++++++++++++++++++- .../js/components/ListExampleShared.js | 20 +------------------ .../js/examples/FlatList/FlatList-basic.js | 3 --- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 6a4f8873e67f74..a38825e19a6f62 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -2157,6 +2157,11 @@ class CellRenderer extends React.Component< }, }; + constructor(props) { + super(props); + this.ref = React.createRef(); + } + static getDerivedStateFromProps( props: CellRendererProps, prevState: CellRendererState, @@ -2203,6 +2208,12 @@ class CellRenderer extends React.Component< this.props.onUnmount(this.props.cellKey); } + // [TODO(macOS GH#774) + componentDidUpdate() { + if (this.props.isSelected) { + this.ref?.current.focus(); + } + } // TODO(macOS GH#774)] _renderElement( renderItem, ListItemComponent, @@ -2288,16 +2299,22 @@ class CellRenderer extends React.Component< ? [styles.row, inversionStyle] : inversionStyle; + // [TODO(macOS GH#774)] const result = !CellRendererComponent ? ( /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * To see the error, delete this comment and run Flow. */ - + {element} {itemSeparator} ) : ( ); + // TODO(macOS GH#774)] return ( diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 6c3fc118a547a3..4d25f17137c370 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -58,39 +58,21 @@ class ItemComponent extends React.PureComponent<{ onShowUnderlay?: () => void, onHideUnderlay?: () => void, textSelectable?: ?boolean, - isSelected: ?Boolean, // TODO ... }> { - constructor(props) { - super(props); - this.itemRef = React.createRef(); - } _onPress = () => { this.props.onPress(this.props.item.key); }; - render(): React.Node { - const { - fixedHeight, - horizontal, - item, - textSelectable, - isSelected, - } = this.props; + const {fixedHeight, horizontal, item, textSelectable} = this.props; const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; - - if (isSelected) { - this.itemRef?.current?.focus(); - } - return ( { ? 'ListItemComponent' : 'renderItem'; - console.log('Saad flatlist, which: ' + flatListPropKey); - console.log(JSON.stringify(this.props, null, 2)); - return { renderItem: undefined, /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) From a089eda7db83284f2831025a3359e1986e93aa31 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Sat, 16 Jul 2022 20:27:35 -0700 Subject: [PATCH 15/22] Don't move keyboard focus with selection --- Libraries/Lists/VirtualizedList.js | 32 ++++++------------- .../js/components/ListExampleShared.js | 20 ++++++++++-- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index a38825e19a6f62..9e1b2b443b05ed 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -884,7 +884,13 @@ class VirtualizedList extends React.PureComponent { index={ii} inversionStyle={inversionStyle} item={item} - isSelected={this.state.selectedRowIndex === ii ? true : false} // TODO(macOS GH#774) + // [TODO(macOS GH#774) + isSelected={ + this.props.enableSelectionOnKeyPress && + this.state.selectedRowIndex === ii + ? true + : false + } // TODO(macOS GH#774)] key={key} prevCellKey={prevCellKey} onUpdateSeparators={this._onUpdateSeparators} @@ -1330,10 +1336,10 @@ class VirtualizedList extends React.PureComponent { // $FlowFixMe[prop-missing] Invalid prop usage =0.89.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.89 was deployed. * To see the error, delete this comment and run Flow. */ - + {element} {itemSeparator} ) : ( {!item.noImage && } @@ -355,6 +363,14 @@ const styles = StyleSheet.create({ text: { flex: 1, }, + // TODO + selectedItem: { + backgroundColor: PlatformColor('selectedControlColor'), + }, + selectedItemText: { + color: PlatformColor('selectedControlTextColor'), + }, + // TODO }); module.exports = { From f4ccfdca23c640a812f4ee175c8df88f3c12ccf2 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Sat, 16 Jul 2022 20:29:18 -0700 Subject: [PATCH 16/22] Update tags --- packages/rn-tester/js/components/ListExampleShared.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 5a061778e6083d..f7e65d6f1145bb 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -363,14 +363,14 @@ const styles = StyleSheet.create({ text: { flex: 1, }, - // TODO + // [TODO(macOS GH#774) selectedItem: { backgroundColor: PlatformColor('selectedControlColor'), }, selectedItemText: { color: PlatformColor('selectedControlTextColor'), }, - // TODO + // [TODO(macOS GH#774)] }); module.exports = { From 4453e7569ae3bec631c106029aae53762ab265bb Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Sun, 17 Jul 2022 14:30:24 -0700 Subject: [PATCH 17/22] Fix flow errors --- Libraries/Lists/VirtualizedList.js | 2 +- packages/rn-tester/js/components/ListExampleShared.js | 4 +++- packages/rn-tester/js/examples/FlatList/FlatList-basic.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 9e1b2b443b05ed..d92dbfd0b8f640 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1614,7 +1614,7 @@ class VirtualizedList extends React.PureComponent { } } } else if (key === 'HOME') { - this._scrollRef.scrollTo({x: 0, y: 0}); + this.scrollToOffset({animated: true, offset: 0}); } else if (key === 'END') { this.scrollToEnd({animated: true}); } else if (key === 'ENTER') { diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index f7e65d6f1145bb..2d109726b3c927 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -59,13 +59,15 @@ class ItemComponent extends React.PureComponent<{ onShowUnderlay?: () => void, onHideUnderlay?: () => void, textSelectable?: ?boolean, + isSelected?: ?Boolean, // TODO(macOS GH#774) ... }> { _onPress = () => { this.props.onPress(this.props.item.key); }; render(): React.Node { - const { // [TODO(macOS GH#774) + // [TODO(macOS GH#774) + const { fixedHeight, horizontal, item, diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 2fb730289232f0..8465281b7999b9 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -63,6 +63,7 @@ type State = {| fadingEdgeLength: number, onPressDisabled: boolean, textSelectable: boolean, + enableSelectionOnKeyPress: boolean, // TODO(macOS GH#774)] |}; class FlatListExample extends React.PureComponent { @@ -80,6 +81,7 @@ class FlatListExample extends React.PureComponent { fadingEdgeLength: 0, onPressDisabled: false, textSelectable: true, + enableSelectionOnKeyPress: false, // TODO(macOS GH#774) }; _onChangeFilterText = filterText => { From ae04c16d43827afc1da100eb373c0d79157d0314 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 18 Jul 2022 17:27:58 -0700 Subject: [PATCH 18/22] Update colors, make ScrollView focusable --- Libraries/Lists/VirtualizedList.js | 17 ++++++++++------- .../js/components/ListExampleShared.js | 6 ++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index d92dbfd0b8f640..760dfc6e57f874 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -884,8 +884,7 @@ class VirtualizedList extends React.PureComponent { index={ii} inversionStyle={inversionStyle} item={item} - // [TODO(macOS GH#774) - isSelected={ + isSelected={ // [TODO(macOS GH#774) this.props.enableSelectionOnKeyPress && this.state.selectedRowIndex === ii ? true @@ -1336,7 +1335,11 @@ class VirtualizedList extends React.PureComponent { // $FlowFixMe[prop-missing] Invalid prop usage { // $FlowFixMe Invalid prop usage ); } diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 2d109726b3c927..14a49dec7dada3 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -367,10 +367,12 @@ const styles = StyleSheet.create({ }, // [TODO(macOS GH#774) selectedItem: { - backgroundColor: PlatformColor('selectedControlColor'), + backgroundColor: PlatformColor('selectedContentBackgroundColor'), }, selectedItemText: { - color: PlatformColor('selectedControlTextColor'), + // This was the closest UI Element color that looked right... + // https://developer.apple.com/documentation/appkit/nscolor/ui_element_colors + color: PlatformColor('selectedMenuItemTextColor'), }, // [TODO(macOS GH#774)] }); From d4bdb686565d1e86365e061d4eb05d77d892c1fc Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 18 Jul 2022 17:33:38 -0700 Subject: [PATCH 19/22] prettier --- Libraries/Components/ScrollView/ScrollView.js | 2 +- Libraries/Lists/VirtualizedList.js | 3 ++- packages/rn-tester/js/examples/FlatList/FlatList-basic.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index b1350be363b9df..c92d52814c21ad 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1212,7 +1212,7 @@ class ScrollView extends React.Component { this.scrollToEnd({animated: true}); } } - } + } }; _handleScrollByKeyDown = (event: ScrollEvent, newOffset) => { diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 760dfc6e57f874..db3af25b246b63 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -884,7 +884,8 @@ class VirtualizedList extends React.PureComponent { index={ii} inversionStyle={inversionStyle} item={item} - isSelected={ // [TODO(macOS GH#774) + // [TODO(macOS GH#774) + isSelected={ this.props.enableSelectionOnKeyPress && this.state.selectedRowIndex === ii ? true diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 8465281b7999b9..ecfbdf2025ba66 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -287,8 +287,8 @@ class FlatListExample extends React.PureComponent { /* $FlowFixMe[invalid-computed-prop] (>=0.111.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.111 was deployed. * To see the error, delete this comment and run Flow. */ - [flatListPropKey]: (props) => { - const {item, separators, isSelected} = props; + [flatListPropKey]: props => { + const {item, separators, isSelected} = props; // TODO(macOS GH#774) return ( { onShowUnderlay={separators.highlight} onHideUnderlay={separators.unhighlight} textSelectable={this.state.textSelectable} - isSelected={isSelected} + isSelected={isSelected} // TODO(macOS GH#774) /> ); }, From 34d51e165348e567223dd4c6e6a93d8f079b850c Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 18 Jul 2022 17:35:43 -0700 Subject: [PATCH 20/22] undo change --- packages/rn-tester/js/examples/FlatList/FlatList-basic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index ecfbdf2025ba66..a9dcd074cbf642 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -277,7 +277,7 @@ class FlatListExample extends React.PureComponent { return onPressAction; }; _onRefresh = () => Alert.alert('onRefresh: nothing to refresh :P'); - _renderItemComponent = props => { + _renderItemComponent = () => { const flatListPropKey = this.state.useFlatListItemComponent ? 'ListItemComponent' : 'renderItem'; From 010db4e9c1103005096bb98496d8433eda7485f6 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Tue, 19 Jul 2022 10:32:29 -0700 Subject: [PATCH 21/22] Fix flow errors --- Libraries/Lists/VirtualizedList.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index db3af25b246b63..0995ee1ef57048 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1337,9 +1337,7 @@ class VirtualizedList extends React.PureComponent { { // $FlowFixMe Invalid prop usage Date: Tue, 19 Jul 2022 13:15:28 -0700 Subject: [PATCH 22/22] Clean up code + handle page up/down with new prop --- Libraries/Lists/VirtualizedList.js | 118 +++++++++++++---------------- 1 file changed, 53 insertions(+), 65 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 0995ee1ef57048..d9a93d013da9bf 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1337,7 +1337,7 @@ class VirtualizedList extends React.PureComponent { { // $FlowFixMe Invalid prop usage { } }; - _handleKeyDown = (e: ScrollEvent) => { + _handleKeyDown = (event: ScrollEvent) => { if (this.props.onScrollKeyDown) { - this.props.onScrollKeyDown(e); + this.props.onScrollKeyDown(event); } else { if (Platform.OS === 'macos') { // $FlowFixMe Cannot get e.nativeEvent because property nativeEvent is missing in Event - const event = e.nativeEvent; - const key = event.key; + const nativeEvent = event.nativeEvent; + const key = nativeEvent.key; let prevIndex = -1; let newIndex = -1; @@ -1558,78 +1558,66 @@ class VirtualizedList extends React.PureComponent { prevIndex = this.state.selectedRowIndex; } - const {data, getItem} = this.props; - if (key === 'DOWN_ARROW') { - newIndex = this._selectRowBelowIndex(prevIndex); - this.ensureItemAtIndexIsVisible(newIndex); - - if (prevIndex !== newIndex) { - const item = getItem(data, newIndex); - if (this.props.onSelectionChanged) { - this.props.onSelectionChanged({ - previousSelection: prevIndex, - newSelection: newIndex, - item: item, - }); - } - } - } else if (key === 'UP_ARROW') { + // const {data, getItem} = this.props; + if (key === 'UP_ARROW') { newIndex = this._selectRowAboveIndex(prevIndex); - this.ensureItemAtIndexIsVisible(newIndex); - - if (prevIndex !== newIndex) { - const item = getItem(data, newIndex); - if (this.props.onSelectionChanged) { - this.props.onSelectionChanged({ - previousSelection: prevIndex, - newSelection: newIndex, - item: item, - }); - } - } - } else if (key === 'OPTION_DOWN') { - newIndex = this._selectRowAtIndex(this.state.last); - this.ensureItemAtIndexIsVisible(newIndex); - - if (prevIndex !== newIndex) { - const item = getItem(data, newIndex); - if (this.props.onSelectionChanged) { - this.props.onSelectionChanged({ - previousSelection: prevIndex, - newSelection: newIndex, - item: item, - }); + this._handleSelectionChange(prevIndex, newIndex); + } else if (key === 'DOWN_ARROW') { + newIndex = this._selectRowBelowIndex(prevIndex); + this._handleSelectionChange(prevIndex, newIndex); + } else if (key === 'ENTER') { + if (this.props.onSelectionEntered) { + const item = this.props.getItem(this.props.data, prevIndex); + if (this.props.onSelectionEntered) { + this.props.onSelectionEntered(item); } } } else if (key === 'OPTION_UP') { newIndex = this._selectRowAtIndex(0); - this.ensureItemAtIndexIsVisible(newIndex); - - if (prevIndex !== newIndex) { - const item = getItem(data, newIndex); - if (this.props.onSelectionChanged) { - this.props.onSelectionChanged({ - previousSelection: prevIndex, - newSelection: newIndex, - item: item, - }); - } - } + this._handleSelectionChange(prevIndex, newIndex); + } else if (key === 'OPTION_DOWN') { + newIndex = this._selectRowAtIndex(this.state.last); + this._handleSelectionChange(prevIndex, newIndex); + } else if (key === 'PAGE_UP') { + const maxY = + event.nativeEvent.contentSize.height - + event.nativeEvent.layoutMeasurement.height; + const newOffset = Math.min( + maxY, + nativeEvent.contentOffset.y + -nativeEvent.layoutMeasurement.height, + ); + this.scrollToOffset({animated: true, offset: newOffset}); + } else if (key === 'PAGE_DOWN') { + const maxY = + event.nativeEvent.contentSize.height - + event.nativeEvent.layoutMeasurement.height; + const newOffset = Math.min( + maxY, + nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height, + ); + this.scrollToOffset({animated: true, offset: newOffset}); } else if (key === 'HOME') { this.scrollToOffset({animated: true, offset: 0}); } else if (key === 'END') { this.scrollToEnd({animated: true}); - } else if (key === 'ENTER') { - if (this.props.onSelectionEntered) { - const item = getItem(data, prevIndex); - if (this.props.onSelectionEntered) { - this.props.onSelectionEntered(item); - } - } } } } }; + + _handleSelectionChange = (prevIndex, newIndex) => { + this.ensureItemAtIndexIsVisible(newIndex); + if (prevIndex !== newIndex) { + const item = this.props.getItem(this.props.data, newIndex); + if (this.props.onSelectionChanged) { + this.props.onSelectionChanged({ + previousSelection: prevIndex, + newSelection: newIndex, + item: item, + }); + } + } + }; // ]TODO(macOS GH#774) _renderDebugOverlay() {