Skip to content

Remove remaining need for fork of RN for win32 JS #3811

New issue

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

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

Already on GitHub? Sign in to your account

Merged
4 commits merged into from
Dec 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Remove remaining need for fork of RN for win32 JS",
"packageName": "@office-iss/react-native-win32",
"email": "acoates@microsoft.com",
"commit": "b17624cd44d682c73db5ae17a3d10c8bed07c5f8",
"date": "2019-12-20T19:19:05.418Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Fix RNTester bundle (#2728)",
"packageName": "react-native-windows",
"email": "acoates@microsoft.com",
"commit": "65167fb5e52f042879d00891e89ed951bdda84bc",
"date": "2019-12-20T23:20:03.026Z"
}
8 changes: 4 additions & 4 deletions packages/react-native-win32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"lint": "just-scripts eslint",
"lint:fix": "eslint ./**/*.js ./**/*.ts? --fix",
"watch": "tsc -w",
"bundle": "just-scripts prepareBundle && react-native bundle --platform win32 --entry-file RNTester.js --bundle-output dist/win32/dev/index.win32.bundle --assets-dest dist/win32/dev",
"run-win32": "rex-win32 --bundle RNTester.win32 --component RNTesterApp --basePath ./dist/win32/dev",
"run-win32-devmain": "rex-win32 --bundle RNTester.win32 --component RNTesterApp --basePath ./dist/win32/dev --useDevMain",
"run-win32-dev-web": "rex-win32 --bundle RNTester.win32 --component RNTesterApp --basePath ./dist/win32/dev --useWebDebugger"
"bundle": "just-scripts prepareBundle && react-native bundle --platform win32 --entry-file RNTester.js --bundle-output dist/win32/dev/RNTester.bundle --assets-dest dist/win32/dev",
"run-win32": "rex-win32 --bundle RNTester --component RNTesterApp --basePath ./dist/win32/dev",
"run-win32-devmain": "rex-win32 --bundle RNTester --component RNTesterApp --basePath ./dist/win32/dev --useDevMain",
"run-win32-dev-web": "rex-win32 --bundle RNTester --component RNTesterApp --basePath ./dist/win32/dev --useWebDebugger"
},
"dependencies": {
"@babel/runtime": "^7.4.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* @format
* @flow strict-local
*/

'use strict';

const Platform = require('../../Utilities/Platform');
const UIManager = require('../../ReactNative/UIManager');

let currentlyFocusedID: ?number = null;
const inputs = new Set();

/**
* Returns the ID of the currently focused text field, if one exists
* If no text field is focused it returns null
*/
function currentlyFocusedField(): ?number {
return currentlyFocusedID;
}

/**
* @param {number} TextInputID id of the text field to focus
* Focuses the specified text field
* noop if the text field was already focused
*/
function focusTextInput(textFieldID: ?number) {
if (currentlyFocusedID !== textFieldID && textFieldID !== null) {
currentlyFocusedID = textFieldID;
if (Platform.OS === 'ios') {
UIManager.focus(textFieldID);
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
textFieldID,
UIManager.getViewManagerConfig('AndroidTextInput').Commands
.focusTextInput,
null,
);
// [Win32
} else if (Platform.OS === 'win32') {
UIManager.dispatchViewManagerCommand(
textFieldID,
UIManager.RCTView.Commands.focus,
null,
);
}
// Win32]
}
}

/**
* @param {number} textFieldID id of the text field to unfocus
* Unfocuses the specified text field
* noop if it wasn't focused
*/
function blurTextInput(textFieldID: ?number) {
if (currentlyFocusedID === textFieldID && textFieldID !== null) {
currentlyFocusedID = null;
if (Platform.OS === 'ios') {
UIManager.blur(textFieldID);
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
textFieldID,
UIManager.getViewManagerConfig('AndroidTextInput').Commands
.blurTextInput,
null,
);
// [Win32
} else if (Platform.OS === 'win32') {
UIManager.dispatchViewManagerCommand(
textFieldID,
UIManager.RCTView.Commands.blur,
null,
);
}
// Win32]
}
}

function registerInput(textFieldID: number) {
inputs.add(textFieldID);
}

function unregisterInput(textFieldID: number) {
inputs.delete(textFieldID);
}

function isTextInput(textFieldID: number) {
return inputs.has(textFieldID);
}

module.exports = {
currentlyFocusedField,
focusTextInput,
blurTextInput,
registerInput,
unregisterInput,
isTextInput,
};
Loading