forked from software-mansion/react-native-reanimated
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from wordpress-mobile/upstream-2.9.1
Update `trunk` with upstream version `2.9.1`
- Loading branch information
Showing
493 changed files
with
24,234 additions
and
6,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Test tvOS build | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'ios/**' | ||
- 'Common/**' | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
env: | ||
WORKING_DIRECTORY: TVOSExample | ||
concurrency: | ||
group: ios-tv-${{ github.ref }} | ||
cancel-in-progress: true | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: Use Node.js 14 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
cache: 'yarn' | ||
cache-dependency-path: 'TVOSExample/yarn.lock' | ||
- name: Install Reanimated node dependencies | ||
run: yarn | ||
- name: Install node dependencies | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
run: yarn | ||
- name: Install pods | ||
working-directory: ${{ env.WORKING_DIRECTORY }}/ios | ||
run: pod install | ||
- name: Build app | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
run: yarn tv-os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,5 @@ lib/ | |
react-native-reanimated-tests.js | ||
|
||
# eclipse | ||
*.settings** | ||
*.settings** | ||
FabricExample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "AnimatedSensorModule.h" | ||
#include "MutableValue.h" | ||
#include "ValueWrapper.h" | ||
|
||
namespace reanimated { | ||
|
||
AnimatedSensorModule::AnimatedSensorModule( | ||
const PlatformDepMethodsHolder &platformDepMethodsHolder, | ||
RuntimeManager *runtimeManager) | ||
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor), | ||
platformUnregisterSensorFunction_( | ||
platformDepMethodsHolder.unregisterSensor), | ||
runtimeManager_(runtimeManager) {} | ||
|
||
AnimatedSensorModule::~AnimatedSensorModule() { | ||
// It is called during app reload because app reload doesn't call hooks | ||
// unmounting | ||
for (auto sensorId : sensorsIds_) { | ||
platformUnregisterSensorFunction_(sensorId); | ||
} | ||
} | ||
|
||
jsi::Value AnimatedSensorModule::registerSensor( | ||
jsi::Runtime &rt, | ||
const jsi::Value &sensorType, | ||
const jsi::Value &interval, | ||
const jsi::Value &sensorDataContainer) { | ||
std::shared_ptr<ShareableValue> sensorsData = ShareableValue::adapt( | ||
rt, sensorDataContainer.getObject(rt), runtimeManager_); | ||
auto &mutableObject = | ||
ValueWrapper::asMutableValue(sensorsData->valueContainer); | ||
|
||
std::function<void(double[])> setter; | ||
if (sensorType.asNumber() == SensorType::ROTATION_VECTOR) { | ||
setter = [&, mutableObject](double newValues[]) { | ||
jsi::Runtime &runtime = *runtimeManager_->runtime.get(); | ||
jsi::Object value(runtime); | ||
value.setProperty(runtime, "qw", newValues[0]); | ||
value.setProperty(runtime, "qx", newValues[1]); | ||
value.setProperty(runtime, "qy", newValues[2]); | ||
value.setProperty(runtime, "qz", newValues[3]); | ||
value.setProperty(runtime, "yaw", newValues[4]); | ||
value.setProperty(runtime, "pitch", newValues[5]); | ||
value.setProperty(runtime, "roll", newValues[6]); | ||
mutableObject->setValue(runtime, std::move(value)); | ||
}; | ||
} else { | ||
setter = [&, mutableObject](double newValues[]) { | ||
jsi::Runtime &runtime = *runtimeManager_->runtime.get(); | ||
jsi::Object value(runtime); | ||
value.setProperty(runtime, "x", newValues[0]); | ||
value.setProperty(runtime, "y", newValues[1]); | ||
value.setProperty(runtime, "z", newValues[2]); | ||
mutableObject->setValue(runtime, std::move(value)); | ||
}; | ||
} | ||
|
||
int sensorId = platformRegisterSensorFunction_( | ||
sensorType.asNumber(), interval.asNumber(), setter); | ||
if (sensorId != -1) { | ||
sensorsIds_.insert(sensorId); | ||
} | ||
return jsi::Value(sensorId); | ||
} | ||
|
||
void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) { | ||
// It is called during sensor hook unmounting | ||
sensorsIds_.erase(sensorId.getNumber()); | ||
platformUnregisterSensorFunction_(sensorId.asNumber()); | ||
} | ||
|
||
} // namespace reanimated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.