-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathARProjectedView.js
More file actions
31 lines (30 loc) · 869 Bytes
/
ARProjectedView.js
File metadata and controls
31 lines (30 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import PropTypes from "prop-types";
import React from "react";
import { ARSessionConsumer } from "./ARSessionProvider";
import { ARNodeConsumer } from "./components/ARNode";
import { adopt } from "react-adopt";
import { ARProjectedView as SwiftARProjectedView } from "./RNSwiftBridge";
const ARBaseProjectedView = props => (
<SwiftARProjectedView
{...props}
style={[props.style, { position: "absolute" }]}
/>
);
const Adoptee = adopt({
session: <ARSessionConsumer />,
node: <ARNodeConsumer />
});
const ARProjectedView = props => {
return (
<Adoptee>
{({ session: { isStarted }, node: { nodeID } }) => {
if (!isStarted) return null;
return <ARBaseProjectedView parentNode={nodeID} {...props} />;
}}
</Adoptee>
);
};
ARProjectedView.propTypes = {
parentNode: PropTypes.string
};
export default ARProjectedView;