merge master
This commit is contained in:
Коммит
1b12e2caaa
|
@ -0,0 +1,164 @@
|
|||
// Used to publish this fork of react-native
|
||||
// Publish it as an attached tar asset to the GitHub release for general consumption, since we can't publish this to the npmjs npm feed
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const execSync = require("child_process").execSync;
|
||||
|
||||
function exec(command) {
|
||||
try {
|
||||
console.log(`Running command: ${command}`);
|
||||
return execSync(command, {
|
||||
stdio: "inherit"
|
||||
});
|
||||
} catch (err) {
|
||||
process.exitCode = 1;
|
||||
console.log(`Failure running: ${command}`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function doPublish() {
|
||||
const publishBranchName = process.env.publishBranchName;
|
||||
|
||||
const tempPublishBranch = `publish-${Date.now()}`;
|
||||
|
||||
const pkgJsonPath = path.resolve(__dirname, "../package.json");
|
||||
let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
||||
|
||||
let releaseVersion = pkgJson.version;
|
||||
|
||||
const versionGroups = /(.*-microsoft\.)([0-9]*)/.exec(releaseVersion);
|
||||
if (versionGroups) {
|
||||
releaseVersion = versionGroups[1] + (parseInt(versionGroups[2]) + 1);
|
||||
} else {
|
||||
if (releaseVersion.indexOf("-") === -1) {
|
||||
releaseVersion = releaseVersion + "-microsoft.0";
|
||||
} else {
|
||||
console.log("Invalid version to publish");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
pkgJson.version = releaseVersion;
|
||||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
||||
console.log(`Updating package.json to version ${releaseVersion}`);
|
||||
|
||||
exec(`git checkout -b ${tempPublishBranch}`);
|
||||
|
||||
exec(`git add ${pkgJsonPath}`);
|
||||
exec(`git commit -m "Applying package update to ${releaseVersion}`);
|
||||
exec(`git tag v${releaseVersion}`);
|
||||
exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`);
|
||||
exec(`git push origin tag v${releaseVersion}`);
|
||||
|
||||
// -------- Generating Android Artifacts with JavaDoc
|
||||
exec("gradlew installArchives");
|
||||
|
||||
// undo uncommenting javadoc setting
|
||||
exec("git checkout ReactAndroid/gradle.properties");
|
||||
|
||||
// Configure npm to publish to internal feed
|
||||
const npmrcPath = path.resolve(__dirname, "../.npmrc");
|
||||
const npmrcContents = `registry=https:${
|
||||
process.env.publishnpmfeed
|
||||
}/registry/\nalways-auth=true`;
|
||||
console.log(`Creating ${npmrcPath} for publishing:`);
|
||||
console.log(npmrcContents);
|
||||
fs.writeFileSync(npmrcPath, npmrcContents);
|
||||
|
||||
exec(`npm publish`);
|
||||
exec(`del ${npmrcPath}`);
|
||||
|
||||
// Push tar to GitHub releases
|
||||
exec(`npm pack`);
|
||||
|
||||
const npmTarPath = path.resolve(
|
||||
__dirname,
|
||||
`../react-native-${releaseVersion}.tgz`
|
||||
);
|
||||
const assetUpdateUrl = `https://uploads.github.com/repos/Microsoft/react-native/releases/{id}/assets?name=react-native-${releaseVersion}.tgz`;
|
||||
const authHeader =
|
||||
"Basic " + new Buffer(":" + process.env.githubToken).toString("base64");
|
||||
const userAgent = "Microsoft-React-Native-Release-Agent";
|
||||
|
||||
let uploadReleaseAssetUrl = "";
|
||||
exec("npm install request@^2.69.0 --no-save");
|
||||
|
||||
const request = require("request");
|
||||
|
||||
const uploadTarBallToRelease = function() {
|
||||
request.post(
|
||||
{
|
||||
url: uploadReleaseAssetUrl,
|
||||
headers: {
|
||||
"User-Agent": userAgent,
|
||||
Authorization: authHeader,
|
||||
"Content-Type": "application/octet-stream"
|
||||
},
|
||||
formData: {
|
||||
file: fs.createReadStream(npmTarPath)
|
||||
}
|
||||
},
|
||||
function(err, res, body) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exitCode = 1;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var formattedResponse = JSON.parse(body);
|
||||
|
||||
if (formattedResponse.errors) {
|
||||
process.exitCode = 1;
|
||||
console.error(formattedResponse.errors);
|
||||
throw formattedResponse.errors;
|
||||
}
|
||||
|
||||
exec(`del ${npmTarPath}`);
|
||||
exec(`git checkout ${publishBranchName}`);
|
||||
exec(`git pull origin ${publishBranchName}`);
|
||||
exec(`git merge ${tempPublishBranch} --no-edit`);
|
||||
exec(
|
||||
`git push origin HEAD:${publishBranchName} --follow-tags --verbose`
|
||||
);
|
||||
exec(`git branch -d ${tempPublishBranch}`);
|
||||
exec(`git push origin --delete -d ${tempPublishBranch}`);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const createReleaseRequestBody = {
|
||||
tag_name: `v${releaseVersion}`,
|
||||
target_commitish: tempPublishBranch,
|
||||
name: `v${releaseVersion}`,
|
||||
body: `v${releaseVersion}`,
|
||||
draft: false,
|
||||
prerelease: true
|
||||
};
|
||||
console.log('createReleaseRequestBody: ' + JSON.stringify(createReleaseRequestBody, null, 2));
|
||||
|
||||
request.post(
|
||||
{
|
||||
url: "https://api.github.com/repos/Microsoft/react-native/releases",
|
||||
headers: {
|
||||
"User-Agent": userAgent,
|
||||
Authorization: authHeader
|
||||
},
|
||||
json: true,
|
||||
body: createReleaseRequestBody
|
||||
},
|
||||
function(err, res, body) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw new Error("Error fetching release id.");
|
||||
}
|
||||
|
||||
console.log("Created GitHub Release: " + JSON.stringify(body, null, 2));
|
||||
uploadReleaseAssetUrl = assetUpdateUrl.replace(/{id}/, body.id);
|
||||
uploadTarBallToRelease();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
doPublish();
|
|
@ -0,0 +1,84 @@
|
|||
# This file defines the Android PR build steps used during the CI loop
|
||||
name: $(Date:yyyyMMdd).$(Rev:.r)
|
||||
|
||||
trigger: none # will disable CI builds entirely
|
||||
|
||||
pr:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
- job: RNGithubPublish
|
||||
displayName: React-Native GitHub Publish
|
||||
pool:
|
||||
name: OE Standard Pool
|
||||
demands: ['Agent.OS -equals Windows_NT', 'ANDROID_NDK', 'OnPrem -equals False']
|
||||
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
|
||||
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
|
||||
steps:
|
||||
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
|
||||
clean: true # whether to fetch clean each time
|
||||
fetchDepth: 2 # the depth of commits to ask Git to fetch
|
||||
lfs: false # whether to download Git-LFS files
|
||||
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
|
||||
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: npm install
|
||||
inputs:
|
||||
script: npm install
|
||||
|
||||
- task: NuGetCommand@2
|
||||
displayName: NuGet restore
|
||||
inputs:
|
||||
command: restore
|
||||
restoreSolution: ReactAndroid/packages.config
|
||||
feedsToUse: config
|
||||
#vstsFeed: # Required when feedsToUse == Select
|
||||
#includeNuGetOrg: true # Required when feedsToUse == Select
|
||||
nugetConfigPath: ReactAndroid/NuGet.Config
|
||||
#externalFeedCredentials: # Optional
|
||||
#noCache: false
|
||||
#disableParallelProcessing: false
|
||||
restoreDirectory: packages/
|
||||
verbosityRestore: Detailed # Options: quiet, normal, detailed
|
||||
#packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' # Required when command == Push
|
||||
#nuGetFeedType: 'internal' # Required when command == Push# Options: internal, external
|
||||
#publishVstsFeed: # Required when command == Push && NuGetFeedType == Internal
|
||||
#publishPackageMetadata: true # Optional
|
||||
#allowPackageConflicts: # Optional
|
||||
#publishFeedCredentials: # Required when command == Push && NuGetFeedType == External
|
||||
#verbosityPush: 'Detailed' # Options: quiet, normal, detailed
|
||||
#packagesToPack: '**/*.csproj' # Required when command == Pack
|
||||
#configuration: '$(BuildConfiguration)' # Optional
|
||||
#packDestination: '$(Build.ArtifactStagingDirectory)' # Optional
|
||||
#versioningScheme: 'off' # Options: off, byPrereleaseNumber, byEnvVar, byBuildNumber
|
||||
#includeReferencedProjects: false # Optional
|
||||
#versionEnvVar: # Required when versioningScheme == ByEnvVar
|
||||
#majorVersion: '1' # Required when versioningScheme == ByPrereleaseNumber
|
||||
#minorVersion: '0' # Required when versioningScheme == ByPrereleaseNumber
|
||||
#patchVersion: '0' # Required when versioningScheme == ByPrereleaseNumber
|
||||
#packTimezone: 'utc' # Required when versioningScheme == ByPrereleaseNumber# Options: utc, local
|
||||
#includeSymbols: false # Optional
|
||||
#toolPackage: # Optional
|
||||
#buildProperties: # Optional
|
||||
#basePath: # Optional
|
||||
#verbosityPack: 'Detailed' # Options: quiet, normal, detailed
|
||||
#arguments: # Required when command == Custom
|
||||
|
||||
- task: CmdLine@1
|
||||
displayName: 'npm auth'
|
||||
inputs:
|
||||
filename: npm
|
||||
arguments: 'config set $(publishnpmfeed)/registry/:_authToken $(npmTokenOffice)'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: Do Publish
|
||||
inputs:
|
||||
script: node .ado/publish.js
|
||||
|
||||
- task: CmdLine@1
|
||||
displayName: 'npm unauth'
|
||||
inputs:
|
||||
filename: npm
|
||||
arguments: 'config set $(publishnpmfeed)/registry/:_authToken XXXXX'
|
||||
|
|
@ -23,7 +23,11 @@
|
|||
.*/Libraries/polyfills/.*
|
||||
|
||||
; Ignore metro
|
||||
; .*/node_modules/metro/.*
|
||||
.*/node_modules/metro/.*
|
||||
.*/node_modules/metro-config/src/configTypes.flow.js.flow
|
||||
|
||||
; Ignore rn-cli.config.js
|
||||
<PROJECT_ROOT>/rn-cli.config.js
|
||||
|
||||
; These should not be required directly
|
||||
; require from fbjs/lib instead: require('fbjs/lib/invariant')
|
||||
|
|
|
@ -1,14 +1 @@
|
|||
Libraries/Animated/* @janicduplessis
|
||||
Libraries/NativeAnimation/* @janicduplessis
|
||||
Libraries/Image/* @shergin
|
||||
Libraries/Text/* @shergin
|
||||
React/Base/* @shergin
|
||||
React/Views/* @shergin
|
||||
React/Modules/* @shergin
|
||||
React/CxxBridge/* @mhorowitz
|
||||
ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis
|
||||
**/*.md @hramos
|
||||
package.json @hramos
|
||||
local-cli/core/* @grabbou @kureev
|
||||
local-cli/link/* @grabbou @kureev
|
||||
local-cli/unlink/* @grabbou @kureev
|
||||
** @acoates-ms
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
GitHub Issues in the `facebook/react-native` repository are used exclusively for tracking bugs in React Native.
|
||||
GitHub Issues in the `Microsoft/react-native` repository are used exclusively for tracking bugs in the Microsoft/React Native fork. If the issue concerns Facebook's react-native, submit the issue to facebook/react-native.
|
||||
|
||||
Please take a look at the issue templates at https://github.com/facebook/react-native/issues/new/choose before submitting a new issue. Following one of the issue templates will ensure maintainers can route your request efficiently. Thanks!
|
||||
|
|
|
@ -1,45 +1,25 @@
|
|||
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
|
||||
Help us understand your motivation by explaining why you decided to make this change.
|
||||
|
||||
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
|
||||
|
||||
_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
|
||||
|
||||
Test Plan:
|
||||
----------
|
||||
Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
Help reviewers and the release process by writing your own changelog entry. When the change doesn't impact React Native developers, it may be ommitted from the changelog for brevity. See below for an example.
|
||||
|
||||
[CATEGORY] [TYPE] - Message
|
||||
# :warning: Make sure you are targeting Microsoft/react-native for your PR :warning:
|
||||
(then delete these lines)
|
||||
|
||||
<!--
|
||||
We are working on reducing the diff between Facebook's public version of react-native, and our Microsoft/react-native. Long term, we want to remove the need for our version and only depend on Facebook's react-native. In order to move in the right direction, new changes should be examined to ensure that we are doing the right thing.
|
||||
|
||||
CATEGORY may be:
|
||||
If you are making a new change then one of the following should be done:
|
||||
- Consider if it is possible to achieve the desired behavior without making a change to react-native. Often a change can be made in a layer above react-native instead.
|
||||
- Create a corresponding PR against [react-native on GitHub](https://github.com/facebook/react-native)
|
||||
**Note:** Ideally you would wait for GitHub feedback before submitting to ISS, since we want to ensure that ISS doesn't deviate from GitHub.
|
||||
-->
|
||||
|
||||
- [General]
|
||||
- [iOS]
|
||||
- [Android]
|
||||
#### Please select one of the following
|
||||
- [ ] I am removing an existing difference between facebook/react-native and Microsoft/react-native :thumbsup:
|
||||
- [ ] I am cherry-picking a change from Facebook's react-native into Microsoft/react-native :thumbsup:
|
||||
- [ ] I am making a fix / change for the macOS implementation of react-native
|
||||
- [ ] I am making a change required for Microsoft usage of react-native
|
||||
|
||||
TYPE may be:
|
||||
#### Description of changes
|
||||
|
||||
- [Added] for new features.
|
||||
- [Changed] for changes in existing functionality.
|
||||
- [Deprecated] for soon-to-be removed features.
|
||||
- [Removed] for now removed features.
|
||||
- [Fixed] for any bug fixes.
|
||||
- [Security] in case of vulnerabilities.
|
||||
(give an overview)
|
||||
|
||||
For more detail, see https://keepachangelog.com/en/1.0.0/#how
|
||||
#### Focus areas to test
|
||||
|
||||
MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.
|
||||
|
||||
EXAMPLES:
|
||||
|
||||
[General] [Added] - Add snapToOffsets prop to ScrollView component
|
||||
[General] [Fixed] - Fix various issues in snapToInterval on ScrollView component
|
||||
[iOS] [Fixed] - Fix crash in RCTImagePicker
|
||||
|
||||
-->
|
||||
(optional)
|
||||
|
|
|
@ -19,7 +19,10 @@ DerivedData
|
|||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
project.xcworkspace
|
||||
# exclude project.xcworkspace except for xcshareddata/WorkspaceSettings.xcsettings
|
||||
project.xcworkspace/*
|
||||
**/project.xcworkspace/contents.xcworkspacedata
|
||||
**/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
|
||||
|
||||
# Gradle
|
||||
/build/
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
{
|
||||
"name": "@microsoft/react-native",
|
||||
"name": "react-native",
|
||||
"entries": [
|
||||
{
|
||||
"version": "0.0.2",
|
||||
"tag": "react-native_v0.0.2",
|
||||
"date": "Wed, 06 Mar 2019 05:43:46 GMT",
|
||||
"comments": {
|
||||
"patch": [
|
||||
{
|
||||
"comment": "Rename microsoft react-native",
|
||||
"author": "Andrew Coates (REDMOND) <acoates@microsoft.com>",
|
||||
"commit": "0c0c2e0fa8762dda21b96ec3031a90450a45607f"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "0.3.9",
|
||||
"tag": "@microsoft/react-native_v0.3.9",
|
||||
|
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,6 +1,13 @@
|
|||
# Change Log - @microsoft/react-native
|
||||
# Change Log - react-native
|
||||
|
||||
This log was last generated on Tue, 05 Mar 2019 20:54:55 GMT and should not be manually modified.
|
||||
This log was last generated on Wed, 06 Mar 2019 05:43:46 GMT and should not be manually modified.
|
||||
|
||||
## 0.0.2
|
||||
Wed, 06 Mar 2019 05:43:46 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Rename microsoft react-native
|
||||
|
||||
## 0.3.9
|
||||
Tue, 05 Mar 2019 20:54:55 GMT
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
SOURCES=$(wildcard *.md)
|
||||
PDF=$(SOURCES:%.md=%.pdf)
|
||||
HTML=$(SOURCES:%.md=%.html)
|
||||
INSTALL=install -c -m 644
|
||||
PYTHON=python
|
||||
PANDOCARGS=-s
|
||||
PANDOC=/usr/bin/pandoc
|
||||
|
||||
export LANGUAGE=C
|
||||
export LC_ALL=C
|
||||
|
||||
all: html index.html
|
||||
|
||||
pdf: $(PDF)
|
||||
|
||||
html: $(HTML)
|
||||
|
||||
# This needs pandoc 1.9 or later to work
|
||||
%.pdf: %.md
|
||||
$(PANDOC) -f markdown -o $*.pdf $*.md
|
||||
|
||||
%.html: %.md style.css
|
||||
$(PANDOC) $(PANDOCARGS) -H style.css -f markdown -t html --toc -o $*.html $*.md
|
||||
|
||||
docs.md: $(SOURCES) style.css
|
||||
$(PANDOC) $(PANDOCARGS) -H style.css -f markdown -t markdown --toc -o $@ *.md
|
||||
|
||||
index.html: $(SOURCES) style.css
|
||||
$(PANDOC) $(PANDOCARGS) -H style.css -f markdown -t html --toc -o $@ *.md
|
||||
|
||||
|
||||
clean:
|
||||
$(RM) $(PDF) $(HTML) index.html
|
|
@ -0,0 +1,11 @@
|
|||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# depends on libfollybenchmark
|
||||
|
||||
# TESTS = function_benchmark
|
||||
|
||||
# check_PROGRAMS = $(TESTS)
|
||||
|
||||
# noinst_HEADERS = test_functions.h benchmark_impl.h
|
||||
|
||||
# function_benchmark_SOURCES = benchmark_impl.cpp main.cpp test_functions.cpp
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2017 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <folly/test/function_benchmark/benchmark_impl.h>
|
||||
|
||||
#include <folly/test/function_benchmark/test_functions.h>
|
||||
|
||||
/*
|
||||
* These functions are defined in a separate file so that gcc won't be able to
|
||||
* inline them and optimize away the indirect calls.
|
||||
*/
|
||||
|
||||
void BM_fn_ptr_invoke_impl(int iters, void (*fn)()) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
void BM_std_function_invoke_impl(int iters,
|
||||
const std::function<void()>& fn) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
void BM_Function_invoke_impl(int iters,
|
||||
const folly::Function<void() const>& fn) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
void BM_mem_fn_invoke_impl(int iters,
|
||||
TestClass* tc,
|
||||
void (TestClass::*memfn)()) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
(tc->*memfn)();
|
||||
}
|
||||
}
|
||||
|
||||
void BM_virtual_fn_invoke_impl(int iters, VirtualClass* vc) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
vc->doNothing();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2017 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <folly/Function.h>
|
||||
|
||||
class TestClass;
|
||||
class VirtualClass;
|
||||
|
||||
void BM_fn_ptr_invoke_impl(int iters, void (*fn)());
|
||||
void BM_std_function_invoke_impl(int iters, const std::function<void()>& fn);
|
||||
void BM_Function_invoke_impl(int iters,
|
||||
const folly::Function<void() const>& fn);
|
||||
void BM_mem_fn_invoke_impl(int iters,
|
||||
TestClass* tc,
|
||||
void (TestClass::*memfn)());
|
||||
void BM_virtual_fn_invoke_impl(int iters, VirtualClass* vc);
|
||||
|
||||
// Inlined version of BM_fn_ptr_invoke_impl().
|
||||
// The compiler could potentially even optimize the call to the function
|
||||
// pointer if it is a constexpr.
|
||||
inline void BM_fn_ptr_invoke_inlined_impl(int iters, void (*fn)()) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke a function object as a template parameter.
|
||||
// This can be used to directly invoke lambda functions
|
||||
template<typename T>
|
||||
void BM_invoke_fn_template_impl(int iters, const T& fn) {
|
||||
for (int n = 0; n < iters; ++n) {
|
||||
fn();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
/*
|
||||
* Copyright 2017 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <folly/test/function_benchmark/benchmark_impl.h>
|
||||
#include <folly/test/function_benchmark/test_functions.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <folly/Benchmark.h>
|
||||
#include <folly/ScopeGuard.h>
|
||||
#include <folly/portability/GFlags.h>
|
||||
|
||||
using folly::ScopeGuard;
|
||||
using folly::makeGuard;
|
||||
|
||||
// Declare the bm_max_iters flag from folly/Benchmark.cpp
|
||||
DECLARE_int32(bm_max_iters);
|
||||
|
||||
// Directly invoking a function
|
||||
BENCHMARK(fn_invoke, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
doNothing();
|
||||
}
|
||||
}
|
||||
|
||||
// Invoking a function through a function pointer
|
||||
BENCHMARK(fn_ptr_invoke, iters) {
|
||||
BM_fn_ptr_invoke_impl(iters, doNothing);
|
||||
}
|
||||
|
||||
// Invoking a function through a std::function object
|
||||
BENCHMARK(std_function_invoke, iters) {
|
||||
BM_std_function_invoke_impl(iters, doNothing);
|
||||
}
|
||||
|
||||
// Invoking a function through a folly::Function object
|
||||
BENCHMARK(Function_invoke, iters) {
|
||||
BM_Function_invoke_impl(iters, doNothing);
|
||||
}
|
||||
|
||||
// Invoking a member function through a member function pointer
|
||||
BENCHMARK(mem_fn_invoke, iters) {
|
||||
TestClass tc;
|
||||
BM_mem_fn_invoke_impl(iters, &tc, &TestClass::doNothing);
|
||||
}
|
||||
|
||||
// Invoke a function pointer through an inlined wrapper function
|
||||
BENCHMARK(fn_ptr_invoke_through_inline, iters) {
|
||||
BM_fn_ptr_invoke_inlined_impl(iters, doNothing);
|
||||
}
|
||||
|
||||
// Invoke a lambda that calls doNothing() through an inlined wrapper function
|
||||
BENCHMARK(lambda_invoke_fn, iters) {
|
||||
BM_invoke_fn_template_impl(iters, [] { doNothing(); });
|
||||
}
|
||||
|
||||
// Invoke a lambda that does nothing
|
||||
BENCHMARK(lambda_noop, iters) {
|
||||
BM_invoke_fn_template_impl(iters, [] {});
|
||||
}
|
||||
|
||||
// Invoke a lambda that modifies a local variable
|
||||
BENCHMARK(lambda_local_var, iters) {
|
||||
uint32_t count1 = 0;
|
||||
uint32_t count2 = 0;
|
||||
BM_invoke_fn_template_impl(iters, [&] {
|
||||
// Do something slightly more complicated than just incrementing a
|
||||
// variable. Otherwise gcc is smart enough to optimize the loop away.
|
||||
if (count1 & 0x1) {
|
||||
++count2;
|
||||
}
|
||||
++count1;
|
||||
});
|
||||
|
||||
// Use the values we computed, so gcc won't optimize the loop away
|
||||
CHECK_EQ(iters, count1);
|
||||
CHECK_EQ(iters / 2, count2);
|
||||
}
|
||||
|
||||
// Invoke a function pointer through the same wrapper used for lambdas
|
||||
BENCHMARK(fn_ptr_invoke_through_template, iters) {
|
||||
BM_invoke_fn_template_impl(iters, doNothing);
|
||||
}
|
||||
|
||||
// Invoking a virtual method
|
||||
BENCHMARK(virtual_fn_invoke, iters) {
|
||||
VirtualClass vc;
|
||||
BM_virtual_fn_invoke_impl(iters, &vc);
|
||||
}
|
||||
|
||||
// Creating a function pointer and invoking it
|
||||
BENCHMARK(fn_ptr_create_invoke, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
void (*fn)() = doNothing;
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Creating a std::function object from a function pointer, and invoking it
|
||||
BENCHMARK(std_function_create_invoke, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
std::function<void()> fn = doNothing;
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Creating a folly::Function object from a function pointer, and
|
||||
// invoking it
|
||||
BENCHMARK(Function_create_invoke, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
folly::Function<void()> fn = doNothing;
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Creating a pointer-to-member and invoking it
|
||||
BENCHMARK(mem_fn_create_invoke, iters) {
|
||||
TestClass tc;
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
void (TestClass::*memfn)() = &TestClass::doNothing;
|
||||
(tc.*memfn)();
|
||||
}
|
||||
}
|
||||
|
||||
// Using std::bind to create a std::function from a member function,
|
||||
// and invoking it
|
||||
BENCHMARK(std_bind_create_invoke, iters) {
|
||||
TestClass tc;
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
std::function<void()> fn = std::bind(&TestClass::doNothing, &tc);
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Using std::bind directly to invoke a member function
|
||||
BENCHMARK(std_bind_direct_invoke, iters) {
|
||||
TestClass tc;
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
auto fn = std::bind(&TestClass::doNothing, &tc);
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a std::function
|
||||
BENCHMARK(scope_guard_std_function, iters) {
|
||||
std::function<void()> fn(doNothing);
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard(fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a std::function,
|
||||
// but create the ScopeGuard with an rvalue to a std::function
|
||||
BENCHMARK(scope_guard_std_function_rvalue, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard(std::function<void()>(doNothing));
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a folly::Function,
|
||||
// but create the ScopeGuard with an rvalue to a folly::Function
|
||||
BENCHMARK(scope_guard_Function_rvalue, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard(folly::Function<void()>(doNothing));
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a function pointer
|
||||
BENCHMARK(scope_guard_fn_ptr, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard(doNothing);
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a lambda that does nothing
|
||||
BENCHMARK(scope_guard_lambda_noop, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard([] {});
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a lambda that invokes a function
|
||||
BENCHMARK(scope_guard_lambda_function, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard([] { doNothing(); });
|
||||
}
|
||||
}
|
||||
|
||||
// Using ScopeGuard to invoke a lambda that modifies a local variable
|
||||
BENCHMARK(scope_guard_lambda_local_var, iters) {
|
||||
uint32_t count = 0;
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
ScopeGuard g = makeGuard([&] {
|
||||
// Increment count if n is odd. Without this conditional check
|
||||
// (i.e., if we just increment count each time through the loop),
|
||||
// gcc is smart enough to optimize the entire loop away, and just set
|
||||
// count = iters.
|
||||
if (n & 0x1) {
|
||||
++count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check that the value of count is what we expect.
|
||||
// This check is necessary: if we don't use count, gcc detects that count is
|
||||
// unused and optimizes the entire loop away.
|
||||
CHECK_EQ(iters / 2, count);
|
||||
}
|
||||
|
||||
BENCHMARK_DRAW_LINE()
|
||||
|
||||
BENCHMARK(throw_exception, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
try {
|
||||
throwException();
|
||||
} catch (const std::exception& ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(catch_no_exception, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
try {
|
||||
doNothing();
|
||||
} catch (const std::exception& ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(return_exc_ptr, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
returnExceptionPtr();
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(exc_ptr_param_return, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
std::exception_ptr ex;
|
||||
exceptionPtrReturnParam(&ex);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(exc_ptr_param_return_null, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
exceptionPtrReturnParam(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(return_string, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
returnString();
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(return_string_noexcept, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
returnStringNoExcept();
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(return_code, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
returnCode(false);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(return_code_noexcept, iters) {
|
||||
for (size_t n = 0; n < iters; ++n) {
|
||||
returnCodeNoExcept(false);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DRAW_LINE()
|
||||
|
||||
BENCHMARK(std_function_create_move_invoke, iters) {
|
||||
LargeClass a;
|
||||
for (size_t i = 0; i < iters; ++i) {
|
||||
std::function<void()> f(a);
|
||||
invoke(std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(Function_create_move_invoke, iters) {
|
||||
LargeClass a;
|
||||
for (size_t i = 0; i < iters; ++i) {
|
||||
folly::Function<void()> f(a);
|
||||
invoke(std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(std_function_create_move_invoke_ref, iters) {
|
||||
LargeClass a;
|
||||
for (size_t i = 0; i < iters; ++i) {
|
||||
std::function<void()> f(std::ref(a));
|
||||
invoke(std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(Function_create_move_invoke_ref, iters) {
|
||||
LargeClass a;
|
||||
for (size_t i = 0; i < iters; ++i) {
|
||||
folly::Function<void()> f(std::ref(a));
|
||||
invoke(std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
// main()
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
folly::runBenchmarks();
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright 2017 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <folly/test/function_benchmark/test_functions.h>
|
||||
|
||||
/*
|
||||
* These functions are defined in a separate file so that
|
||||
* gcc won't be able to inline them.
|
||||
*/
|
||||
|
||||
|
||||
class Exception : public std::exception {
|
||||
public:
|
||||
explicit Exception(const std::string& value) : value_(value) {}
|
||||
~Exception(void) noexcept override {}
|
||||
|
||||
const char* what(void) const noexcept override { return value_.c_str(); }
|
||||
|
||||
private:
|
||||
std::string value_;
|
||||
};
|
||||
|
||||
void doNothing() {
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void throwException() {
|
||||
throw Exception("this is a test");
|
||||
}
|
||||
|
||||
std::exception_ptr returnExceptionPtr() {
|
||||
Exception ex("this is a test");
|
||||
return std::make_exception_ptr(ex);
|
||||
}
|
||||
|
||||
void exceptionPtrReturnParam(std::exception_ptr* excReturn) {
|
||||
if (excReturn) {
|
||||
Exception ex("this is a test");
|
||||
*excReturn = std::make_exception_ptr(ex);
|
||||
}
|
||||
}
|
||||
|
||||
std::string returnString() {
|
||||
return "this is a test";
|
||||
}
|
||||
|
||||
std::string returnStringNoExcept() noexcept {
|
||||
return "this is a test";
|
||||
}
|
||||
|
||||
int returnCode(int value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
int returnCodeNoExcept(int value) noexcept {
|
||||
return value;
|
||||
}
|
||||
|
||||
void TestClass::doNothing() {
|
||||
}
|
||||
|
||||
VirtualClass::~VirtualClass() {
|
||||
}
|
||||
|
||||
void VirtualClass::doNothing() {
|
||||
};
|
||||
|
||||
LargeClass::LargeClass() {
|
||||
// Suppress unused field warning
|
||||
data[0] = 42;
|
||||
}
|
||||
|
||||
void LargeClass::operator()() const {}
|
||||
|
||||
void invoke(std::function<void()> f) {
|
||||
f();
|
||||
}
|
||||
|
||||
void invoke(folly::Function<void()> f) {
|
||||
f();
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2017 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <folly/Function.h>
|
||||
|
||||
void doNothing();
|
||||
|
||||
[[noreturn]] void throwException();
|
||||
std::exception_ptr returnExceptionPtr();
|
||||
void exceptionPtrReturnParam(std::exception_ptr* excReturn);
|
||||
std::string returnString();
|
||||
std::string returnStringNoExcept() noexcept;
|
||||
int returnCode(int value);
|
||||
int returnCodeNoExcept(int value) noexcept;
|
||||
void invoke(std::function<void()>);
|
||||
void invoke(folly::Function<void()>);
|
||||
|
||||
class TestClass {
|
||||
public:
|
||||
void doNothing();
|
||||
};
|
||||
|
||||
class VirtualClass {
|
||||
public:
|
||||
virtual ~VirtualClass();
|
||||
virtual void doNothing();
|
||||
};
|
||||
|
||||
class LargeClass {
|
||||
public:
|
||||
LargeClass();
|
||||
void operator()() const; // do nothing
|
||||
private:
|
||||
// Avoid small object optimization.
|
||||
char data[1024];
|
||||
};
|
|
@ -147,7 +147,7 @@ function testMerge() {
|
|||
expectEqual(JSON.parse(result), VAL_MERGE_EXPECT, 'testMerge');
|
||||
updateMessage('objects deeply merged\nDone!');
|
||||
runTestCase('multi set and get', testOptimizedMultiGet);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -49,10 +49,15 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
|||
|
||||
animateViewLayout() {
|
||||
debug('animateViewLayout invoked');
|
||||
LayoutAnimation.configureNext(Platform.OS === 'macos' ? LayoutAnimation.Presets.easeInEaseOut : LayoutAnimation.Presets.spring, () => {
|
||||
debug('animateViewLayout done');
|
||||
this.checkLayout(this.addWrapText);
|
||||
});
|
||||
LayoutAnimation.configureNext(
|
||||
Platform.OS === 'macos'
|
||||
? LayoutAnimation.Presets.easeInEaseOut
|
||||
: LayoutAnimation.Presets.spring,
|
||||
() => {
|
||||
debug('animateViewLayout done');
|
||||
this.checkLayout(this.addWrapText);
|
||||
},
|
||||
);
|
||||
this.setState({viewStyle: {margin: 60}});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ class Alert {
|
|||
return;
|
||||
}
|
||||
AlertIOS.alert(title, message, buttons);
|
||||
} else if (Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
AlertMacOS.alert(title, message, buttons); // TODO(macOS ISS#2323203)
|
||||
} else if (Platform.OS === 'macos' /* TODO[(macOS ISS#2323203) */) {
|
||||
AlertMacOS.alert(title, message, buttons); // TODO](macOS ISS#2323203)
|
||||
} else if (Platform.OS === 'android') {
|
||||
AlertAndroid.alert(title, message, buttons, options);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import type { AlertType, AlertButtonStyle } from 'AlertIOS';
|
||||
import type {AlertType, AlertButtonStyle} from 'AlertIOS';
|
||||
|
||||
var RCTAlertManager = require('NativeModules').AlertManager;
|
||||
|
||||
|
@ -175,13 +175,11 @@ class AlertMacOS {
|
|||
modal?: ?boolean,
|
||||
critical?: ?boolean,
|
||||
): void {
|
||||
|
||||
var callbacks = [];
|
||||
var buttons = [];
|
||||
if (typeof callbackOrButtons === 'function') {
|
||||
callbacks = [callbackOrButtons];
|
||||
}
|
||||
else if (callbackOrButtons instanceof Array) {
|
||||
} else if (callbackOrButtons instanceof Array) {
|
||||
callbackOrButtons.forEach((btn, index) => {
|
||||
callbacks[index] = btn.onPress;
|
||||
if (btn.text || index < (callbackOrButtons || []).length - 1) {
|
||||
|
@ -192,18 +190,21 @@ class AlertMacOS {
|
|||
});
|
||||
}
|
||||
|
||||
RCTAlertManager.alertWithArgs({
|
||||
title: title || undefined,
|
||||
message: message || undefined,
|
||||
buttons,
|
||||
type: type || undefined,
|
||||
defaultInputs,
|
||||
modal: modal || undefined,
|
||||
critical: critical || undefined,
|
||||
}, (id, value) => {
|
||||
var cb = callbacks[id];
|
||||
cb && cb(value);
|
||||
});
|
||||
RCTAlertManager.alertWithArgs(
|
||||
{
|
||||
title: title || undefined,
|
||||
message: message || undefined,
|
||||
buttons,
|
||||
type: type || undefined,
|
||||
defaultInputs,
|
||||
modal: modal || undefined,
|
||||
critical: critical || undefined,
|
||||
},
|
||||
(id, value) => {
|
||||
var cb = callbacks[id];
|
||||
cb && cb(value);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,10 @@ function interpolate(
|
|||
|
||||
function colorToRgba(input: string): string {
|
||||
let int32Color = normalizeColor(input);
|
||||
if (int32Color === null || typeof int32Color !== 'number') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
int32Color === null ||
|
||||
typeof int32Color !== 'number' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
return input;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,17 @@ export type SemanticOrDynamicColorType = {
|
|||
semantic?: string,
|
||||
dynamic?: {
|
||||
light: ?(string | number | SemanticOrDynamicColorType),
|
||||
dark: ?(string | number | SemanticOrDynamicColorType)
|
||||
}
|
||||
dark: ?(string | number | SemanticOrDynamicColorType),
|
||||
},
|
||||
}; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)): ?(number | SemanticOrDynamicColorType) { // TODO(macOS ISS#2323203)
|
||||
function normalizeColor(
|
||||
color: ?(
|
||||
| string
|
||||
| number
|
||||
| SemanticOrDynamicColorType
|
||||
) /* TODO(macOS ISS#2323203) */,
|
||||
): ?(number | SemanticOrDynamicColorType) /* TODO(macOS ISS#2323203) */ {
|
||||
const matchers = getMatchers();
|
||||
let match;
|
||||
|
||||
|
@ -32,7 +38,8 @@ function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)):
|
|||
return null;
|
||||
}
|
||||
|
||||
if (typeof color === 'object' && color !== null && Platform.OS === 'macos') { // [TODO(macOS ISS#2323203)
|
||||
if (typeof color === 'object' && color !== null && Platform.OS === 'macos') {
|
||||
// [TODO(macOS ISS#2323203)
|
||||
if ('semantic' in color) {
|
||||
// a macos semantic color
|
||||
return color;
|
||||
|
@ -42,12 +49,12 @@ function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)):
|
|||
const dynamicColor: SemanticOrDynamicColorType = {
|
||||
dynamic: {
|
||||
light: normalizeColor(dynamic.light),
|
||||
dark: normalizeColor(dynamic.dark)
|
||||
}
|
||||
dark: normalizeColor(dynamic.dark),
|
||||
},
|
||||
};
|
||||
return dynamicColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof color !== 'string') {
|
||||
return null;
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
|
|
|
@ -19,6 +19,7 @@ const requireNativeComponent = require('requireNativeComponent');
|
|||
|
||||
import type {NativeComponent} from 'ReactNative';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
const RCTActivityIndicator =
|
||||
Platform.OS === 'android'
|
||||
|
@ -53,7 +54,7 @@ type Props = $ReadOnly<{|
|
|||
*
|
||||
* See http://facebook.github.io/react-native/docs/activityindicator.html#color
|
||||
*/
|
||||
color?: ?string,
|
||||
color?: ?(string | SemanticOrDynamicColorType), // ]TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Size of the indicator (default is 'small').
|
||||
|
@ -116,7 +117,7 @@ ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
|
|||
|
||||
ActivityIndicatorWithRef.defaultProps = {
|
||||
animating: true,
|
||||
color: (Platform.OS === 'ios' || Platform.OS === 'macos') ? GRAY : null, // TODO(macOS ISS#2323203)
|
||||
color: Platform.OS === 'ios' || Platform.OS === 'macos' ? GRAY : null, // TODO(macOS ISS#2323203)
|
||||
hidesWhenStopped: true,
|
||||
size: 'small',
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ const View = require('View');
|
|||
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
import type {PressEvent} from 'CoreEventTypes';
|
||||
import type { PressEvent } from 'CoreEventTypes';
|
||||
|
||||
type ButtonProps = $ReadOnly<{|
|
||||
/**
|
||||
|
@ -29,38 +29,38 @@ type ButtonProps = $ReadOnly<{|
|
|||
*/
|
||||
title: string,
|
||||
|
||||
/**
|
||||
* Handler to be called when the user taps the button
|
||||
*/
|
||||
onPress: (event?: PressEvent) => mixed,
|
||||
/**
|
||||
* Handler to be called when the user taps the button
|
||||
*/
|
||||
onPress: (event?: PressEvent) => mixed,
|
||||
|
||||
/**
|
||||
* Color of the text (iOS), or background color of the button (Android)
|
||||
*/
|
||||
color?: ?string,
|
||||
/**
|
||||
* Color of the text (iOS), or background color of the button (Android)
|
||||
*/
|
||||
color ?: ? string,
|
||||
|
||||
/**
|
||||
* TV preferred focus (see documentation for the View component).
|
||||
*/
|
||||
hasTVPreferredFocus?: ?boolean,
|
||||
/**
|
||||
* TV preferred focus (see documentation for the View component).
|
||||
*/
|
||||
hasTVPreferredFocus ?: ? boolean,
|
||||
|
||||
/**
|
||||
* Text to display for blindness accessibility features
|
||||
*/
|
||||
accessibilityLabel?: ?string,
|
||||
/**
|
||||
* Hint text to display blindness accessibility features
|
||||
*/
|
||||
accessibilityHint: PropTypes.string, // TODO(OSS Candidate ISS#2710739)
|
||||
/**
|
||||
* If true, disable all interactions for this component.
|
||||
*/
|
||||
disabled?: ?boolean,
|
||||
/**
|
||||
* Text to display for blindness accessibility features
|
||||
*/
|
||||
accessibilityLabel ?: ? string,
|
||||
/**
|
||||
* Hint text to display blindness accessibility features
|
||||
*/
|
||||
accessibilityHint: PropTypes.string, // TODO(OSS Candidate ISS#2710739)
|
||||
/**
|
||||
* If true, disable all interactions for this component.
|
||||
*/
|
||||
disabled ?: ? boolean,
|
||||
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
testID?: ?string,
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
testID ?: ? string,
|
||||
|}>;
|
||||
|
||||
/**
|
||||
|
@ -106,10 +106,13 @@ class Button extends React.Component<ButtonProps> {
|
|||
const buttonStyles = [styles.button];
|
||||
const textStyles = [styles.text];
|
||||
if (color) {
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
textStyles.push({color: color});
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
textStyles.push({ color: color });
|
||||
} else {
|
||||
buttonStyles.push({backgroundColor: color});
|
||||
buttonStyles.push({ backgroundColor: color });
|
||||
}
|
||||
}
|
||||
const accessibilityStates = [];
|
||||
|
@ -125,11 +128,11 @@ class Button extends React.Component<ButtonProps> {
|
|||
const formattedTitle =
|
||||
Platform.OS === 'android' ? title.toUpperCase() : title;
|
||||
const Touchable =
|
||||
(Platform.OS === 'android') // [TODO(windows ISS)
|
||||
? TouchableNativeFeedback
|
||||
: (Platform.OS === 'uwp' || Platform.OS === 'windesktop')
|
||||
? TouchableHighlight
|
||||
: TouchableOpacity; // ]TODO(windows ISS)
|
||||
Platform.OS === 'android' // [TODO(windows ISS)
|
||||
? TouchableNativeFeedback
|
||||
: Platform.OS === 'uwp' || Platform.OS === 'windesktop'
|
||||
? TouchableHighlight
|
||||
: TouchableOpacity; // ]TODO(windows ISS)
|
||||
return (
|
||||
<Touchable
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
|
@ -160,11 +163,12 @@ const styles = StyleSheet.create({
|
|||
borderRadius: 2,
|
||||
},
|
||||
macos: {}, // TODO(macOS ISS#2323203)
|
||||
uwp: { // [TODO(windows ISS)
|
||||
uwp: {
|
||||
// [TODO(windows ISS)
|
||||
backgroundColor: '#2196F3',
|
||||
borderRadius: 2,
|
||||
},
|
||||
windesktop: {}, // ]TODO(windows ISS)
|
||||
windesktop: {}, // ]TODO(windows ISS)
|
||||
}),
|
||||
text: {
|
||||
textAlign: 'center',
|
||||
|
@ -197,7 +201,8 @@ const styles = StyleSheet.create({
|
|||
backgroundColor: '#dfdfdf',
|
||||
},
|
||||
macos: {}, // TODO(macOS ISS#2323203)
|
||||
uwp: { // [TODO(windows ISS)
|
||||
uwp: {
|
||||
// [TODO(windows ISS)
|
||||
backgroundColor: '#dfdfdf',
|
||||
},
|
||||
windesktop: {}, // ]TODO(windows ISS)
|
||||
|
@ -206,13 +211,15 @@ const styles = StyleSheet.create({
|
|||
ios: {
|
||||
color: '#cdcdcd',
|
||||
},
|
||||
macos: { // [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
// [TODO(macOS ISS#2323203)
|
||||
color: '#cdcdcd',
|
||||
}, // ]TODO(macOS ISS#2323203)
|
||||
android: {
|
||||
color: '#a1a1a1',
|
||||
},
|
||||
uwp: { // [TODO(windows ISS)
|
||||
uwp: {
|
||||
// [TODO(windows ISS)
|
||||
color: '#a1a1a1',
|
||||
},
|
||||
windesktop: {
|
||||
|
|
|
@ -20,7 +20,9 @@ class DummyDatePickerIOS extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<View style={[styles.dummyDatePickerIOS, this.props.style]}>
|
||||
<Text style={styles.datePickerText}>DatePickerIOS is not supported on this platform!</Text>
|
||||
<Text style={styles.datePickerText}>
|
||||
DatePickerIOS is not supported on this platform!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -40,7 +42,7 @@ var styles = StyleSheet.create({
|
|||
datePickerText: {
|
||||
color: '#333333',
|
||||
margin: 20,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummyDatePickerIOS;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
const DatePickerAndroid = {
|
||||
async open(options: Object): Promise<Object> {
|
||||
return Promise.reject({
|
||||
message: 'DatePickerAndroid is not supported on this platform.'
|
||||
message: 'DatePickerAndroid is not supported on this platform.',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ var StyleSheet = require('StyleSheet');
|
|||
var Text = require('Text');
|
||||
var View = require('View');
|
||||
|
||||
class dummyDatePickerMacOS extends React.Component {
|
||||
class DummyDatePickerMacOS extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={[styles.dummyDatePickerMacOS, this.props.style]}>
|
||||
|
@ -38,7 +38,7 @@ var styles = StyleSheet.create({
|
|||
datePickerText: {
|
||||
color: '#333333',
|
||||
margin: 20,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummyDatePickerMacOS;
|
||||
|
|
|
@ -38,7 +38,7 @@ var styles = StyleSheet.create({
|
|||
datePickerText: {
|
||||
color: '#333333',
|
||||
margin: 20,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummyDatePickerMacOS;
|
||||
|
|
|
@ -147,7 +147,7 @@ const DatePickerMacOS = createReactClass({
|
|||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const RCTDatePickerMacOS = requireNativeComponent('RCTDatePicker' /* TODO refactor as class that extends React.Component<Props>, {
|
||||
|
|
|
@ -135,7 +135,10 @@ class Picker extends React.Component<PickerProps> {
|
|||
};
|
||||
|
||||
render() {
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
/* $FlowFixMe(>=0.81.0 site=react_native_ios_fb) This suppression was
|
||||
* added when renaming suppression sites. */
|
||||
return <PickerIOS {...this.props}>{this.props.children}</PickerIOS>;
|
||||
|
|
|
@ -24,7 +24,7 @@ import type {SyntheticEvent} from 'CoreEventTypes';
|
|||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {TextStyleProp} from 'StyleSheet';
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor' // ]TODO(macOS ISS#2323203)
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
type PickerIOSChangeEvent = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
|
|
|
@ -56,7 +56,7 @@ var PickerIOS = createReactClass({
|
|||
_stateFromProps: function(props) {
|
||||
var selectedIndex = 0;
|
||||
var items = [];
|
||||
React.Children.toArray(props.children).forEach(function (child, index) {
|
||||
React.Children.toArray(props.children).forEach(function(child, index) {
|
||||
if (child.props.value === props.selectedValue) {
|
||||
selectedIndex = index;
|
||||
}
|
||||
|
@ -73,8 +73,10 @@ var PickerIOS = createReactClass({
|
|||
return (
|
||||
<View style={this.props.style}>
|
||||
<RCTPickerIOS
|
||||
ref={/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) */
|
||||
picker => this._picker = picker}
|
||||
ref={
|
||||
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) */
|
||||
picker => (this._picker = picker)
|
||||
}
|
||||
style={[styles.pickerIOS, this.props.itemStyle]}
|
||||
items={this.state.items}
|
||||
selectedIndex={this.state.selectedIndex}
|
||||
|
@ -91,7 +93,10 @@ picker => this._picker = picker}
|
|||
this.props.onChange(event);
|
||||
}
|
||||
if (this.props.onValueChange) {
|
||||
this.props.onValueChange(event.nativeEvent.newValue, event.nativeEvent.newIndex);
|
||||
this.props.onValueChange(
|
||||
event.nativeEvent.newValue,
|
||||
event.nativeEvent.newIndex,
|
||||
);
|
||||
}
|
||||
|
||||
// The picker is a controlled component. This means we expect the
|
||||
|
@ -100,9 +105,12 @@ picker => this._picker = picker}
|
|||
// disallow/undo/mutate the selection of certain values. In other
|
||||
// words, the embedder of this component should be the source of
|
||||
// truth, not the native component.
|
||||
if (this._picker && this.state.selectedIndex !== event.nativeEvent.newIndex) {
|
||||
if (
|
||||
this._picker &&
|
||||
this.state.selectedIndex !== event.nativeEvent.newIndex
|
||||
) {
|
||||
this._picker.setNativeProps({
|
||||
selectedIndex: this.state.selectedIndex
|
||||
selectedIndex: this.state.selectedIndex,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -111,7 +119,7 @@ picker => this._picker = picker}
|
|||
type Props = {
|
||||
value: any,
|
||||
label: string,
|
||||
color: string
|
||||
color: string,
|
||||
};
|
||||
|
||||
PickerIOS.Item = class extends React.Component<Props> {
|
||||
|
@ -136,7 +144,8 @@ var styles = StyleSheet.create({
|
|||
},
|
||||
});
|
||||
|
||||
var RCTPickerIOS = requireNativeComponent('RCTPicker', /* TODO refactor to a class that extends React.Component {
|
||||
var RCTPickerIOS = requireNativeComponent(
|
||||
'RCTPicker' /* TODO refactor to a class that extends React.Component {
|
||||
propTypes: {
|
||||
style: itemStylePropType,
|
||||
},
|
||||
|
@ -146,6 +155,7 @@ var RCTPickerIOS = requireNativeComponent('RCTPicker', /* TODO refactor to a cla
|
|||
onChange: true,
|
||||
selectedIndex: true,
|
||||
},
|
||||
}*/);
|
||||
}*/,
|
||||
);
|
||||
|
||||
module.exports = PickerIOS;
|
||||
|
|
|
@ -69,7 +69,7 @@ var ProgressViewIOS = createReactClass({
|
|||
style={[styles.progressView, this.props.style]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
|
@ -80,7 +80,7 @@ var styles = StyleSheet.create({
|
|||
|
||||
var RCTProgressView = requireNativeComponent(
|
||||
'RCTProgressView' /* TODO refactor to a class that extends React.Component<Props>,
|
||||
ProgressViewIOS*/
|
||||
ProgressViewIOS*/,
|
||||
);
|
||||
|
||||
module.exports = ProgressViewIOS;
|
||||
|
|
|
@ -748,42 +748,66 @@ const ScrollView = createReactClass({
|
|||
}
|
||||
},
|
||||
|
||||
_handleKeyDown: function(e: Object) { // [TODO(macOS ISS#2323203)
|
||||
// [TODO(macOS ISS#2323203)
|
||||
_handleKeyDown: function(e: Object) {
|
||||
if (this.props.onKeyDown) {
|
||||
this.props.onKeyDown(e);
|
||||
}
|
||||
else {
|
||||
const event = e['nativeEvent'];
|
||||
const key = event['key'];
|
||||
const kMinScrollOffset = 10;
|
||||
|
||||
if (Platform.OS === 'macos') {
|
||||
if (key === 'PAGE_UP') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x, y: event.contentOffset.y + -event.layoutMeasurement.height})
|
||||
}
|
||||
else if (key === 'PAGE_DOWN') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x, y: event.contentOffset.y + event.layoutMeasurement.height})
|
||||
}
|
||||
else if (key === 'LEFT_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x + -(this.props.horizontalLineScroll || kMinScrollOffset), y: event.contentOffset.y});
|
||||
}
|
||||
else if (key === 'RIGHT_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x + (this.props.horizontalLineScroll || kMinScrollOffset), y: event.contentOffset.y});
|
||||
}
|
||||
else if (key === 'DOWN_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x, y: event.contentOffset.y + (this.props.verticalLineScroll || kMinScrollOffset)});
|
||||
}
|
||||
else if (key === 'UP_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {x: event.contentOffset.x, y: event.contentOffset.y + -(this.props.verticalLineScroll || kMinScrollOffset)});
|
||||
}
|
||||
this.props.onKeyDown(e);
|
||||
} else {
|
||||
const event = e.nativeEvent;
|
||||
const key = event.key;
|
||||
const kMinScrollOffset = 10;
|
||||
|
||||
if (Platform.OS === 'macos') {
|
||||
if (key === 'PAGE_UP') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x: event.contentOffset.x,
|
||||
y: event.contentOffset.y + -event.layoutMeasurement.height,
|
||||
});
|
||||
} else if (key === 'PAGE_DOWN') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x: event.contentOffset.x,
|
||||
y: event.contentOffset.y + event.layoutMeasurement.height,
|
||||
});
|
||||
} else if (key === 'LEFT_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x:
|
||||
event.contentOffset.x +
|
||||
-(this.props.horizontalLineScroll || kMinScrollOffset),
|
||||
y: event.contentOffset.y,
|
||||
});
|
||||
} else if (key === 'RIGHT_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x:
|
||||
event.contentOffset.x +
|
||||
(this.props.horizontalLineScroll || kMinScrollOffset),
|
||||
y: event.contentOffset.y,
|
||||
});
|
||||
} else if (key === 'DOWN_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x: event.contentOffset.x,
|
||||
y:
|
||||
event.contentOffset.y +
|
||||
(this.props.verticalLineScroll || kMinScrollOffset),
|
||||
});
|
||||
} else if (key === 'UP_ARROW') {
|
||||
this._handleScrollByKeyDown(event, {
|
||||
x: event.contentOffset.x,
|
||||
y:
|
||||
event.contentOffset.y +
|
||||
-(this.props.verticalLineScroll || kMinScrollOffset),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_handleScrollByKeyDown: function(e: Object, newOffset) {
|
||||
const maxX = e.contentSize.width - e.layoutMeasurement.width;
|
||||
const maxY = e.contentSize.height - e.layoutMeasurement.height;
|
||||
this.scrollTo({x: Math.max(0, Math.min(maxX, newOffset.x)), y: Math.max(0, Math.min(maxY, newOffset.y))});
|
||||
this.scrollTo({
|
||||
x: Math.max(0, Math.min(maxX, newOffset.x)),
|
||||
y: Math.max(0, Math.min(maxY, newOffset.y)),
|
||||
});
|
||||
}, // ]TODO(macOS ISS#2323203)
|
||||
|
||||
_handleScroll: function(e: Object) {
|
||||
|
@ -849,7 +873,10 @@ const ScrollView = createReactClass({
|
|||
ScrollViewClass = AndroidScrollView;
|
||||
ScrollContentContainerViewClass = View;
|
||||
}
|
||||
} else if (Platform.OS === 'uwp' || Platform.OS === 'windesktop') { // [TODO(windows ISS)
|
||||
} /* [TODO(windows ISS) */ else if (
|
||||
Platform.OS === 'uwp' ||
|
||||
Platform.OS === 'windesktop'
|
||||
) {
|
||||
ScrollViewClass = RCTScrollView;
|
||||
ScrollContentContainerViewClass = View; // ]TODO(windows ISS)
|
||||
} else {
|
||||
|
@ -1010,7 +1037,8 @@ const ScrollView = createReactClass({
|
|||
this.props.pagingEnabled &&
|
||||
this.props.snapToInterval == null &&
|
||||
this.props.snapToOffsets == null,
|
||||
macos: // [TODO(macOS ISS#2323203)
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos:
|
||||
this.props.pagingEnabled &&
|
||||
this.props.snapToInterval == null &&
|
||||
this.props.snapToOffsets == null, // ]TODO(macOS ISS#2323203)
|
||||
|
|
|
@ -93,19 +93,20 @@ var SegmentedControlIOS = createReactClass({
|
|||
* If true, then selecting a segment won't persist visually.
|
||||
* The `onValueChange` callback will still work as expected.
|
||||
*/
|
||||
momentary: PropTypes.bool
|
||||
momentary: PropTypes.bool,
|
||||
},
|
||||
|
||||
getDefaultProps: function(): DefaultProps {
|
||||
return {
|
||||
values: [],
|
||||
enabled: true
|
||||
enabled: true,
|
||||
};
|
||||
},
|
||||
|
||||
_onChange: function(event: Event) {
|
||||
this.props.onChange && this.props.onChange(event);
|
||||
this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value);
|
||||
this.props.onValueChange &&
|
||||
this.props.onValueChange(event.nativeEvent.value);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -117,7 +118,7 @@ var SegmentedControlIOS = createReactClass({
|
|||
onChange={this._onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
|
@ -127,8 +128,8 @@ var styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
var RCTSegmentedControl = requireNativeComponent(
|
||||
'RCTSegmentedControl'/* TODO refactor to a class that extends React.Component<Props>,
|
||||
SegmentedControlIOS*/
|
||||
'RCTSegmentedControl' /* TODO refactor to a class that extends React.Component<Props>,
|
||||
SegmentedControlIOS*/,
|
||||
);
|
||||
|
||||
module.exports = SegmentedControlIOS;
|
||||
|
|
|
@ -262,7 +262,10 @@ SliderWithRef.defaultProps = {
|
|||
};
|
||||
|
||||
let styles;
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
styles = StyleSheet.create({
|
||||
slider: {
|
||||
height: 40,
|
||||
|
|
|
@ -17,7 +17,7 @@ const requireNativeComponent = require('requireNativeComponent');
|
|||
|
||||
import type {SwitchChangeEvent} from 'CoreEventTypes';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor' // TODO(macOS ISS#2323203)
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // TODO(macOS ISS#2323203)
|
||||
|
||||
// @see ReactSwitchManager.java
|
||||
export type NativeAndroidProps = $ReadOnly<{|
|
||||
|
|
|
@ -43,15 +43,21 @@ let RCTSinglelineTextInputView;
|
|||
|
||||
if (Platform.OS === 'android') {
|
||||
AndroidTextInput = requireNativeComponent('AndroidTextInput');
|
||||
} else if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
} else if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
RCTMultilineTextInputView = requireNativeComponent(
|
||||
'RCTMultilineTextInputView',
|
||||
);
|
||||
RCTSinglelineTextInputView = requireNativeComponent(
|
||||
'RCTSinglelineTextInputView',
|
||||
);
|
||||
} else if (Platform.OS === 'uwp' || Platform.OS === 'windesktop') { // TODO(windows ISS)
|
||||
var RCTTextInput = requireNativeComponent('RCTTextInput'); // TODO(windows ISS)
|
||||
} /* TODO[(windows ISS) */ else if (
|
||||
Platform.OS === 'uwp' ||
|
||||
Platform.OS === 'windesktop'
|
||||
) {
|
||||
var RCTTextInput = requireNativeComponent('RCTTextInput'); // TODO](windows ISS)
|
||||
}
|
||||
|
||||
const onlyMultiline = {
|
||||
|
@ -922,7 +928,8 @@ const TextInput = createReactClass({
|
|||
/**
|
||||
* Returns the native `TextView` node.
|
||||
*/
|
||||
getTextViewHandle: function(): any { // [TODO(OSS Candidate ISS#2710739)
|
||||
getTextViewHandle: function(): any {
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
return ReactNative.findNodeHandle(this._inputRef);
|
||||
}, // ]TODO(OSS Candidate ISS#2710739)
|
||||
|
||||
|
@ -989,13 +996,15 @@ const TextInput = createReactClass({
|
|||
|
||||
render: function() {
|
||||
let textInput;
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
|
||||
// TODO(macOS ISS#2323203)
|
||||
textInput = UIManager.getViewManagerConfig('RCTVirtualText')
|
||||
? this._renderIOS()
|
||||
: this._renderIOSLegacy();
|
||||
} else if (Platform.OS === 'android') {
|
||||
textInput = this._renderAndroid();
|
||||
} else if (Platform.OS === 'uwp' || Platform.OS === 'windesktop') { // TODO(windows ISS)
|
||||
} else if (Platform.OS === 'uwp' || Platform.OS === 'windesktop') {
|
||||
// TODO(windows ISS)
|
||||
return this._renderWindows(); // TODO(windows ISS)
|
||||
}
|
||||
return (
|
||||
|
@ -1224,7 +1233,8 @@ const TextInput = createReactClass({
|
|||
);
|
||||
},
|
||||
|
||||
_renderWindows: function() { // [TODO(windows ISS)
|
||||
_renderWindows: function() {
|
||||
// [TODO(windows ISS)
|
||||
var props = Object.assign({}, this.props);
|
||||
props.style = [(styles: any).input, this.props.style];
|
||||
|
||||
|
@ -1244,7 +1254,9 @@ const TextInput = createReactClass({
|
|||
// 1. The state is updated only after the native code completes setting focus on the view
|
||||
// 2. In case the focus is moving from one TextInput(A) to another TextInput(B), the state of
|
||||
// A needs to be updated (blurred) before info about B is updated in TestInputState.
|
||||
TextInputState.setFocusedTextInput(ReactNative.findNodeHandle(this._inputRef)); // ]TODO(android ISS)
|
||||
TextInputState.setFocusedTextInput(
|
||||
ReactNative.findNodeHandle(this._inputRef),
|
||||
); // ]TODO(android ISS)
|
||||
if (this.props.onFocus) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
|
@ -1344,7 +1356,9 @@ const TextInput = createReactClass({
|
|||
// 1. The state is updated only after the native code completes clearing focus on the view
|
||||
// 2. In case the focus is moving from one TextInput(A) to another TextInput(B), the state of
|
||||
// A needs to be updated (blurred) before info about B is updated in TestInputState.
|
||||
TextInputState.clearFocusedTextInput(ReactNative.findNodeHandle(this._inputRef)); // ]TODO(android ISS)
|
||||
TextInputState.clearFocusedTextInput(
|
||||
ReactNative.findNodeHandle(this._inputRef),
|
||||
); // ]TODO(android ISS)
|
||||
|
||||
// This is a hack to fix https://fburl.com/toehyir8
|
||||
// @todo(rsnara) Figure out why this is necessary.
|
||||
|
|
|
@ -37,7 +37,10 @@ function currentlyFocusedField(): ?number {
|
|||
function focusTextInput(textFieldID: ?number) {
|
||||
if (currentlyFocusedID !== textFieldID && textFieldID !== null) {
|
||||
// TODO(android ISS) removed: currentlyFocusedID = textFieldID;
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
UIManager.focus(textFieldID);
|
||||
} else if (Platform.OS === 'android') {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
|
@ -46,6 +49,12 @@ function focusTextInput(textFieldID: ?number) {
|
|||
.focusTextInput,
|
||||
null,
|
||||
);
|
||||
} else if (Platform.OS === 'win32') {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
textFieldID,
|
||||
UIManager.RCTView.Commands.focus,
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +67,10 @@ function focusTextInput(textFieldID: ?number) {
|
|||
function blurTextInput(textFieldID: ?number) {
|
||||
if (currentlyFocusedID === textFieldID && textFieldID !== null) {
|
||||
currentlyFocusedID = null;
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
UIManager.blur(textFieldID);
|
||||
} else if (Platform.OS === 'android') {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
|
@ -67,6 +79,12 @@ function blurTextInput(textFieldID: ?number) {
|
|||
.blurTextInput,
|
||||
null,
|
||||
);
|
||||
} else if (Platform.OS === 'win32') {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
textFieldID,
|
||||
UIManager.RCTView.Commands.blur,
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,17 @@ const TouchableBounce = ((createReactClass({
|
|||
accessibilityRole={this.props.accessibilityRole}
|
||||
accessibilityStates={this.props.accessibilityStates}
|
||||
onAccessibilityTap={this.props.onAccessibilityTap} // TODO(OSS Candidate ISS#2710739)
|
||||
acceptsKeyboardFocus={
|
||||
(this.props.acceptsKeyboardFocus === undefined ||
|
||||
this.props.acceptsKeyboardFocus) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS/win ISS#2323203)
|
||||
enableFocusRing={
|
||||
(this.props.enableFocusRing === undefined ||
|
||||
this.props.enableFocusRing) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS/win ISS#2323203)
|
||||
tabIndex={this.props.tabIndex} // TODO(win ISS#2323203)
|
||||
nativeID={this.props.nativeID}
|
||||
testID={this.props.testID}
|
||||
hitSlop={this.props.hitSlop}
|
||||
|
@ -182,7 +193,12 @@ const TouchableBounce = ((createReactClass({
|
|||
onResponderMove={this.touchableHandleResponderMove}
|
||||
onResponderRelease={this.touchableHandleResponderRelease}
|
||||
onResponderTerminate={this.touchableHandleResponderTerminate}
|
||||
clickable={this.props.clickable !== false && this.props.onPress !== undefined && !this.props.disabled} // TODO(android ISS)
|
||||
tooltip={this.props.tooltip} // TODO(macOS/win ISS#2323203)
|
||||
clickable={
|
||||
this.props.clickable !== false &&
|
||||
this.props.onPress !== undefined &&
|
||||
!this.props.disabled
|
||||
} // TODO(android ISS)
|
||||
onClick={this.touchableHandlePress} // TODO(android ISS)
|
||||
onMouseEnter={this.props.onMouseEnter} // [TODO(macOS ISS#2323203)
|
||||
onMouseLeave={this.props.onMouseLeave}
|
||||
|
@ -190,7 +206,7 @@ const TouchableBounce = ((createReactClass({
|
|||
onDragLeave={this.props.onDragLeave}
|
||||
onDrop={this.props.onDrop}
|
||||
draggedTypes={this.props.draggedTypes} // ]TODO(macOS ISS#2323203)
|
||||
>
|
||||
>
|
||||
{this.props.children}
|
||||
{Touchable.renderDebugView({
|
||||
color: 'orange',
|
||||
|
|
|
@ -342,8 +342,17 @@ const TouchableHighlight = ((createReactClass({
|
|||
accessibilityRole={this.props.accessibilityRole}
|
||||
accessibilityStates={this.props.accessibilityStates}
|
||||
onAccessibilityTap={this.props.onAccessibilityTap} // TODO(OSS Candidate ISS#2710739)
|
||||
acceptsKeyboardFocus={(this.props.acceptsKeyboardFocus === undefined || this.props.acceptsKeyboardFocus) && !this.props.disabled} // TODO(macOS ISS#2323203)
|
||||
enableFocusRing={(this.props.enableFocusRing === undefined || this.props.enableFocusRing) && !this.props.disabled} // TODO(macOS ISS#2323203)
|
||||
acceptsKeyboardFocus={
|
||||
(this.props.acceptsKeyboardFocus === undefined ||
|
||||
this.props.acceptsKeyboardFocus) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS/win ISS#2323203)
|
||||
enableFocusRing={
|
||||
(this.props.enableFocusRing === undefined ||
|
||||
this.props.enableFocusRing) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS/win ISS#2323203)
|
||||
tabIndex={this.props.tabIndex} // TODO(win ISS#2323203)
|
||||
style={StyleSheet.compose(
|
||||
this.props.style,
|
||||
this.state.extraUnderlayStyle,
|
||||
|
@ -361,14 +370,17 @@ const TouchableHighlight = ((createReactClass({
|
|||
onResponderMove={this.touchableHandleResponderMove}
|
||||
onResponderRelease={this.touchableHandleResponderRelease}
|
||||
onResponderTerminate={this.touchableHandleResponderTerminate}
|
||||
clickable={this.props.clickable !== false && this.props.onPress !== undefined} // TODO(android ISS)
|
||||
tooltip={this.props.tooltip} // TODO(macOS/win ISS#2323203)
|
||||
clickable={
|
||||
this.props.clickable !== false && this.props.onPress !== undefined
|
||||
} // TODO(android ISS)
|
||||
onClick={this.touchableHandlePress} // TODO(android ISS)
|
||||
onMouseEnter={this.props.onMouseEnter} // [TODO(macOS ISS#2323203)
|
||||
onMouseEnter={this.props.onMouseEnter} // [TODO(macOS/win ISS#2323203)
|
||||
onMouseLeave={this.props.onMouseLeave}
|
||||
onDragEnter={this.props.onDragEnter}
|
||||
onDragLeave={this.props.onDragLeave}
|
||||
onDrop={this.props.onDrop}
|
||||
draggedTypes={this.props.draggedTypes} // ]TODO(macOS ISS#2323203)
|
||||
draggedTypes={this.props.draggedTypes} // ]TODO(macOS/win ISS#2323203)
|
||||
nativeID={this.props.nativeID}
|
||||
testID={this.props.testID}>
|
||||
{React.cloneElement(child, {
|
||||
|
|
|
@ -288,8 +288,11 @@ const TouchableNativeFeedback = createReactClass({
|
|||
onResponderMove: this._handleResponderMove,
|
||||
onResponderRelease: this.touchableHandleResponderRelease,
|
||||
onResponderTerminate: this.touchableHandleResponderTerminate,
|
||||
clickable: this.props.clickable !== false && this.props.onPress !== undefined && !this.props.disabled, // TODO(android ISS)
|
||||
onClick: this.touchableHandlePress, // TODO(android ISS)
|
||||
clickable:
|
||||
this.props.clickable !== false &&
|
||||
this.props.onPress !== undefined &&
|
||||
!this.props.disabled, // TODO(android ISS)
|
||||
onClick: this.touchableHandlePress, // TODO(android ISS)
|
||||
};
|
||||
|
||||
// We need to clone the actual element so that the ripple background drawable
|
||||
|
|
|
@ -259,8 +259,17 @@ const TouchableOpacity = ((createReactClass({
|
|||
accessibilityRole={this.props.accessibilityRole}
|
||||
accessibilityStates={this.props.accessibilityStates}
|
||||
onAccessibilityTap={this.props.onAccessibilityTap} // TODO(OSS Candidate ISS#2710739)
|
||||
acceptsKeyboardFocus={(this.props.acceptsKeyboardFocus === undefined || this.props.acceptsKeyboardFocus) && !this.props.disabled} // TODO(macOS ISS#2323203)
|
||||
enableFocusRing={(this.props.enableFocusRing === undefined || this.props.enableFocusRing) && !this.props.disabled} // TODO(macOS ISS#2323203)
|
||||
acceptsKeyboardFocus={
|
||||
(this.props.acceptsKeyboardFocus === undefined ||
|
||||
this.props.acceptsKeyboardFocus) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS ISS#2323203)
|
||||
enableFocusRing={
|
||||
(this.props.enableFocusRing === undefined ||
|
||||
this.props.enableFocusRing) &&
|
||||
!this.props.disabled
|
||||
} // TODO(macOS ISS#2323203)
|
||||
tabIndex={this.props.tabIndex} // TODO(win ISS#2323203)
|
||||
style={[this.props.style, {opacity: this.state.anim}]}
|
||||
nativeID={this.props.nativeID}
|
||||
testID={this.props.testID}
|
||||
|
@ -277,7 +286,10 @@ const TouchableOpacity = ((createReactClass({
|
|||
onResponderMove={this.touchableHandleResponderMove}
|
||||
onResponderRelease={this.touchableHandleResponderRelease}
|
||||
onResponderTerminate={this.touchableHandleResponderTerminate}
|
||||
clickable={this.props.clickable !== false && this.props.onPress !== undefined} // TODO(android ISS)
|
||||
tooltip={this.props.tooltip} // TODO(macOS/win ISS#2323203)
|
||||
clickable={
|
||||
this.props.clickable !== false && this.props.onPress !== undefined
|
||||
} // TODO(android ISS)
|
||||
onClick={this.touchableHandlePress} // TODO(android ISS)
|
||||
onMouseEnter={this.props.onMouseEnter} // [TODO(macOS ISS#2323203)
|
||||
onMouseLeave={this.props.onMouseLeave}
|
||||
|
@ -285,7 +297,7 @@ const TouchableOpacity = ((createReactClass({
|
|||
onDragLeave={this.props.onDragLeave}
|
||||
onDrop={this.props.onDrop}
|
||||
draggedTypes={this.props.draggedTypes} // ]TODO(macOS ISS#2323203)
|
||||
>
|
||||
>
|
||||
{this.props.children}
|
||||
{Touchable.renderDebugView({
|
||||
color: 'cyan',
|
||||
|
|
|
@ -36,12 +36,8 @@ import type {
|
|||
} from 'ViewAccessibility';
|
||||
|
||||
// [TODO(macOS ISS#2323203)
|
||||
const {
|
||||
DraggedTypes
|
||||
} = require('DraggedType');
|
||||
import type {
|
||||
DraggedTypesType
|
||||
} from 'DraggedType';
|
||||
const {DraggedTypes} = require('DraggedType');
|
||||
import type {DraggedTypesType} from 'DraggedType';
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
|
||||
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
|
@ -76,8 +72,8 @@ export type Props = $ReadOnly<{|
|
|||
onPressOut?: ?Function,
|
||||
onAccessibilityTap?: ?Function, // TODO(OSS Candidate ISS#2710739)
|
||||
acceptsKeyboardFocus?: ?boolean, // [TODO(macOS ISS#2323203)
|
||||
onMouseEnter?: ?Function,
|
||||
onMouseLeave?: ?Function,
|
||||
onMouseEnter?: ?Function,
|
||||
onMouseLeave?: ?Function,
|
||||
onDragEnter?: ?Function,
|
||||
onMouseLeave?: ?Function,
|
||||
onDragEnter?: ?Function,
|
||||
|
@ -116,6 +112,7 @@ const TouchableWithoutFeedback = ((createReactClass({
|
|||
PropTypes.arrayOf(PropTypes.oneOf(DeprecatedAccessibilityTraits)),
|
||||
]),
|
||||
onAccessibilityTap: PropTypes.func, // TODO(OSS Candidate ISS#2710739)
|
||||
tabIndex: PropTypes.number, // TODO(macOS/win ISS#2323203)
|
||||
|
||||
/**
|
||||
* When `accessible` is true (which is the default) this may be called when
|
||||
|
@ -157,15 +154,16 @@ const TouchableWithoutFeedback = ((createReactClass({
|
|||
* Enables Drag'n'Drop Support for certain types of dragged types
|
||||
*
|
||||
* Possible values for `draggedTypes` are:
|
||||
*
|
||||
*
|
||||
* - `'fileUrl'`
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
draggedTypes: PropTypes.oneOfType([ // TODO(macOS ISS#2323203)
|
||||
draggedTypes: PropTypes.oneOfType([
|
||||
PropTypes.oneOf(DraggedTypes),
|
||||
PropTypes.arrayOf(PropTypes.oneOf(DraggedTypes)),
|
||||
]),
|
||||
]), // TODO(macOS ISS#2323203)
|
||||
tooltip: PropTypes.string, // TODO(macOS/win ISS#2323203)
|
||||
/**
|
||||
* Called when the touch is released, but not if cancelled (e.g. by a scroll
|
||||
* that steals the responder lock).
|
||||
|
@ -298,8 +296,13 @@ const TouchableWithoutFeedback = ((createReactClass({
|
|||
accessibilityStates: this.props.accessibilityStates,
|
||||
accessibilityTraits: this.props.accessibilityTraits,
|
||||
onAccessibilityTap: this.props.onAccessibilityTap, // TODO(OSS Candidate ISS#2710739)
|
||||
acceptsKeyboardFocus: (this.props.acceptsKeyboardFocus === undefined || this.props.acceptsKeyboardFocus) && !this.props.disabled, // TODO(macOS ISS#2323203)
|
||||
enableFocusRing: (this.props.enableFocusRing === true && !this.props.disabled), // TODO(macOS ISS#2323203)
|
||||
acceptsKeyboardFocus:
|
||||
(this.props.acceptsKeyboardFocus === undefined ||
|
||||
this.props.acceptsKeyboardFocus) &&
|
||||
!this.props.disabled, // TODO(macOS ISS#2323203)
|
||||
enableFocusRing:
|
||||
this.props.enableFocusRing === true && !this.props.disabled, // TODO(macOS ISS#2323203)
|
||||
tabIndex: this.props.tabIndex, // TODO(win ISS#2323203)
|
||||
nativeID: this.props.nativeID,
|
||||
testID: this.props.testID,
|
||||
onLayout: this.props.onLayout,
|
||||
|
@ -311,7 +314,9 @@ const TouchableWithoutFeedback = ((createReactClass({
|
|||
onResponderMove: this.touchableHandleResponderMove,
|
||||
onResponderRelease: this.touchableHandleResponderRelease,
|
||||
onResponderTerminate: this.touchableHandleResponderTerminate,
|
||||
clickable: this.props.clickable !== false && this.props.onPress !== undefined, // TODO(android ISS)
|
||||
tooltip: this.props.tooltip, // TODO(macOS/win ISS#2323203)
|
||||
clickable:
|
||||
this.props.clickable !== false && this.props.onPress !== undefined, // TODO(android ISS)
|
||||
onClick: this.touchableHandlePress, // TODO(android ISS)
|
||||
onMouseEnter: this.props.onMouseEnter, // [TODO(macOS ISS#2323203)
|
||||
onMouseLeave: this.props.onMouseLeave, // [TODO(macOS ISS#2323203)
|
||||
|
|
|
@ -12,16 +12,10 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
export type DraggedType =
|
||||
| 'fileUrl';
|
||||
export type DraggedType = 'fileUrl';
|
||||
|
||||
export type DraggedTypesType =
|
||||
| DraggedType
|
||||
| $ReadOnlyArray<DraggedType>;
|
||||
export type DraggedTypesType = DraggedType | $ReadOnlyArray<DraggedType>;
|
||||
|
||||
module.exports = {
|
||||
DraggedTypes: [
|
||||
'fileUrl'
|
||||
],
|
||||
DraggedTypes: ['fileUrl'],
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ ReactNativeViewAttributes.UIView = {
|
|||
importantForAccessibility: true,
|
||||
nativeID: true,
|
||||
testID: true,
|
||||
tabIndex: true, // TODO(win ISS#2323203)
|
||||
renderToHardwareTextureAndroid: true,
|
||||
shouldRasterizeIOS: true,
|
||||
onLayout: true,
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
|
||||
export type AccessibilityTrait =
|
||||
| 'none'
|
||||
| 'button'
|
||||
|
@ -32,7 +31,6 @@ export type AccessibilityTrait =
|
|||
| 'group'
|
||||
| 'list'; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
|
||||
export type AccessibilityTraits =
|
||||
| AccessibilityTrait
|
||||
| $ReadOnlyArray<AccessibilityTrait>;
|
||||
|
@ -43,8 +41,9 @@ export type AccessibilityComponentType =
|
|||
| 'radiobutton_checked'
|
||||
| 'radiobutton_unchecked';
|
||||
|
||||
export type AccessibilityNodeInfoProp = { // [TODO(android ISS)
|
||||
clickable: bool,
|
||||
// [TODO(android ISS)
|
||||
export type AccessibilityNodeInfoProp = {
|
||||
clickable: boolean,
|
||||
}; // ]TODO(android ISS)
|
||||
|
||||
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
|
||||
|
|
|
@ -24,13 +24,9 @@ import type {
|
|||
} from 'ViewAccessibility';
|
||||
|
||||
// [TODO(macOS ISS#2323203)
|
||||
const {
|
||||
DraggedTypes
|
||||
} = require('DraggedType');
|
||||
const {DraggedTypes} = require('DraggedType');
|
||||
|
||||
import type {
|
||||
DraggedType
|
||||
} from 'DraggedType';
|
||||
import type {DraggedType} from 'DraggedType';
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
|
||||
export type ViewLayout = Layout;
|
||||
|
@ -218,38 +214,6 @@ type GestureResponderEventProps = $ReadOnly<{|
|
|||
onStartShouldSetResponderCapture?: ?Function,
|
||||
|}>;
|
||||
|
||||
type AndroidViewProps = $ReadOnly<{|
|
||||
nativeBackgroundAndroid?: ?Object,
|
||||
nativeForegroundAndroid?: ?Object,
|
||||
|
||||
/* Deprecated transform prop. Use the transform style prop instead */
|
||||
rotation?: empty,
|
||||
/* Deprecated transform prop. Use the transform style prop instead */
|
||||
scaleX?: empty,
|
||||
/* Deprecated transform prop. Use the transform style prop instead */
|
||||
scaleY?: empty,
|
||||
/* Deprecated transform prop. Use the transform style prop instead */
|
||||
translateX?: empty,
|
||||
/* Deprecated transform prop. Use the transform style prop instead */
|
||||
translateY?: empty,
|
||||
|
||||
/**
|
||||
* When `true`, indicates that the view is clickable. By default,
|
||||
* all the touchable elements are clickable.
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
clickable: PropTypes.bool, // TODO(android ISS)
|
||||
|
||||
/**
|
||||
* When `clickable` is true, the system will try to invoke this function
|
||||
* when the user performs a click.
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
onClick: PropTypes.func, // TODO(android ISS)
|
||||
|}>;
|
||||
|
||||
type AndroidViewProps = $ReadOnly<{|
|
||||
nativeBackgroundAndroid?: ?Object,
|
||||
nativeForegroundAndroid?: ?Object,
|
||||
|
@ -286,6 +250,22 @@ type AndroidViewProps = $ReadOnly<{|
|
|||
*/
|
||||
needsOffscreenAlphaCompositing?: ?boolean,
|
||||
|
||||
/**
|
||||
* When `true`, indicates that the view is clickable. By default,
|
||||
* all the touchable elements are clickable.
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
clickable?: ?boolean, // TODO(android ISS)
|
||||
|
||||
/**
|
||||
* When `clickable` is true, the system will try to invoke this function
|
||||
* when the user performs a click.
|
||||
*
|
||||
* @platform android
|
||||
*/
|
||||
|
||||
onClick?: ?Function, // TODO(android ISS)
|
||||
/**
|
||||
* Indicates to accessibility services to treat UI component like a
|
||||
* native one. Works for Android only.
|
||||
|
@ -294,6 +274,7 @@ type AndroidViewProps = $ReadOnly<{|
|
|||
*
|
||||
* See http://facebook.github.io/react-native/docs/view.html#accessibilitycomponenttype
|
||||
*/
|
||||
|
||||
accessibilityComponentType?: ?AccessibilityComponentType,
|
||||
|
||||
/**
|
||||
|
@ -311,7 +292,7 @@ type AndroidViewProps = $ReadOnly<{|
|
|||
*
|
||||
* @platform android
|
||||
*/
|
||||
onFocusChange: PropTypes.func, // TODO(android ISS)
|
||||
onFocusChange?: ?Function, // TODO(android ISS)
|
||||
|
||||
/**
|
||||
* Controls how view is important for accessibility which is if it
|
||||
|
@ -383,9 +364,9 @@ type IOSViewProps = $ReadOnly<{|
|
|||
*
|
||||
* @platform ios
|
||||
*/
|
||||
onAccessibilityAction: PropTypes.func,
|
||||
|
||||
onDoubleClick: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
onAccessibilityAction?: ?Function,
|
||||
|
||||
onDoubleClick?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* When `accessible` is true, the system will try to invoke this function
|
||||
|
@ -393,7 +374,7 @@ type IOSViewProps = $ReadOnly<{|
|
|||
*
|
||||
* See http://facebook.github.io/react-native/docs/view.html#onaccessibilitytap
|
||||
*/
|
||||
onAccessibilityTap: PropTypes.func,
|
||||
onAccessibilityTap?: ?Function,
|
||||
|
||||
/**
|
||||
* When `accessible` is `true`, the system will invoke this function when the
|
||||
|
@ -473,6 +454,8 @@ export type ViewProps = $ReadOnly<{|
|
|||
*/
|
||||
nativeID?: ?string,
|
||||
|
||||
tabIndex?: ?number, // TODO(win ISS#2323203)
|
||||
|
||||
/**
|
||||
* This defines how far a touch event can start away from the view.
|
||||
* Typical interface guidelines recommend touch targets that are at least
|
||||
|
@ -509,55 +492,55 @@ export type ViewProps = $ReadOnly<{|
|
|||
|
||||
/**
|
||||
* Fired when a pointing device is moved over the view
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
onMouseEnter: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
|
||||
onMouseEnter?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when a pointing device is moved out the view
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
onMouseLeave: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
|
||||
onMouseLeave?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when a dragged element enters a valid drop target
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
onDragEnter: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
|
||||
onDragEnter?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when a dragged element leaves a valid drop target
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
onDragLeave: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
onDragLeave?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when an element is dropped on a valid drop target
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
onDrop: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Specifies the Tooltip for the view
|
||||
* @platform macos
|
||||
*/
|
||||
tooltip: PropTypes.string, // TODO(macOS ISS#2323203)
|
||||
onDrop?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Specifies whether the view participates in the key view loop as user tabs
|
||||
* through different controls.
|
||||
*/
|
||||
acceptsKeyboardFocus: PropTypes.bool, // TODO(macOS ISS#2323203)
|
||||
* Specifies the Tooltip for the view
|
||||
* @platform macos
|
||||
*/
|
||||
tooltip?: ?string, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Specifies whether focus ring should be drawn when the view has the first responder status.
|
||||
*/
|
||||
enableFocusRing: PropTypes.bool, // TODO(macOS ISS#2323203)
|
||||
* Specifies whether the view participates in the key view loop as user tabs
|
||||
* through different controls.
|
||||
*/
|
||||
acceptsKeyboardFocus?: ?boolean, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Specifies whether focus ring should be drawn when the view has the first responder status.
|
||||
*/
|
||||
enableFocusRing?: ?boolean, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when an element is focused
|
||||
|
@ -565,7 +548,7 @@ export type ViewProps = $ReadOnly<{|
|
|||
* @platform macos
|
||||
* @platform ios
|
||||
*/
|
||||
onFocus: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
onFocus?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Fired when an element loses focus
|
||||
|
@ -573,21 +556,18 @@ export type ViewProps = $ReadOnly<{|
|
|||
* @platform macos
|
||||
* @platform ios
|
||||
*/
|
||||
onBlur: PropTypes.func, // TODO(macOS ISS#2323203)
|
||||
onBlur?: ?Function, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Enables Dran'n'Drop Support for certain types of dragged types
|
||||
*
|
||||
* Possible values for `draggedTypes` are:
|
||||
*
|
||||
*
|
||||
* - `'fileUrl'`
|
||||
*
|
||||
*
|
||||
* @platform macos
|
||||
*/
|
||||
draggedTypes: PropTypes.oneOfType([ // TODO(macOS ISS#2323203)
|
||||
PropTypes.oneOf(DraggedTypes),
|
||||
PropTypes.arrayOf(PropTypes.oneOf(DraggedTypes)),
|
||||
]),
|
||||
draggedTypes?: ?DraggedTypes | ?$ReadOnlyArray<DraggedTypes>, // TODO(macOS ISS#2323203)
|
||||
|
||||
/**
|
||||
* Any additional platform-specific view prop types, or prop type overrides.
|
||||
|
|
|
@ -30,12 +30,14 @@ class WKWebView extends React.Component<RCTWKWebViewProps> {
|
|||
|
||||
showRedboxOnPropChanges(nextProps: RCTWKWebViewProps, propName: string) {
|
||||
if (this.props[propName] !== nextProps[propName]) {
|
||||
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
||||
console.error(
|
||||
`Changes to property ${propName} do nothing after the initial render.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <RCTWKWebView {...this.props}/>;
|
||||
return <RCTWKWebView {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -422,33 +422,38 @@ class WebView extends React.Component {
|
|||
otherView = (this.props.renderLoading || defaultRenderLoading)();
|
||||
} else if (this.state.viewState === WebViewState.ERROR) {
|
||||
var errorEvent = this.state.lastErrorEvent;
|
||||
invariant(
|
||||
errorEvent != null,
|
||||
'lastErrorEvent expected to be non-null'
|
||||
);
|
||||
invariant(errorEvent != null, 'lastErrorEvent expected to be non-null');
|
||||
otherView = (this.props.renderError || defaultRenderError)(
|
||||
errorEvent.domain,
|
||||
errorEvent.code,
|
||||
errorEvent.description
|
||||
errorEvent.description,
|
||||
);
|
||||
} else if (this.state.viewState !== WebViewState.IDLE) {
|
||||
console.error(
|
||||
'RCTWebView invalid state encountered: ' + this.state.loading
|
||||
'RCTWebView invalid state encountered: ' + this.state.loading,
|
||||
);
|
||||
}
|
||||
|
||||
var webViewStyles = [styles.container, styles.webView, this.props.style];
|
||||
if (this.state.viewState === WebViewState.LOADING ||
|
||||
this.state.viewState === WebViewState.ERROR) {
|
||||
if (
|
||||
this.state.viewState === WebViewState.LOADING ||
|
||||
this.state.viewState === WebViewState.ERROR
|
||||
) {
|
||||
// if we're in either LOADING or ERROR states, don't show the webView
|
||||
webViewStyles.push(styles.hidden);
|
||||
}
|
||||
|
||||
var onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => {
|
||||
var shouldStart = this.props.onShouldStartLoadWithRequest &&
|
||||
this.props.onShouldStartLoadWithRequest(event.nativeEvent);
|
||||
RCTWebViewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier);
|
||||
});
|
||||
var onShouldStartLoadWithRequest =
|
||||
this.props.onShouldStartLoadWithRequest &&
|
||||
((event: Event) => {
|
||||
var shouldStart =
|
||||
this.props.onShouldStartLoadWithRequest &&
|
||||
this.props.onShouldStartLoadWithRequest(event.nativeEvent);
|
||||
RCTWebViewManager.startLoadWithResult(
|
||||
!!shouldStart,
|
||||
event.nativeEvent.lockIdentifier,
|
||||
);
|
||||
});
|
||||
|
||||
var source = this.props.source || {};
|
||||
if (this.props.html) {
|
||||
|
@ -459,7 +464,7 @@ class WebView extends React.Component {
|
|||
|
||||
const messagingEnabled = typeof this.props.onMessage === 'function';
|
||||
|
||||
var webView =
|
||||
var webView = (
|
||||
<RCTWebView
|
||||
ref={RCT_WEBVIEW_REF}
|
||||
key="webViewKey"
|
||||
|
@ -469,7 +474,9 @@ class WebView extends React.Component {
|
|||
bounces={this.props.bounces}
|
||||
scrollEnabled={this.props.scrollEnabled}
|
||||
contentInset={this.props.contentInset}
|
||||
automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets}
|
||||
automaticallyAdjustContentInsets={
|
||||
this.props.automaticallyAdjustContentInsets
|
||||
}
|
||||
onLoadingStart={this._onLoadingStart}
|
||||
onLoadingFinish={this._onLoadingFinish}
|
||||
onLoadingError={this._onLoadingError}
|
||||
|
@ -478,9 +485,12 @@ class WebView extends React.Component {
|
|||
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
||||
scalesPageToFit={this.props.scalesPageToFit}
|
||||
allowsInlineMediaPlayback={this.props.allowsInlineMediaPlayback}
|
||||
mediaPlaybackRequiresUserAction={this.props.mediaPlaybackRequiresUserAction}
|
||||
mediaPlaybackRequiresUserAction={
|
||||
this.props.mediaPlaybackRequiresUserAction
|
||||
}
|
||||
dataDetectorTypes={this.props.dataDetectorTypes}
|
||||
/>;
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
@ -497,7 +507,7 @@ class WebView extends React.Component {
|
|||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.goForward,
|
||||
null
|
||||
null,
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -508,7 +518,7 @@ class WebView extends React.Component {
|
|||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.goBack,
|
||||
null
|
||||
null,
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -520,7 +530,7 @@ class WebView extends React.Component {
|
|||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.reload,
|
||||
null
|
||||
null,
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -531,7 +541,7 @@ class WebView extends React.Component {
|
|||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.stopLoading,
|
||||
null
|
||||
null,
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -545,25 +555,25 @@ class WebView extends React.Component {
|
|||
* document.addEventListener('message', e => { document.title = e.data; });
|
||||
* ```
|
||||
*/
|
||||
postMessage = (data) => {
|
||||
postMessage = data => {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.postMessage,
|
||||
[String(data)]
|
||||
[String(data)],
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Injects a javascript string into the referenced WebView. Deliberately does not
|
||||
* return a response because using eval() to return a response breaks this method
|
||||
* on pages with a Content Security Policy that disallows eval(). If you need that
|
||||
* functionality, look into postMessage/onMessage.
|
||||
*/
|
||||
injectJavaScript = (data) => {
|
||||
* Injects a javascript string into the referenced WebView. Deliberately does not
|
||||
* return a response because using eval() to return a response breaks this method
|
||||
* on pages with a Content Security Policy that disallows eval(). If you need that
|
||||
* functionality, look into postMessage/onMessage.
|
||||
*/
|
||||
injectJavaScript = data => {
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this.getWebViewHandle(),
|
||||
UIManager.RCTWebView.Commands.injectJavaScript,
|
||||
[data]
|
||||
[data],
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -599,7 +609,7 @@ class WebView extends React.Component {
|
|||
|
||||
this.setState({
|
||||
lastErrorEvent: event.nativeEvent,
|
||||
viewState: WebViewState.ERROR
|
||||
viewState: WebViewState.ERROR,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -616,7 +626,7 @@ class WebView extends React.Component {
|
|||
_onMessage = (event: Event) => {
|
||||
var {onMessage} = this.props;
|
||||
onMessage && onMessage(event);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var RCTWebView = requireNativeComponent('RCTWebView', WebView, {
|
||||
|
|
|
@ -29,7 +29,8 @@ if (__DEV__) {
|
|||
// Note: if you add any AppState subscriptions to this file,
|
||||
// you will also need to guard against `AppState.isAvailable`,
|
||||
// or the code will throw for bundles that don't have it.
|
||||
const isAppActive = () => (!AppState.isAvailable || AppState.currentState !== 'background'); // TODO(windows ISS)
|
||||
const isAppActive = () =>
|
||||
!AppState.isAvailable || AppState.currentState !== 'background'; // TODO(windows ISS)
|
||||
|
||||
// Get hostname from development server (packager)
|
||||
const devServer = getDevServer();
|
||||
|
|
|
@ -32,7 +32,10 @@ class NativeEventEmitter extends EventEmitter {
|
|||
|
||||
constructor(nativeModule: ?NativeModule) {
|
||||
super(RCTDeviceEventEmitter.sharedSubscriber);
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
invariant(nativeModule, 'Native module cannot be null.');
|
||||
this._nativeModule = nativeModule;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,10 @@ type ViewabilityHelperCallbackTuple = {
|
|||
}) => void,
|
||||
};
|
||||
|
||||
export type SelectedRowIndexPathType = { // [TODO(macOS ISS#2323203)
|
||||
// [TODO(macOS ISS#2323203)
|
||||
export type SelectedRowIndexPathType = {
|
||||
sectionIndex: number,
|
||||
rowIndex: number
|
||||
rowIndex: number,
|
||||
}; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
type RequiredProps = {
|
||||
|
@ -180,7 +181,7 @@ type OptionalProps = {
|
|||
averageItemLength: number,
|
||||
}) => void,
|
||||
/**
|
||||
* If provided, will be invoked whenever the selection on the list changes. Make sure to set
|
||||
* If provided, will be invoked whenever the selection on the list changes. Make sure to set
|
||||
* the property enableSelectionOnKeyPress to true to change selection via keyboard (macOS).
|
||||
*
|
||||
* @platform macos
|
||||
|
@ -268,7 +269,7 @@ type ChildListState = {
|
|||
type State = {
|
||||
first: number,
|
||||
last: number,
|
||||
selectedRowIndex: number // TODO(macOS ISS#2323203)
|
||||
selectedRowIndex: number, // TODO(macOS ISS#2323203)
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -419,21 +420,21 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
|
||||
// [TODO(macOS ISS#2323203)
|
||||
ensureItemAtIndexIsVisible = (rowIndex: number) => {
|
||||
const frame = this._getFrameMetricsApprox(rowIndex);
|
||||
const visTop = this._scrollMetrics.offset;
|
||||
const visLen = this._scrollMetrics.visibleLength;
|
||||
const visEnd = visTop + visLen;
|
||||
const contentLength = this._scrollMetrics.contentLength;
|
||||
const frameEnd = frame.offset + frame.length;
|
||||
|
||||
const frame = this._getFrameMetricsApprox(rowIndex);
|
||||
const visTop = this._scrollMetrics.offset;
|
||||
const visLen = this._scrollMetrics.visibleLength;
|
||||
const visEnd = visTop + visLen;
|
||||
const contentLength = this._scrollMetrics.contentLength;
|
||||
const frameEnd = frame.offset + frame.length;
|
||||
|
||||
if (frameEnd > visEnd) {
|
||||
const newOffset = Math.min(contentLength, visTop + (frameEnd - visEnd));
|
||||
this.scrollToOffset({offset : newOffset});
|
||||
this.scrollToOffset({offset: newOffset});
|
||||
} else if (frame.offset < visTop) {
|
||||
const newOffset = Math.max(0, visTop - frame.length);
|
||||
this.scrollToOffset({offset : newOffset });
|
||||
this.scrollToOffset({offset: newOffset});
|
||||
}
|
||||
}
|
||||
};
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
|
||||
recordInteraction() {
|
||||
|
@ -645,7 +646,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
this.props.getItemCount(this.props.data),
|
||||
(this.props.initialScrollIndex || 0) + this.props.initialNumToRender,
|
||||
) - 1,
|
||||
selectedRowIndex: 0 // TODO(macOS ISS#2323203)
|
||||
selectedRowIndex: 0, // TODO(macOS ISS#2323203)
|
||||
};
|
||||
|
||||
if (this._isNestedWithSameOrientation()) {
|
||||
|
@ -742,7 +743,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
index={ii}
|
||||
inversionStyle={inversionStyle}
|
||||
item={item}
|
||||
isSelected={ this.state.selectedRowIndex == ii ? true : false } // TODO(macOS ISS#2323203)
|
||||
isSelected={this.state.selectedRowIndex == ii ? true : false} // TODO(macOS ISS#2323203)
|
||||
key={key}
|
||||
prevCellKey={prevCellKey}
|
||||
onUpdateSeparators={this._onUpdateSeparators}
|
||||
|
@ -1080,7 +1081,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
_defaultRenderScrollComponent = props => {
|
||||
let keyEventHandler = this.props.onKeyDown; // [TODO(macOS ISS#2323203)
|
||||
if (!keyEventHandler) {
|
||||
keyEventHandler = this.props.enableSelectionOnKeyPress ? this._handleKeyDown : null;
|
||||
keyEventHandler = this.props.enableSelectionOnKeyPress
|
||||
? this._handleKeyDown
|
||||
: null;
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
const onRefresh = props.onRefresh;
|
||||
if (this._isNestedWithSameOrientation()) {
|
||||
|
@ -1092,7 +1095,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
'`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
|
||||
JSON.stringify(props.refreshing) +
|
||||
'`',
|
||||
);
|
||||
);
|
||||
return (
|
||||
// $FlowFixMe Invalid prop usage
|
||||
<ScrollView
|
||||
|
@ -1231,67 +1234,76 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|||
};
|
||||
|
||||
// [TODO(macOS ISS#2323203)
|
||||
_selectRowAboveIndex = (rowIndex) => {
|
||||
_selectRowAboveIndex = rowIndex => {
|
||||
const rowAbove = rowIndex > 0 ? rowIndex - 1 : rowIndex;
|
||||
this.setState( state => { return {selectedRowIndex: rowAbove}; });
|
||||
this.setState(state => {
|
||||
return {selectedRowIndex: rowAbove};
|
||||
});
|
||||
return rowAbove;
|
||||
}
|
||||
|
||||
_selectRowBelowIndex = (rowIndex) => {
|
||||
};
|
||||
|
||||
_selectRowBelowIndex = rowIndex => {
|
||||
if (this.props.getItemCount) {
|
||||
const {data} = this.props;
|
||||
const itemCount = this.props.getItemCount(data);
|
||||
const rowBelow = rowIndex < (itemCount - 1) ? rowIndex + 1 : rowIndex;
|
||||
this.setState( state => { return {selectedRowIndex: rowBelow}; });
|
||||
const rowBelow = rowIndex < itemCount - 1 ? rowIndex + 1 : rowIndex;
|
||||
this.setState(state => {
|
||||
return {selectedRowIndex: rowBelow};
|
||||
});
|
||||
return rowBelow;
|
||||
} else {
|
||||
return rowIndex;
|
||||
}
|
||||
}
|
||||
|
||||
_handleKeyDown = (e) => {
|
||||
};
|
||||
|
||||
_handleKeyDown = e => {
|
||||
if (this.props.onKeyDown) {
|
||||
this.props.onKeyDown(e);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (Platform.OS === 'macos') {
|
||||
const event = e['nativeEvent'];
|
||||
const key = event['key'];
|
||||
|
||||
const event = e.nativeEvent;
|
||||
const key = event.key;
|
||||
|
||||
let prevIndex = -1;
|
||||
let newIndex = -1;
|
||||
if ("selectedRowIndex" in this.state) {
|
||||
prevIndex = this.state.selectedRowIndex;
|
||||
if ('selectedRowIndex' in this.state) {
|
||||
prevIndex = this.state.selectedRowIndex;
|
||||
}
|
||||
|
||||
const {data, getItem} = this.props;
|
||||
if (key === 'DOWN_ARROW') {
|
||||
newIndex = this._selectRowBelowIndex(prevIndex);
|
||||
this.ensureItemAtIndexIsVisible(newIndex);
|
||||
|
||||
if (this.props.onSelectionChanged && prevIndex != newIndex) {
|
||||
const item = getItem(data, newIndex);
|
||||
this.props.onSelectionChanged( {previousSelection: prevIndex, newSelection: newIndex, item: item});
|
||||
}
|
||||
}
|
||||
else if (key === 'UP_ARROW') {
|
||||
newIndex = this._selectRowAboveIndex(prevIndex);
|
||||
this.ensureItemAtIndexIsVisible(newIndex);
|
||||
|
||||
if (this.props.onSelectionChanged && prevIndex != newIndex) {
|
||||
const item = getItem(data, newIndex);
|
||||
this.props.onSelectionChanged( {previousSelection: prevIndex, newSelection: newIndex, item: item});
|
||||
}
|
||||
}
|
||||
else if (key === 'ENTER') {
|
||||
if (this.props.onSelectionEntered) {
|
||||
const item = getItem(data, prevIndex);
|
||||
this.props.onSelectionEntered(item);
|
||||
}
|
||||
newIndex = this._selectRowBelowIndex(prevIndex);
|
||||
this.ensureItemAtIndexIsVisible(newIndex);
|
||||
|
||||
if (this.props.onSelectionChanged && prevIndex != newIndex) {
|
||||
const item = getItem(data, newIndex);
|
||||
this.props.onSelectionChanged({
|
||||
previousSelection: prevIndex,
|
||||
newSelection: newIndex,
|
||||
item: item,
|
||||
});
|
||||
}
|
||||
} else if (key === 'UP_ARROW') {
|
||||
newIndex = this._selectRowAboveIndex(prevIndex);
|
||||
this.ensureItemAtIndexIsVisible(newIndex);
|
||||
|
||||
if (this.props.onSelectionChanged && prevIndex != newIndex) {
|
||||
const item = getItem(data, newIndex);
|
||||
this.props.onSelectionChanged({
|
||||
previousSelection: prevIndex,
|
||||
newSelection: newIndex,
|
||||
item: item,
|
||||
});
|
||||
}
|
||||
} else if (key === 'ENTER') {
|
||||
if (this.props.onSelectionEntered) {
|
||||
const item = getItem(data, prevIndex);
|
||||
this.props.onSelectionEntered(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
|
||||
_renderDebugOverlay() {
|
||||
|
|
|
@ -19,7 +19,7 @@ const invariant = require('fbjs/lib/invariant');
|
|||
import type {ViewToken} from 'ViewabilityHelper';
|
||||
import type {
|
||||
Props as VirtualizedListProps,
|
||||
SelectedRowIndexPathType // TODO(macOS ISS#2323203)
|
||||
SelectedRowIndexPathType, // TODO(macOS ISS#2323203)
|
||||
} from 'VirtualizedList';
|
||||
|
||||
type Item = any;
|
||||
|
@ -115,7 +115,7 @@ type OptionalProps<SectionT: SectionBase> = {
|
|||
*/
|
||||
onRefresh?: ?() => void,
|
||||
/**
|
||||
* If provided, processes key press and mouse click events to update selection state
|
||||
* If provided, processes key press and mouse click events to update selection state
|
||||
* and invokes the provided function to notify of selection state changes.
|
||||
*
|
||||
* @platform macos
|
||||
|
@ -150,7 +150,7 @@ type DefaultProps = typeof VirtualizedList.defaultProps & {
|
|||
};
|
||||
type State = {
|
||||
childProps: VirtualizedListProps,
|
||||
selectedRowIndexPath: SelectedRowIndexPathType // TODO(macOS ISS#2323203)
|
||||
selectedRowIndexPath: SelectedRowIndexPathType, // TODO(macOS ISS#2323203)
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -224,104 +224,124 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
|
|||
selectedRowIndexPath: {sectionIndex: 0, rowIndex: -1}, // TODO(macOS ISS#2323203)
|
||||
};
|
||||
}
|
||||
_selectRowAboveIndexPath = (rowIndexPath) => { // [TODO(macOS ISS#2323203)
|
||||
// [TODO(macOS ISS#2323203)
|
||||
_selectRowAboveIndexPath = rowIndexPath => {
|
||||
let sectionIndex = rowIndexPath.sectionIndex;
|
||||
if (sectionIndex >= this.props.sections.length) {
|
||||
return rowIndexPath;
|
||||
}
|
||||
|
||||
|
||||
const count = this.props.sections[sectionIndex].data.length;
|
||||
let row = rowIndexPath.rowIndex;
|
||||
let rowAbove = row - 1;
|
||||
|
||||
|
||||
if (rowAbove < 0) {
|
||||
if (sectionIndex > 0) {
|
||||
sectionIndex = sectionIndex - 1;
|
||||
rowAbove = Math.max(0, this.props.sections[sectionIndex].data.length - 1);
|
||||
} else {
|
||||
rowAbove = row;
|
||||
}
|
||||
if (sectionIndex > 0) {
|
||||
sectionIndex = sectionIndex - 1;
|
||||
rowAbove = Math.max(
|
||||
0,
|
||||
this.props.sections[sectionIndex].data.length - 1,
|
||||
);
|
||||
} else {
|
||||
rowAbove = row;
|
||||
}
|
||||
}
|
||||
const nextIndexPath = {sectionIndex: sectionIndex, rowIndex: rowAbove};
|
||||
this.setState( state => { return {selectedRowIndexPath: nextIndexPath}; });
|
||||
this.setState(state => {
|
||||
return {selectedRowIndexPath: nextIndexPath};
|
||||
});
|
||||
return nextIndexPath;
|
||||
}
|
||||
|
||||
_selectRowBelowIndexPath = (rowIndexPath) => {
|
||||
};
|
||||
|
||||
_selectRowBelowIndexPath = rowIndexPath => {
|
||||
let sectionIndex = rowIndexPath.sectionIndex;
|
||||
if (sectionIndex >= this.props.sections.length) {
|
||||
return rowIndexPath;
|
||||
}
|
||||
|
||||
|
||||
const count = this.props.sections[sectionIndex].data.length;
|
||||
let row = rowIndexPath.rowIndex;
|
||||
let rowBelow = row + 1;
|
||||
|
||||
|
||||
if (rowBelow > count - 1) {
|
||||
if (sectionIndex < this.props.sections.length - 1) {
|
||||
sectionIndex = sectionIndex + 1;
|
||||
rowBelow = 0;
|
||||
}
|
||||
else {
|
||||
rowBelow = row;
|
||||
}
|
||||
if (sectionIndex < this.props.sections.length - 1) {
|
||||
sectionIndex = sectionIndex + 1;
|
||||
rowBelow = 0;
|
||||
} else {
|
||||
rowBelow = row;
|
||||
}
|
||||
}
|
||||
const nextIndexPath = {sectionIndex: sectionIndex, rowIndex: rowBelow};
|
||||
this.setState( state => { return {selectedRowIndexPath: nextIndexPath}; });
|
||||
this.setState(state => {
|
||||
return {selectedRowIndexPath: nextIndexPath};
|
||||
});
|
||||
return nextIndexPath;
|
||||
}
|
||||
|
||||
_ensureItemAtIndexPathIsVisible = (rowIndexPath) => {
|
||||
};
|
||||
|
||||
_ensureItemAtIndexPathIsVisible = rowIndexPath => {
|
||||
let index = rowIndexPath.rowIndex + 1;
|
||||
for (let ii = 0; ii < rowIndexPath.sectionIndex; ii++) {
|
||||
index += this.props.sections[ii].data.length + 2;
|
||||
}
|
||||
this._listRef.ensureItemAtIndexIsVisible(index);
|
||||
}
|
||||
|
||||
_handleKeyDown = (e) => {
|
||||
};
|
||||
|
||||
_handleKeyDown = e => {
|
||||
if (Platform.OS === 'macos') {
|
||||
const event = e['nativeEvent'];
|
||||
const key = event['key'];
|
||||
const event = e.nativeEvent;
|
||||
const key = event.key;
|
||||
let prevIndexPath = this.state.selectedRowIndexPath;
|
||||
let nextIndexPath = null;
|
||||
const sectionIndex = this.state.selectedRowIndexPath.sectionIndex;
|
||||
const rowIndex = this.state.selectedRowIndexPath.rowIndex;
|
||||
|
||||
|
||||
if (key === 'DOWN_ARROW') {
|
||||
nextIndexPath = this._selectRowBelowIndexPath(prevIndexPath);
|
||||
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
||||
|
||||
if (this.props.onSelectionChanged) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionChanged( {previousSelection: prevIndexPath, newSelection: nextIndexPath, item: item});
|
||||
}
|
||||
}
|
||||
else if (key === 'UP_ARROW') {
|
||||
nextIndexPath = this._selectRowAboveIndexPath(prevIndexPath);
|
||||
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
||||
|
||||
if (this.props.onSelectionChanged) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionChanged( {previousSelection: prevIndexPath, newSelection: nextIndexPath, item: item});
|
||||
}
|
||||
}
|
||||
else if (key === 'ENTER') {
|
||||
if (this.props.onSelectionEntered) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionEntered(item);
|
||||
}
|
||||
nextIndexPath = this._selectRowBelowIndexPath(prevIndexPath);
|
||||
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
||||
|
||||
if (this.props.onSelectionChanged) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionChanged({
|
||||
previousSelection: prevIndexPath,
|
||||
newSelection: nextIndexPath,
|
||||
item: item,
|
||||
});
|
||||
}
|
||||
} else if (key === 'UP_ARROW') {
|
||||
nextIndexPath = this._selectRowAboveIndexPath(prevIndexPath);
|
||||
this._ensureItemAtIndexPathIsVisible(nextIndexPath);
|
||||
|
||||
if (this.props.onSelectionChanged) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionChanged({
|
||||
previousSelection: prevIndexPath,
|
||||
newSelection: nextIndexPath,
|
||||
item: item,
|
||||
});
|
||||
}
|
||||
} else if (key === 'ENTER') {
|
||||
if (this.props.onSelectionEntered) {
|
||||
const item = this.props.sections[sectionIndex].data[rowIndex];
|
||||
this.props.onSelectionEntered(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
}; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
render() {
|
||||
let keyEventHandler = this.props.onKeyDown; // [TODO(macOS ISS#2323203)
|
||||
if (!keyEventHandler) {
|
||||
keyEventHandler = this.props.enableSelectionOnKeyPress ? this._handleKeyDown : null;
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
return (
|
||||
<VirtualizedList {...this.state.childProps} ref={this._captureRef} onKeyDown={keyEventHandler} {...this.state.selectedRowIndexPath} /> // TODO(macOS ISS#2323203)
|
||||
let keyEventHandler = this.props.onKeyDown; // [TODO(macOS ISS#2323203)
|
||||
if (!keyEventHandler) {
|
||||
keyEventHandler = this.props.enableSelectionOnKeyPress
|
||||
? this._handleKeyDown
|
||||
: null;
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
return (
|
||||
<VirtualizedList
|
||||
{...this.state.childProps}
|
||||
ref={this._captureRef}
|
||||
onKeyDown={keyEventHandler}
|
||||
{...this.state.selectedRowIndexPath}
|
||||
/> // TODO(macOS ISS#2323203)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -417,22 +437,21 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
|
|||
};
|
||||
|
||||
// [TODO(macOS ISS#2323203)
|
||||
_isItemSelected = (item: Item) : boolean => {
|
||||
let isSelected = false;
|
||||
if (this.state.selectedRowIndexPath)
|
||||
{
|
||||
const selection = this.state.selectedRowIndexPath;
|
||||
const sections = this.props.sections;
|
||||
if (sections && selection.sectionIndex < sections.length) {
|
||||
const section = sections[selection.sectionIndex];
|
||||
if (selection.rowIndex < section.data.length) {
|
||||
const selectedItem = section.data[selection.rowIndex];
|
||||
isSelected = (item == selectedItem);
|
||||
}
|
||||
}
|
||||
_isItemSelected = (item: Item): boolean => {
|
||||
let isSelected = false;
|
||||
if (this.state.selectedRowIndexPath) {
|
||||
const selection = this.state.selectedRowIndexPath;
|
||||
const sections = this.props.sections;
|
||||
if (sections && selection.sectionIndex < sections.length) {
|
||||
const section = sections[selection.sectionIndex];
|
||||
if (selection.rowIndex < section.data.length) {
|
||||
const selectedItem = section.data[selection.rowIndex];
|
||||
isSelected = item == selectedItem;
|
||||
}
|
||||
}
|
||||
return isSelected;
|
||||
}
|
||||
}
|
||||
return isSelected;
|
||||
};
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
|
||||
_renderItem = ({item, index}: {item: Item, index: number}) => {
|
||||
|
|
|
@ -57,7 +57,10 @@ type ConnectivityStateAndroid = $Enum<{
|
|||
const _subscriptions = new Map();
|
||||
|
||||
let _isConnectedDeprecated;
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
_isConnectedDeprecated = function(
|
||||
reachability: ReachabilityStateIOS,
|
||||
): boolean {
|
||||
|
|
|
@ -14,7 +14,10 @@ const Platform = require('Platform');
|
|||
let requestId = 1;
|
||||
|
||||
function setRequestId(id) {
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
return;
|
||||
}
|
||||
requestId = id;
|
||||
|
|
|
@ -235,7 +235,9 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
if (expectErrorBlock) {
|
||||
RCTAssert(expectErrorBlock(errors[0]), @"Expected an error but the first one was missing or did not match.");
|
||||
} else {
|
||||
RCTAssert(errors == nil, @"RedBox errors: %@", errors);
|
||||
// [TODO(OSS Candidate ISS#2710739): xcpretty formats the test failure output to show only one line of the assert string followed by a snippet of source code including the assert statement and the lines just before and after.
|
||||
// Convert the `errors` array into a single line string delimited by \n so that CI logs contain meaningful information.
|
||||
RCTAssert(errors == nil, @"RedBox errors: %@", [[errors valueForKey:@"description"] componentsJoinedByString:@"\\n"]); // ]TODO(OSS Candidate ISS#2710739)
|
||||
RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds);
|
||||
RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed");
|
||||
}
|
||||
|
|
|
@ -118,7 +118,10 @@ function lazifyViewManagerConfig(viewName) {
|
|||
* only needed for iOS, which puts the constants in the ViewManager
|
||||
* namespace instead of UIManager, unlike Android.
|
||||
*/
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
Object.keys(UIManager).forEach(viewName => {
|
||||
lazifyViewManagerConfig(viewName);
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ const resolveAssetSource = require('resolveAssetSource');
|
|||
const sizesDiffer = require('sizesDiffer');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
const warning = require('fbjs/lib/warning');
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor' // ]TODO(macOS ISS#2323203)
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
function getNativeComponentAttributes(uiViewClassName: string) {
|
||||
const viewConfig = UIManager.getViewManagerConfig(uiViewClassName);
|
||||
|
@ -182,7 +182,10 @@ function getProcessorForType(typeName: string): ?(nextProp: any) => any {
|
|||
return null;
|
||||
}
|
||||
|
||||
function processColorArray(colors: ?Array<any>): ?Array<?(number | SemanticOrDynamicColorType)> { // ]TODO(macOS ISS#2323203)
|
||||
function processColorArray(
|
||||
colors: ?Array<any>,
|
||||
): ?Array<?(number | SemanticOrDynamicColorType)> {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
return colors == null ? null : colors.map(processColor);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,10 @@ export type LayoutStyle = ____LayoutStyle_Internal;
|
|||
export type ShadowStyle = ____ShadowStyle_Internal;
|
||||
export type TransformStyle = ____TransformStyle_Internal;
|
||||
|
||||
let hairlineWidth = (Platform.OS === 'win32' || Platform.OS === 'windesktop') ? 0.5 : PixelRatio.roundToNearestPixel(0.4); // TODO(windows ISS)
|
||||
let hairlineWidth =
|
||||
Platform.OS === 'win32' || Platform.OS === 'windesktop'
|
||||
? 0.5
|
||||
: PixelRatio.roundToNearestPixel(0.4); // TODO(windows ISS)
|
||||
if (hairlineWidth === 0) {
|
||||
hairlineWidth = 1 / PixelRatio.get();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
'use strict';
|
||||
|
||||
const AnimatedNode = require('AnimatedNode');
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor' // TODO(macOS ISS#2323203)
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // TODO(macOS ISS#2323203)
|
||||
|
||||
export type ColorValue = null | string | SemanticOrDynamicColorType; // TODO(macOS ISS#2323203)
|
||||
export type DimensionValue = null | number | string | AnimatedNode;
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
const Platform = require('Platform');
|
||||
|
||||
const normalizeColor = require('normalizeColor');
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor' // ]TODO(macOS ISS#2323203)
|
||||
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
|
||||
|
||||
/* eslint no-bitwise: 0 */
|
||||
function processColor(color?: ?(string | number | SemanticOrDynamicColorType)): ?(number | SemanticOrDynamicColorType) { // TODO(macOS ISS#2323203)
|
||||
function processColor(
|
||||
color?: ?(string | number | SemanticOrDynamicColorType),
|
||||
): ?(number | SemanticOrDynamicColorType) /* TODO(macOS ISS#2323203) */ {
|
||||
if (color === undefined || color === null) {
|
||||
return color;
|
||||
}
|
||||
|
@ -26,14 +28,17 @@ function processColor(color?: ?(string | number | SemanticOrDynamicColorType)):
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof int32Color === 'object' && Platform.OS === 'macos') { // [TODO(macOS ISS#2323203)
|
||||
if (
|
||||
typeof int32Color === 'object' &&
|
||||
Platform.OS === 'macos' /* [TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
if ('dynamic' in int32Color && int32Color.dynamic !== undefined) {
|
||||
const dynamic = int32Color.dynamic;
|
||||
const dynamicColor = {
|
||||
dynamic: {
|
||||
light: processColor(dynamic.light),
|
||||
dark: processColor(dynamic.dark)
|
||||
}
|
||||
dark: processColor(dynamic.dark),
|
||||
},
|
||||
};
|
||||
return dynamicColor;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,11 @@ function processTransform(
|
|||
// Android & iOS implementations of transform property accept the list of
|
||||
// transform properties as opposed to a transform Matrix. This is necessary
|
||||
// to control transform property updates completely on the native thread.
|
||||
if (Platform.OS === 'android' || Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'android' ||
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
return transform;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,16 @@ static UIColor *defaultPlaceholderColor()
|
|||
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
return [self.window makeFirstResponder:self];
|
||||
BOOL success = [[self window] makeFirstResponder:self];
|
||||
|
||||
if (success) {
|
||||
id<RCTBackedTextInputDelegate> textInputDelegate = [self textInputDelegate];
|
||||
if ([textInputDelegate respondsToSelector:@selector(textInputDidBeginEditing)]) {
|
||||
[textInputDelegate textInputDidBeginEditing];
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
#endif // ]TODO(macOS ISS#2323203)
|
||||
|
|
|
@ -305,15 +305,6 @@ static UIColor *defaultPlaceholderTextColor()
|
|||
|
||||
#pragma mark - NSTextViewDelegate methods
|
||||
|
||||
- (void)textDidBeginEditing:(NSNotification *)notification
|
||||
{
|
||||
[super textDidBeginEditing:notification];
|
||||
id<RCTUITextFieldDelegate> delegate = self.delegate;
|
||||
if ([delegate respondsToSelector:@selector(textFieldBeginEditing:)]) {
|
||||
[delegate textFieldBeginEditing:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)textDidChange:(NSNotification *)notification
|
||||
{
|
||||
[super textDidChange:notification];
|
||||
|
@ -358,6 +349,15 @@ static UIColor *defaultPlaceholderTextColor()
|
|||
{
|
||||
BOOL isFirstResponder = [super becomeFirstResponder];
|
||||
if (isFirstResponder) {
|
||||
id<RCTUITextFieldDelegate> delegate = self.delegate;
|
||||
if ([delegate respondsToSelector:@selector(textFieldBeginEditing:)]) {
|
||||
// The AppKit -[NSTextField textDidBeginEditing:] notification is only called when the user
|
||||
// makes the first change to the text in the text field.
|
||||
// The react-native -[RCTUITextFieldDelegate textFieldBeginEditing:] is intended to be
|
||||
// called when the text field is focused so call it here in becomeFirstResponder.
|
||||
[delegate textFieldBeginEditing:self];
|
||||
}
|
||||
|
||||
NSScrollView *scrollView = [self enclosingScrollView];
|
||||
if (scrollView != nil) {
|
||||
NSRect visibleRect = [[scrollView documentView] convertRect:self.frame fromView:self];
|
||||
|
|
|
@ -48,7 +48,10 @@ const HMRClient = {
|
|||
Try the following to fix the issue:
|
||||
- Ensure that the packager server is running and available on the same network`;
|
||||
|
||||
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
|
||||
if (
|
||||
Platform.OS === 'ios' ||
|
||||
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
|
||||
) {
|
||||
error += `
|
||||
- Ensure that the Packager server URL is correctly set in AppDelegate`;
|
||||
} else {
|
||||
|
|
|
@ -220,7 +220,11 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) {
|
|||
}
|
||||
|
||||
_close(code?: number, reason?: string): void {
|
||||
if (Platform.OS === 'android') {
|
||||
if (
|
||||
Platform.OS === 'android' ||
|
||||
Platform.OS === 'win32' ||
|
||||
Platform.OS === 'windesktop'
|
||||
) {
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
||||
const statusCode = typeof code === 'number' ? code : CLOSE_NORMAL;
|
||||
const closeReason = typeof reason === 'string' ? reason : '';
|
||||
|
|
|
@ -36,10 +36,13 @@ type State = {|
|
|||
|};
|
||||
|
||||
const VIEWPORT_RATIO = 0.5;
|
||||
const MAX_ITEMS = (Platform.OS === 'win32' || Platform.OS === 'windesktop') ? 3 : Math.floor( // TODO(windows ISS)
|
||||
(Dimensions.get('window').height * VIEWPORT_RATIO) /
|
||||
(YellowBoxListRow.GUTTER + YellowBoxListRow.HEIGHT),
|
||||
);
|
||||
const MAX_ITEMS =
|
||||
Platform.OS === 'win32' || Platform.OS === 'windesktop'
|
||||
? 3
|
||||
: Math.floor(
|
||||
(Dimensions.get('window').height * VIEWPORT_RATIO) /
|
||||
(YellowBoxListRow.GUTTER + YellowBoxListRow.HEIGHT),
|
||||
); // TODO(windows ISS)
|
||||
|
||||
class YellowBoxList extends React.Component<Props, State> {
|
||||
state = {
|
||||
|
|
|
@ -220,7 +220,8 @@ module.exports = {
|
|||
get DatePickerAndroid() {
|
||||
return require('DatePickerAndroid');
|
||||
},
|
||||
get DatePickerMacOS() { // [TODO(macOS ISS#2323203)
|
||||
// [TODO(macOS ISS#2323203)
|
||||
get DatePickerMacOS() {
|
||||
return require('DatePickerMacOS');
|
||||
}, // ]TODO(macOS ISS#2323203)
|
||||
get DeviceInfo() {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildSystemType</key>
|
||||
<string>Original</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -60,7 +60,7 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
|
|||
|
||||
class ShareActionSheetExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
|
||||
state = {
|
||||
text: ''
|
||||
text: '',
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@ -82,8 +82,8 @@ class ShareActionSheetExample extends React.Component<$FlowFixMeProps, $FlowFixM
|
|||
message: 'message to go with the shared url',
|
||||
subject: 'a subject to go in the email heading',
|
||||
excludedActivityTypes: [
|
||||
'com.apple.share.Twitter.post'
|
||||
]
|
||||
'com.apple.share.Twitter.post',
|
||||
],
|
||||
},
|
||||
(error) => alert(error),
|
||||
(completed, method) => {
|
||||
|
@ -102,7 +102,7 @@ var style = StyleSheet.create({
|
|||
button: {
|
||||
marginBottom: 10,
|
||||
fontWeight: '500',
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
exports.title = 'ActionSheetIOS';
|
||||
|
@ -110,18 +110,18 @@ exports.description = 'Interface to show iOS\' action sheets';
|
|||
exports.examples = [
|
||||
{
|
||||
title: 'Show Action Sheet',
|
||||
render(): React.Element<any> { return <ActionSheetExample />; }
|
||||
render(): React.Element<any> { return <ActionSheetExample />; },
|
||||
},
|
||||
{
|
||||
title: 'Show Share Action Sheet',
|
||||
render(): React.Element<any> {
|
||||
return <ShareActionSheetExample url="https://code.facebook.com" />;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Share Local Image',
|
||||
render(): React.Element<any> {
|
||||
return <ShareActionSheetExample url="bunny.png" />;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
import React, {Component} from 'react';
|
||||
import {ActivityIndicator, StyleSheet, View} from 'react-native';
|
||||
const Platform = require('Platform');
|
||||
|
||||
/**
|
||||
* Optional Flowtype state and timer types definition
|
||||
|
@ -100,8 +101,18 @@ exports.examples = [
|
|||
render() {
|
||||
return (
|
||||
<View style={styles.horizontal}>
|
||||
<ActivityIndicator color="#0000ff" />
|
||||
<ActivityIndicator color="#aa00aa" />
|
||||
<ActivityIndicator
|
||||
color={
|
||||
Platform.OS === 'macos'
|
||||
? {dynamic: {light: 'black', dark: 'white'}}
|
||||
: '#0000ff'
|
||||
}
|
||||
/>
|
||||
<ActivityIndicator
|
||||
color={
|
||||
Platform.OS === 'macos' ? {semantic: 'textColor'} : '#aa00aa'
|
||||
}
|
||||
/>
|
||||
<ActivityIndicator color="#aa3300" />
|
||||
<ActivityIndicator color="#00aa00" />
|
||||
</View>
|
||||
|
@ -149,7 +160,7 @@ exports.examples = [
|
|||
size="large"
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
platform: 'android',
|
||||
|
@ -185,5 +196,13 @@ const styles = StyleSheet.create({
|
|||
flexDirection: 'row',
|
||||
justifyContent: 'space-around',
|
||||
padding: 8,
|
||||
...Platform.select({
|
||||
macos: {
|
||||
backgroundColor: {semantic: 'windowBackgroundColor'},
|
||||
},
|
||||
default: {
|
||||
backgroundColor: undefined,
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
|
|
@ -27,13 +27,13 @@ exports.examples = [{
|
|||
title: 'Alerts',
|
||||
render() {
|
||||
return <SimpleAlertExampleBlock />;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Prompt Options',
|
||||
render(): React.Element<any> {
|
||||
return <PromptOptions />;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Prompt Types',
|
||||
|
@ -84,7 +84,7 @@ exports.examples = [{
|
|||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Prompt Presentation',
|
||||
|
@ -133,7 +133,7 @@ exports.examples = [{
|
|||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Prompt Style',
|
||||
|
@ -179,7 +179,7 @@ exports.examples = [{
|
|||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -195,7 +195,7 @@ class PromptOptions extends React.Component<$FlowFixMeProps, any> {
|
|||
|
||||
this.customButtons = [{
|
||||
text: 'Custom OK',
|
||||
onPress: this.saveResponse
|
||||
onPress: this.saveResponse,
|
||||
}, {
|
||||
text: 'Custom Cancel',
|
||||
style: 'cancel',
|
||||
|
|
|
@ -128,7 +128,7 @@ exports.examples = [
|
|||
Animated.parallel([
|
||||
Easing.inOut(Easing.quad), // Symmetric
|
||||
Easing.back(1.5), // Goes backwards first
|
||||
Easing.ease // Default bezier
|
||||
Easing.ease, // Default bezier
|
||||
].map((easing, ii) => (
|
||||
timing(this.anims[ii], {
|
||||
toValue: 320, easing, duration: 3000,
|
||||
|
@ -150,7 +150,7 @@ exports.examples = [
|
|||
<Animated.View
|
||||
key={text}
|
||||
style={[styles.content, {
|
||||
left: this.anims[ii]
|
||||
left: this.anims[ii],
|
||||
}]}>
|
||||
<Text>{text}</Text>
|
||||
</Animated.View>
|
||||
|
@ -168,7 +168,7 @@ exports.examples = [
|
|||
render: () => (
|
||||
<Text>Checkout the Gratuitous Animation App!</Text>
|
||||
),
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
|
|
|
@ -44,13 +44,13 @@ class DatePickerExample extends React.Component<
|
|||
// Ideally, the timezone input would be a picker rather than a
|
||||
// text input, but we don't have any pickers yet :(
|
||||
return (
|
||||
<View style=
|
||||
{{
|
||||
flex: 1,
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'gray'
|
||||
}}>
|
||||
backgroundColor: 'gray',
|
||||
}}>
|
||||
<WithLabel label="Value:">
|
||||
<Text testID="date-and-time-indicator">
|
||||
{this.state.date.toLocaleDateString() +
|
||||
|
|
|
@ -201,11 +201,11 @@ class FlatListExample extends React.PureComponent<{}, $FlowFixMeState> {
|
|||
this._listRef.getNode().recordInteraction();
|
||||
pressItem(this, key);
|
||||
};
|
||||
_handleSelectionEntered = (item) => {
|
||||
_handleSelectionEntered = item => {
|
||||
const {key} = item;
|
||||
this._listRef.getNode().recordInteraction();
|
||||
pressItem(this, key);
|
||||
}
|
||||
};
|
||||
_listRef: Animated.FlatList;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var Platform = require('Platform');
|
|||
var {StyleSheet, Text, View, TextInput} = ReactNative;
|
||||
|
||||
type State = {
|
||||
eventStream: string;
|
||||
eventStream: string,
|
||||
};
|
||||
|
||||
class FocusEventExample extends React.Component<{}, State> {
|
||||
|
@ -28,38 +28,158 @@ class FocusEventExample extends React.Component<{}, State> {
|
|||
return (
|
||||
<View>
|
||||
<Text>
|
||||
Focus events are called when a component receives or loses focus.
|
||||
This can be acquired by manually focusing components {Platform.OS === 'macos' ? ' or using tab-based nav' : '' }
|
||||
Focus events are called when a component receives or loses focus. This
|
||||
can be acquired by manually focusing components
|
||||
{Platform.OS === 'macos' ? ' or using tab-based nav' : ''}
|
||||
</Text>
|
||||
<View>
|
||||
<TextInput
|
||||
onFocus={() => {
|
||||
this.setState((prevState) => ({ eventStream: prevState.eventStream + '\nTextInput Focus' }));
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nTextInput Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState((prevState) => ({ eventStream: prevState.eventStream + '\nTextInput Blur' }));
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nTextInput Blur',
|
||||
}));
|
||||
}}
|
||||
style={styles.default}
|
||||
placeholder={'TextInput'}
|
||||
placeholderTextColor={
|
||||
Platform.OS === 'macos' ? {semantic: 'textColor'} : 'black'
|
||||
}
|
||||
style={styles.textInput}
|
||||
/>
|
||||
|
||||
|
||||
{// Only test View on MacOS, since canBecomeFirstResponder is false on all iOS, therefore we can't focus
|
||||
Platform.OS === 'macos' ?
|
||||
<View style={styles.default}
|
||||
acceptsKeyboardFocus={true}onFocus={() => {
|
||||
this.setState((prevState) => ({ eventStream: prevState.eventStream + '\nView Focus' }));
|
||||
Platform.OS === 'macos' ? (
|
||||
<View
|
||||
acceptsKeyboardFocus={true}
|
||||
enableFocusRing={true}
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nView Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState((prevState) => ({ eventStream: prevState.eventStream + '\nView Blur' }));
|
||||
}}
|
||||
>
|
||||
<Text>
|
||||
Focusable View
|
||||
</Text>
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nView Blur',
|
||||
}));
|
||||
}}>
|
||||
<Text>Focusable View</Text>
|
||||
</View>
|
||||
: null}
|
||||
<Text>
|
||||
{'Events: ' + this.state.eventStream + '\n\n'}
|
||||
</Text>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Singleline TextInput Parent Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Singleline TextInput Parent Blur',
|
||||
}));
|
||||
}}>
|
||||
<TextInput
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Singleline TextInput Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Singleline TextInput Blur',
|
||||
}));
|
||||
}}
|
||||
style={styles.textInput}
|
||||
placeholder={'Nested Singleline TextInput'}
|
||||
placeholderTextColor={
|
||||
Platform.OS === 'macos' ? {semantic: 'textColor'} : 'black'
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{// Only test View on MacOS, since canBecomeFirstResponder is false on all iOS, therefore we can't focus
|
||||
Platform.OS === 'macos' ? (
|
||||
<View
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream + '\nNested View Parent Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream + '\nNested View Parent Blur',
|
||||
}));
|
||||
}}>
|
||||
<View
|
||||
acceptsKeyboardFocus={true}
|
||||
enableFocusRing={true}
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nNested View Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream: prevState.eventStream + '\nNested View Blur',
|
||||
}));
|
||||
}}>
|
||||
<Text>Nested Focusable View</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Multiline TextInput Parent Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Multiline TextInput Parent Blur',
|
||||
}));
|
||||
}}>
|
||||
<TextInput
|
||||
onFocus={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream +
|
||||
'\nNested Multiline TextInput Focus',
|
||||
}));
|
||||
}}
|
||||
onBlur={() => {
|
||||
this.setState(prevState => ({
|
||||
eventStream:
|
||||
prevState.eventStream + '\nNested Multiline TextInput Blur',
|
||||
}));
|
||||
}}
|
||||
style={styles.textInput}
|
||||
multiline={true}
|
||||
placeholder={'Nested Multiline TextInput'}
|
||||
placeholderTextColor={
|
||||
Platform.OS === 'macos' ? {semantic: 'textColor'} : 'black'
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Text>{'Events: ' + this.state.eventStream + '\n\n'}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
@ -67,9 +187,18 @@ class FocusEventExample extends React.Component<{}, State> {
|
|||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
default: {
|
||||
textInput: {
|
||||
...Platform.select({
|
||||
macos: {
|
||||
color: {semantic: 'textColor'},
|
||||
backgroundColor: {semantic: 'textBackgroundColor'},
|
||||
borderColor: {semantic: 'gridColor'},
|
||||
},
|
||||
default: {
|
||||
borderColor: '#0f0f0f',
|
||||
},
|
||||
}),
|
||||
borderWidth: StyleSheet.hairlineWidth,
|
||||
borderColor: '#0f0f0f',
|
||||
flex: 1,
|
||||
fontSize: 13,
|
||||
padding: 4,
|
||||
|
@ -77,8 +206,7 @@ var styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
exports.title = 'Focus Events';
|
||||
exports.description =
|
||||
'Examples that show how Focus events can be used.';
|
||||
exports.description = 'Examples that show how Focus events can be used.';
|
||||
exports.examples = [
|
||||
{
|
||||
title: 'FocusEventExample',
|
||||
|
|
|
@ -19,20 +19,19 @@ const {Image, StyleSheet, Text, View} = ReactNative;
|
|||
|
||||
class ImageCapInsetsExample extends React.Component<{}> {
|
||||
render() {
|
||||
|
||||
let nativeImage;
|
||||
if (Platform.OS === 'macos') {
|
||||
nativeImage = nativeImageSource({
|
||||
macos: 'story-background',
|
||||
width: 60,
|
||||
height: 60
|
||||
});
|
||||
macos: 'story-background',
|
||||
width: 60,
|
||||
height: 60,
|
||||
});
|
||||
} else {
|
||||
nativeImage = nativeImageSource({
|
||||
ios: 'story-background',
|
||||
width: 60,
|
||||
height: 60
|
||||
})
|
||||
ios: 'story-background',
|
||||
width: 60,
|
||||
height: 60,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -857,8 +857,7 @@ exports.examples = [
|
|||
},
|
||||
{
|
||||
title: 'Bundled images',
|
||||
description:
|
||||
'Images shipped in a separate native bundle',
|
||||
description: 'Images shipped in a separate native bundle',
|
||||
render: function() {
|
||||
return (
|
||||
<View style={{flexDirection: 'row'}}>
|
||||
|
|
|
@ -34,10 +34,15 @@ class LayoutEventExample extends React.Component<{}, State> {
|
|||
};
|
||||
|
||||
animateViewLayout = () => {
|
||||
LayoutAnimation.configureNext(Platform.OS === 'macos' ? LayoutAnimation.Presets.easeInEaseOut : LayoutAnimation.Presets.spring, () => {
|
||||
console.log('layout animation done.');
|
||||
this.addWrapText();
|
||||
});
|
||||
LayoutAnimation.configureNext(
|
||||
Platform.OS === 'macos'
|
||||
? LayoutAnimation.Presets.easeInEaseOut
|
||||
: LayoutAnimation.Presets.spring,
|
||||
() => {
|
||||
console.log('layout animation done.');
|
||||
this.addWrapText();
|
||||
},
|
||||
);
|
||||
this.setState({
|
||||
viewStyle: {
|
||||
margin: this.state.viewStyle.margin > 20 ? 20 : 60,
|
||||
|
|
|
@ -58,8 +58,20 @@ class IntentAndroidExample extends React.Component {
|
|||
<OpenURLButton url={'https://www.facebook.com'} />
|
||||
<OpenURLButton url={'http://www.facebook.com'} />
|
||||
<OpenURLButton url={'http://facebook.com'} />
|
||||
<OpenURLButton url={Platform.OS === 'macos' ? 'mailto:mark@facebook.com' : 'fb://notifications'} />
|
||||
<OpenURLButton url={Platform.OS === 'macos' ? 'maps:ll=45.5200,-122.681' : 'geo:37.484847,-122.148386'} />
|
||||
<OpenURLButton
|
||||
url={
|
||||
Platform.OS === 'macos'
|
||||
? 'mailto:mark@facebook.com'
|
||||
: 'fb://notifications'
|
||||
}
|
||||
/>
|
||||
<OpenURLButton
|
||||
url={
|
||||
Platform.OS === 'macos'
|
||||
? 'maps:ll=45.5200,-122.681'
|
||||
: 'geo:37.484847,-122.148386'
|
||||
}
|
||||
/>
|
||||
<OpenURLButton url={'tel:9876543210'} />
|
||||
</RNTesterBlock>
|
||||
);
|
||||
|
|
|
@ -58,13 +58,21 @@ const Header = ({onBack, title}: {onBack?: () => mixed, title: string}) => (
|
|||
);
|
||||
|
||||
class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
|
||||
_mounted: boolean; // TODO(OSS Candidate ISS#2710739)
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
BackHandler.addEventListener('hardwareBackPress', this._handleBack);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._mounted = true; // TODO(OSS Candidate ISS#2710739)
|
||||
Linking.getInitialURL().then(url => {
|
||||
AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
if (!this._mounted) {
|
||||
return;
|
||||
}
|
||||
// ]TODO(OSS Candidate ISS#2710739)
|
||||
const exampleAction = URIActionMap(
|
||||
this.props.exampleFromAppetizeParams,
|
||||
);
|
||||
|
@ -80,6 +88,12 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
|
|||
});
|
||||
}
|
||||
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
componentWillUnmount() {
|
||||
this._mounted = false;
|
||||
}
|
||||
// ]TODO(OSS Candidate ISS#2710739)
|
||||
|
||||
_handleBack = () => {
|
||||
this._handleAction(RNTesterActions.Back());
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ const {
|
|||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
SafeAreaView
|
||||
SafeAreaView,
|
||||
} = ReactNative;
|
||||
|
||||
import type {RNTesterExample} from './RNTesterList.macos';
|
||||
|
@ -60,13 +60,21 @@ const Header = ({onBack, title}: {onBack?: () => mixed, title: string}) => (
|
|||
);
|
||||
|
||||
class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
|
||||
_mounted: boolean; // TODO(OSS Candidate ISS#2710739)
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
// BackHandler.addEventListener('hardwareBackPress', this._handleBack);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._mounted = true; // TODO(OSS Candidate ISS#2710739)
|
||||
Linking.getInitialURL().then(url => {
|
||||
AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
if (!this._mounted) {
|
||||
return;
|
||||
}
|
||||
// ]TODO(OSS Candidate ISS#2710739)
|
||||
const exampleAction = URIActionMap(
|
||||
this.props.exampleFromAppetizeParams,
|
||||
);
|
||||
|
@ -91,6 +99,12 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
|
|||
});
|
||||
}
|
||||
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
componentWillUnmount() {
|
||||
this._mounted = false;
|
||||
}
|
||||
// ]TODO(OSS Candidate ISS#2710739)
|
||||
|
||||
_handleBack = () => {
|
||||
this._handleAction(RNTesterActions.Back());
|
||||
};
|
||||
|
|
|
@ -115,6 +115,10 @@ class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
|||
automaticallyAdjustContentInsets={false}
|
||||
keyboardDismissMode="on-drag"
|
||||
renderSectionHeader={renderSectionHeader}
|
||||
backgroundColor={Platform.select({
|
||||
macos: 'transparent',
|
||||
default: undefined,
|
||||
})} // TODO(macOS ISS#2323203)
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
@ -122,10 +126,10 @@ class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
|||
);
|
||||
}
|
||||
|
||||
_handleOnSelectionEntered = (item) => {
|
||||
_handleOnSelectionEntered = item => {
|
||||
const {key} = item;
|
||||
this.props.onNavigate(RNTesterActions.ExampleAction(key));
|
||||
}
|
||||
};
|
||||
|
||||
_itemShouldUpdate(curr, prev) {
|
||||
return curr.item !== prev.item;
|
||||
|
@ -178,43 +182,51 @@ const styles = StyleSheet.create({
|
|||
flex: 1,
|
||||
},
|
||||
list: {
|
||||
...Platform.select({ // [TODO(macOS ISS#2323203)
|
||||
...Platform.select({
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
backgroundColor: {semantic: 'controlBackgroundColor'},
|
||||
},
|
||||
default: { // ]TODO(macOS ISS#2323203)
|
||||
default: {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
backgroundColor: '#eeeeee',
|
||||
} // [TODO(macOS ISS#2323203)
|
||||
}) // ]TODO(macOS ISS#2323203)
|
||||
}, // [TODO(macOS ISS#2323203)
|
||||
}), // ]TODO(macOS ISS#2323203)
|
||||
},
|
||||
sectionHeader: {
|
||||
...Platform.select({ // [TODO(macOS ISS#2323203)
|
||||
...Platform.select({
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
backgroundColor: {semantic: 'unemphasizedSelectedContentBackgroundColor'},
|
||||
color: {semantic: 'headerTextColor'}
|
||||
backgroundColor: {
|
||||
semantic: 'unemphasizedSelectedContentBackgroundColor',
|
||||
},
|
||||
color: {semantic: 'headerTextColor'},
|
||||
},
|
||||
default: { // ]TODO(macOS ISS#2323203)
|
||||
default: {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
backgroundColor: '#eeeeee',
|
||||
color: 'black'
|
||||
} // [TODO(macOS ISS#2323203)
|
||||
color: 'black',
|
||||
}, // [TODO(macOS ISS#2323203)
|
||||
}), // ]TODO(macOS ISS#2323203)
|
||||
padding: 5,
|
||||
fontWeight: '500',
|
||||
fontSize: 11,
|
||||
},
|
||||
row: {
|
||||
...Platform.select({ // [TODO(macOS ISS#2323203)
|
||||
...Platform.select({
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
backgroundColor: {semantic: 'controlBackgroundColor'},
|
||||
},
|
||||
default: { // ]TODO(macOS ISS#2323203)
|
||||
},
|
||||
default: {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
backgroundColor: 'white',
|
||||
} // [TODO(macOS ISS#2323203)
|
||||
}, // [TODO(macOS ISS#2323203)
|
||||
}), // ]TODO(macOS ISS#2323203)
|
||||
justifyContent: 'center',
|
||||
paddingHorizontal: 15,
|
||||
paddingVertical: 8,
|
||||
},
|
||||
},
|
||||
selectedRow: {
|
||||
backgroundColor: '#DDECF8',
|
||||
justifyContent: 'center',
|
||||
|
@ -223,13 +235,15 @@ const styles = StyleSheet.create({
|
|||
},
|
||||
separator: {
|
||||
height: StyleSheet.hairlineWidth,
|
||||
...Platform.select({ // [TODO(macOS ISS#2323203)
|
||||
...Platform.select({
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
backgroundColor: {semantic: 'separatorColor'},
|
||||
},
|
||||
default: { // ]TODO(macOS ISS#2323203)
|
||||
},
|
||||
default: {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
backgroundColor: '#bbbbbb',
|
||||
} // [TODO(macOS ISS#2323203)
|
||||
}, // [TODO(macOS ISS#2323203)
|
||||
}), // ]TODO(macOS ISS#2323203)
|
||||
marginLeft: 15,
|
||||
},
|
||||
|
@ -237,19 +251,22 @@ const styles = StyleSheet.create({
|
|||
height: StyleSheet.hairlineWidth,
|
||||
backgroundColor: 'rgb(217, 217, 217)',
|
||||
},
|
||||
sectionListContentContainer: {
|
||||
backgroundColor: 'white',
|
||||
},
|
||||
sectionListContentContainer: Platform.select({
|
||||
macos: {backgroundColor: {semantic: 'separatorColor'}},
|
||||
default: {backgroundColor: 'white'},
|
||||
}),
|
||||
rowTitleText: {
|
||||
fontSize: 17,
|
||||
fontWeight: '500',
|
||||
...Platform.select({ // [TODO(macOS ISS#2323203)
|
||||
...Platform.select({
|
||||
// [TODO(macOS ISS#2323203)
|
||||
macos: {
|
||||
color: {semantic: 'controlTextColor'},
|
||||
},
|
||||
default: { // ]TODO(macOS ISS#2323203)
|
||||
},
|
||||
default: {
|
||||
// ]TODO(macOS ISS#2323203)
|
||||
color: 'black',
|
||||
} // [TODO(macOS ISS#2323203)
|
||||
}, // [TODO(macOS ISS#2323203)
|
||||
}), // ]TODO(macOS ISS#2323203)
|
||||
},
|
||||
rowDetailText: {
|
||||
|
|
|
@ -41,12 +41,13 @@ const ComponentExamples: Array<RNTesterExample> = [
|
|||
key: 'FlatListExample',
|
||||
module: require('./FlatListExample'),
|
||||
supportsTVOS: true,
|
||||
},// [TODO(OSS Candidate ISS#2710739)
|
||||
},
|
||||
// [TODO(OSS Candidate ISS#2710739)
|
||||
{
|
||||
key: 'FocusEvents',
|
||||
module: require('./FocusEventsExample'),
|
||||
supportsTVOS: true,
|
||||
},// ]TODO(OSS Candidate ISS#2710739)
|
||||
}, // ]TODO(OSS Candidate ISS#2710739)
|
||||
{
|
||||
key: 'ImageExample',
|
||||
module: require('./ImageExample'),
|
||||
|
|
|
@ -203,7 +203,7 @@ const APIExamples: Array<RNTesterExample> = [
|
|||
{
|
||||
key: 'GeolocationExample',
|
||||
module: require('./GeolocationExample'),
|
||||
supportsTVOS:false,
|
||||
supportsTVOS: false,
|
||||
},
|
||||
{
|
||||
key: 'LayoutAnimationExample',
|
||||
|
|
|
@ -405,7 +405,7 @@ class RTLExample extends React.Component<any, State> {
|
|||
style={[
|
||||
styles.container,
|
||||
// `direction` property is supported only on iOS&macOS now.
|
||||
(Platform.OS === 'ios' || Platform.OS === 'macos')
|
||||
Platform.OS === 'ios' || Platform.OS === 'macos'
|
||||
? {direction: this.state.isRTL ? 'rtl' : 'ltr'}
|
||||
: null,
|
||||
]}
|
||||
|
|
|
@ -174,7 +174,7 @@ exports.examples = [
|
|||
render(): React.Element<any> {
|
||||
return <ColorSegmentedControlExample />;
|
||||
},
|
||||
platform: 'ios'
|
||||
platform: 'ios',
|
||||
},
|
||||
{
|
||||
title: 'Change events can be detected',
|
||||
|
|
|
@ -824,7 +824,7 @@ exports.examples = [
|
|||
return <TextBaseLineLayoutExample />;
|
||||
},
|
||||
},
|
||||
/* Text textTransform not supported on macOS
|
||||
/* Text textTransform not supported on macOS
|
||||
{
|
||||
title: 'Transform',
|
||||
render: function() {
|
||||
|
|
|
@ -132,23 +132,27 @@ exports.examples = [
|
|||
return <TouchableDisabled />;
|
||||
},
|
||||
},
|
||||
{ // [TODO(macOS ISS#2323203)
|
||||
{
|
||||
// [TODO(macOS ISS#2323203)
|
||||
title: 'Touchable Hover',
|
||||
description: '<Touchable*> components reacts to mouse enter ' +
|
||||
description:
|
||||
'<Touchable*> components reacts to mouse enter ' +
|
||||
'and mouse exit events',
|
||||
render: function(): React.Element<any> {
|
||||
return <TouchableHover />;
|
||||
},
|
||||
platform: 'macos',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
title: 'Touchable feedback mouse events',
|
||||
description: '<Touchable*> components reacts to mouse events ' +
|
||||
description:
|
||||
'<Touchable*> components reacts to mouse events ' +
|
||||
'and mouse exit events',
|
||||
render: function(): React.Element<any> {
|
||||
return <TouchableMouseEvents />;
|
||||
},
|
||||
platform: 'macos',
|
||||
} // ]TODO(macOS ISS#2323203)
|
||||
}, // ]TODO(macOS ISS#2323203)
|
||||
];
|
||||
|
||||
class TouchableHighlightBox extends React.Component<{}, $FlowFixMeState> {
|
||||
|
@ -511,13 +515,18 @@ class TouchableDisabled extends React.Component<{}> {
|
|||
// [TODO(macOS ISS#2323203)
|
||||
class TouchableHover extends React.Component<{}, $FlowFixMeState> {
|
||||
state = {
|
||||
hoverOver: false
|
||||
hoverOver: false,
|
||||
};
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<TouchableOpacity onMouseEnter={this._handlePress} onMouseLeave={this._handlePress} style={[styles.row, styles.block]}>
|
||||
<Text style={this.state.hoverOver ? {color:'red'} : {color:'blue'}}>Touchable Opacity with mouse enter/exit events</Text>
|
||||
<TouchableOpacity
|
||||
onMouseEnter={this._handlePress}
|
||||
onMouseLeave={this._handlePress}
|
||||
style={[styles.row, styles.block]}>
|
||||
<Text style={this.state.hoverOver ? {color: 'red'} : {color: 'blue'}}>
|
||||
Touchable Opacity with mouse enter/exit events
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableHighlight
|
||||
|
@ -555,14 +564,14 @@ class TouchableMouseEvents extends React.Component<{}, $FlowFixMeState> {
|
|||
accessibilityLabel="touchable feedback mouse events"
|
||||
accessibilityTraits="button"
|
||||
accessibilityComponentType="button"
|
||||
onPressIn={(e) => this._appendEvent('MouseIn', e.nativeEvent)}
|
||||
onPressOut={(e) => this._appendEvent('MouseOut', e.nativeEvent)}>
|
||||
<Text style={styles.button}>
|
||||
Click Me
|
||||
</Text>
|
||||
onPressIn={e => this._appendEvent('MouseIn', e.nativeEvent)}
|
||||
onPressOut={e => this._appendEvent('MouseOut', e.nativeEvent)}>
|
||||
<Text style={styles.button}>Click Me</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View testID="touchable_feedback_mouse_events_console" style={styles.eventLogBox}>
|
||||
<View
|
||||
testID="touchable_feedback_mouse_events_console"
|
||||
style={styles.eventLogBox}>
|
||||
{this.state.eventLog.map((e, ii) => <Text key={ii}>{e}</Text>)}
|
||||
</View>
|
||||
</View>
|
||||
|
@ -594,8 +603,8 @@ class TouchableMouseEvents extends React.Component<{}, $FlowFixMeState> {
|
|||
}
|
||||
if (modifier.length > 0) {
|
||||
modifier = ' - ' + modifier.slice(0, -2) + ' pressed';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
eventLog.unshift(eventType + eventName + modifier);
|
||||
this.setState({eventLog});
|
||||
};
|
||||
|
|
|
@ -39,37 +39,59 @@ class ViewFocusEventsExample extends React.Component<{}, $FlowFixMeState> {
|
|||
});
|
||||
return (
|
||||
<View>
|
||||
<Button onPress={() => this.setState({showSampleViews: !this.state.showSampleViews})} title={(this.state.showSampleViews) ? 'Hide Sample Focus event View' : 'Show Sample View'} />
|
||||
<Button onPress={() => this.defaultFocusView ? this.defaultFocusView.focus() : null} title={'Give Focus to default View'} />
|
||||
{ (this.state.showSampleViews) ?
|
||||
<View>
|
||||
<Text> Enter on any view will move focus within this view </Text>
|
||||
<TouchableNativeFeedback onPress={() => this.defaultFocusView ? this.defaultFocusView.focus() : null}>
|
||||
<View ref = {v => this.view1 = v} style={[ styles.focusView]} >
|
||||
<Text> Test View</Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
|
||||
<TouchableNativeFeedback onPress={() => this.view2 ? this.view2.focus() : null}>
|
||||
<View ref = {v => this.defaultFocusView = v} style={[ styles.focusView]} >
|
||||
<Text> Default Focus View </Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
|
||||
<TouchableNativeFeedback onPress={() => this.view1 ? this.view1.focus() : null}>
|
||||
<View ref = {v => this.view2 = v}
|
||||
style={[ styles.focusView]}
|
||||
onFocusChange = {(hasFocus) => {this.setState({showTextView: hasFocus})}}>
|
||||
<Text> Show sample textview on focus </Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
{
|
||||
this.state.showTextView ?
|
||||
<Text> This is a sample Text</Text>
|
||||
: null
|
||||
<Button
|
||||
onPress={() =>
|
||||
this.setState({showSampleViews: !this.state.showSampleViews})
|
||||
}
|
||||
</View>
|
||||
: null }
|
||||
title={
|
||||
this.state.showSampleViews
|
||||
? 'Hide Sample Focus event View'
|
||||
: 'Show Sample View'
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
onPress={() =>
|
||||
this.defaultFocusView ? this.defaultFocusView.focus() : null
|
||||
}
|
||||
title={'Give Focus to default View'}
|
||||
/>
|
||||
{this.state.showSampleViews ? (
|
||||
<View>
|
||||
<Text> Enter on any view will move focus within this view </Text>
|
||||
<TouchableNativeFeedback
|
||||
onPress={() =>
|
||||
this.defaultFocusView ? this.defaultFocusView.focus() : null
|
||||
}>
|
||||
<View ref={v => (this.view1 = v)} style={[styles.focusView]}>
|
||||
<Text> Test View</Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
|
||||
<TouchableNativeFeedback
|
||||
onPress={() => (this.view2 ? this.view2.focus() : null)}>
|
||||
<View
|
||||
ref={v => (this.defaultFocusView = v)}
|
||||
style={[styles.focusView]}>
|
||||
<Text> Default Focus View </Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
|
||||
<TouchableNativeFeedback
|
||||
onPress={() => (this.view1 ? this.view1.focus() : null)}>
|
||||
<View
|
||||
ref={v => (this.view2 = v)}
|
||||
style={[styles.focusView]}
|
||||
onFocusChange={hasFocus => {
|
||||
this.setState({showTextView: hasFocus});
|
||||
}}>
|
||||
<Text> Show sample textview on focus </Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
{this.state.showTextView ? (
|
||||
<Text> This is a sample Text</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -285,21 +307,22 @@ exports.examples = [
|
|||
);
|
||||
},
|
||||
},
|
||||
{ // [TODO(macOS ISS#2323203)
|
||||
{
|
||||
// [TODO(macOS ISS#2323203)
|
||||
title: 'ToolTip',
|
||||
render() {
|
||||
return (
|
||||
<View tooltip='Parent View'>
|
||||
<Text style={{ fontSize: 11 }}>
|
||||
<View tooltip="Parent View">
|
||||
<Text style={{fontSize: 11}}>
|
||||
This Parent View has tooltip "Parent View"
|
||||
</Text>
|
||||
<View tooltip='Child View 1'>
|
||||
<Text style={{ fontSize: 11 }}>
|
||||
<View tooltip="Child View 1">
|
||||
<Text style={{fontSize: 11}}>
|
||||
This view has tooltip "Child View 1"
|
||||
</Text>
|
||||
</View>
|
||||
<View tooltip='Child View 2'>
|
||||
<Text style={{ fontSize: 11 }}>
|
||||
<View tooltip="Child View 2">
|
||||
<Text style={{fontSize: 11}}>
|
||||
This view has tooltip "Child View 2"
|
||||
</Text>
|
||||
</View>
|
||||
|
|
|
@ -66,18 +66,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setColor:(UIColor*)color
|
||||
- (void)setColor: (UIColor*)color
|
||||
{
|
||||
_color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"];
|
||||
[colorPoly setDefaults];
|
||||
CIVector *redVector = [CIVector vectorWithX:color.redComponent Y:0 Z:0 W:0];
|
||||
CIVector *greenVector = [CIVector vectorWithX:color.greenComponent Y:0 Z:0 W:0];
|
||||
CIVector *blueVector = [CIVector vectorWithX:color.blueComponent Y:0 Z:0 W:0];
|
||||
[colorPoly setValue:redVector forKey:@"inputRedCoefficients"];
|
||||
[colorPoly setValue:greenVector forKey:@"inputGreenCoefficients"];
|
||||
[colorPoly setValue:blueVector forKey:@"inputBlueCoefficients"];
|
||||
self.contentFilters = @[colorPoly];
|
||||
if (_color != color) {
|
||||
_color = color;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateLayer
|
||||
{
|
||||
[super updateLayer];
|
||||
if (_color) {
|
||||
CGFloat r, g, b, a;
|
||||
[[_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a];
|
||||
|
||||
CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"];
|
||||
[colorPoly setDefaults];
|
||||
CIVector *redVector = [CIVector vectorWithX:r Y:0 Z:0 W:0];
|
||||
CIVector *greenVector = [CIVector vectorWithX:g Y:0 Z:0 W:0];
|
||||
CIVector *blueVector = [CIVector vectorWithX:b Y:0 Z:0 W:0];
|
||||
[colorPoly setValue:redVector forKey:@"inputRedCoefficients"];
|
||||
[colorPoly setValue:greenVector forKey:@"inputGreenCoefficients"];
|
||||
[colorPoly setValue:blueVector forKey:@"inputBlueCoefficients"];
|
||||
self.contentFilters = @[colorPoly];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHidesWhenStopped:(BOOL)hidesWhenStopped
|
||||
|
|
|
@ -205,7 +205,7 @@ task buildReactNdkLib(dependsOn: [prepareBoost, prepareDoubleConversion, prepare
|
|||
'NDK_OUT=' + temporaryDir,
|
||||
"NDK_LIBS_OUT=$buildDir/react-ndk/all",
|
||||
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
||||
"REACT_V8_DIR=$projectDir/src/main/jni/v8",
|
||||
"THIRD_PARTY_NDK_SRC_DIR=$projectDir/src/main/jni/third-party",
|
||||
"V8_NUGET_DIR=$projectDir/$V8Path",
|
||||
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
|
||||
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
|
||||
|
@ -217,7 +217,7 @@ task cleanReactNdkLib(type: Exec) {
|
|||
commandLine getNdkBuildFullPath(),
|
||||
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
|
||||
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
||||
"REACT_V8_DIR=$projectDir/src/main/jni/v8",
|
||||
"THIRD_PARTY_NDK_SRC_DIR=$projectDir/src/main/jni/third-party",
|
||||
"V8_NUGET_DIR=$projectDir/$V8Path",
|
||||
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
|
||||
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
|
||||
|
|
|
@ -22,7 +22,7 @@ APP_MK_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
|||
# Where are APP_MK_DIR, THIRD_PARTY_NDK_DIR, etc. defined?
|
||||
# The directories inside NDK_MODULE_PATH (ex: APP_MK_DIR, THIRD_PARTY_NDK_DIR,
|
||||
# etc.) are defined inside build.gradle.
|
||||
NDK_MODULE_PATH := $(APP_MK_DIR)$(HOST_DIRSEP)$(THIRD_PARTY_NDK_DIR)$(HOST_DIRSEP)$(REACT_COMMON_DIR)$(HOST_DIRSEP)$(APP_MK_DIR)first-party$(HOST_DIRSEP)$(REACT_SRC_DIR)$(REACT_V8_DIR)$(HOST_DIRSEP)$(REACT_V8_DIR)/../v8base$(HOST_DIRSEP)$(REACT_V8_DIR)/../v8platform
|
||||
NDK_MODULE_PATH := $(APP_MK_DIR)$(HOST_DIRSEP)$(THIRD_PARTY_NDK_DIR)$(HOST_DIRSEP)$(REACT_COMMON_DIR)$(HOST_DIRSEP)$(APP_MK_DIR)first-party$(HOST_DIRSEP)$(REACT_SRC_DIR)$(REACT_V8_DIR)$(HOST_DIRSEP)$(REACT_V8_DIR)/../v8base$(HOST_DIRSEP)$(REACT_V8_DIR)/../v8platform$(HOST_DIRSEP)$(THIRD_PARTY_NDK_SRC_DIR)$(HOST_DIRSEP)
|
||||
|
||||
APP_STL := gnustl_shared
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
macro(determine_gflags_namespace VARIABLE)
|
||||
if (NOT DEFINED "${VARIABLE}")
|
||||
if (CMAKE_REQUIRED_INCLUDES)
|
||||
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else ()
|
||||
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
|
||||
endif ()
|
||||
|
||||
set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
set(_NAMESPACES gflags google)
|
||||
set(_check_code
|
||||
"
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
|
||||
}
|
||||
")
|
||||
if (NOT CMAKE_REQUIRED_QUIET)
|
||||
message (STATUS "Looking for gflags namespace")
|
||||
endif ()
|
||||
if (${ARGC} EQUAL 3)
|
||||
set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
|
||||
endif ()
|
||||
|
||||
set (_check_file
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx)
|
||||
|
||||
foreach (_namespace ${_NAMESPACES})
|
||||
file (WRITE "${_check_file}" "${_check_code}")
|
||||
try_compile (${VARIABLE}
|
||||
"${CMAKE_BINARY_DIR}" "${_check_file}"
|
||||
COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGFLAGS_NAMESPACE=${_namespace}
|
||||
LINK_LIBRARIES gflags
|
||||
CMAKE_FLAGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
if (${VARIABLE})
|
||||
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE)
|
||||
break ()
|
||||
else ()
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining the gflags namespace ${_namespace} failed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
endif ()
|
||||
endforeach (_namespace)
|
||||
|
||||
if (${ARGC} EQUAL 3)
|
||||
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
|
||||
endif ()
|
||||
|
||||
if (${VARIABLE})
|
||||
if (NOT CMAKE_REQUIRED_QUIET)
|
||||
message (STATUS "Looking for gflags namespace - ${${VARIABLE}}")
|
||||
endif ()
|
||||
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining the gflags namespace passed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
else ()
|
||||
if (NOT CMAKE_REQUIRED_QUIET)
|
||||
message (STATUS "Looking for gflags namespace - failed")
|
||||
endif ()
|
||||
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace")
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
|
@ -0,0 +1,179 @@
|
|||
/* src/config.h. Generated from config.h.in by configure. */
|
||||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* define if glog doesn't use RTTI */
|
||||
#define DISABLE_RTTI 1
|
||||
|
||||
/* Namespace for Google classes */
|
||||
#define GOOGLE_NAMESPACE google
|
||||
|
||||
/* Define if you have the `dladdr' function */
|
||||
#define HAVE_DLADDR 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
/* #undef HAVE_EXECINFO_H */
|
||||
|
||||
/* Define if you have the `fcntl' function */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the <glob.h> header file. */
|
||||
/* #undef HAVE_GLOB_H */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
/* #undef HAVE_LIBPTHREAD */
|
||||
|
||||
/* Define to 1 if you have the <libunwind.h> header file. */
|
||||
/* #undef HAVE_LIBUNWIND_H */
|
||||
|
||||
/* define if you have google gflags library */
|
||||
/* #undef HAVE_LIB_GFLAGS */
|
||||
|
||||
/* define if you have google gmock library */
|
||||
/* #undef HAVE_LIB_GMOCK */
|
||||
|
||||
/* define if you have google gtest library */
|
||||
/* #undef HAVE_LIB_GTEST */
|
||||
|
||||
/* define if you have libunwind */
|
||||
/* #undef HAVE_LIB_UNWIND */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* define if the compiler implements namespaces */
|
||||
#define HAVE_NAMESPACES 1
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#define HAVE_PTHREAD 1
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#define HAVE_PWD_H 1
|
||||
|
||||
/* define if the compiler implements pthread_rwlock_* */
|
||||
#define HAVE_RWLOCK 1
|
||||
|
||||
/* Define if you have the `sigaltstack' function */
|
||||
#define HAVE_SIGALTSTACK 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <syscall.h> header file. */
|
||||
/* #undef HAVE_SYSCALL_H */
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#define HAVE_SYSLOG_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/syscall.h> header file. */
|
||||
#define HAVE_SYS_SYSCALL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ucontext.h> header file. */
|
||||
/* #undef HAVE_SYS_UCONTEXT_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
|
||||
/* Define to 1 if you have the <ucontext.h> header file. */
|
||||
/* #undef HAVE_UCONTEXT_H */
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <unwind.h> header file. */
|
||||
#define HAVE_UNWIND_H 1
|
||||
|
||||
/* define if the compiler supports using expression for operator */
|
||||
#define HAVE_USING_OPERATOR 1
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#define HAVE___ATTRIBUTE__ 1
|
||||
|
||||
/* define if your compiler has __builtin_expect */
|
||||
#define HAVE___BUILTIN_EXPECT 1
|
||||
|
||||
/* define if your compiler has __sync_val_compare_and_swap */
|
||||
#define HAVE___SYNC_VAL_COMPARE_AND_SWAP 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "glog"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "opensource@google.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "glog"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "glog 0.3.3"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "glog"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.3.3"
|
||||
|
||||
/* How to access the PC from a struct ucontext */
|
||||
/* #undef PC_FROM_UCONTEXT */
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
/* #undef STDC_HEADERS */
|
||||
|
||||
/* the namespace where STL code like vector<> is defined */
|
||||
#define STL_NAMESPACE std
|
||||
|
||||
/* location of source code */
|
||||
#define TEST_SRC_DIR "."
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.3.3"
|
||||
|
||||
/* Stops putting the code inside the Google namespace */
|
||||
#define _END_GOOGLE_NAMESPACE_ }
|
||||
|
||||
/* Puts following code inside the Google namespace */
|
||||
#define _START_GOOGLE_NAMESPACE_ namespace google {
|
||||
|
||||
|
||||
/* TODO(vjn/dreiss): revisit these when use the android-21 (or newer) NDK platform. */
|
||||
#undef HAVE_SYSCALL_H
|
||||
#undef HAVE_SYS_SYSCALL_H
|
||||
#undef OS_LINUX
|
||||
#undef OS_MACOSX
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче