Skip to content

Commit 0f81b68

Browse files
committed
Add Viro
1 parent f60e676 commit 0f81b68

File tree

4 files changed

+81
-15
lines changed

4 files changed

+81
-15
lines changed

App.tsx

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,56 @@
1-
import { StatusBar } from 'expo-status-bar';
2-
import { StyleSheet, Text, View } from 'react-native';
1+
import React, { useState } from "react";
2+
import { StyleSheet } from "react-native";
3+
import {
4+
ViroARScene,
5+
ViroText,
6+
ViroTrackingStateConstants,
7+
ViroARSceneNavigator,
8+
ViroTrackingReason,
9+
} from "@viro-community/react-viro";
310

4-
export default function App() {
11+
const HelloWorldSceneAR = () => {
12+
const [text, setText] = useState("Initializing AR...");
13+
14+
function onInitialized(state: any, reason: ViroTrackingReason) {
15+
console.log("guncelleme", state, reason);
16+
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
17+
setText("Hello World!");
18+
} else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) {
19+
// Handle loss of tracking
20+
}
21+
}
22+
23+
return (
24+
<ViroARScene onTrackingUpdated={onInitialized}>
25+
<ViroText
26+
text={text}
27+
scale={[0.5, 0.5, 0.5]}
28+
position={[0, 0, -1]}
29+
style={styles.helloWorldTextStyle}
30+
/>
31+
</ViroARScene>
32+
);
33+
};
34+
35+
export default () => {
536
return (
6-
<View style={styles.container}>
7-
<Text>Open up App.tsx to start working on your app!</Text>
8-
<StatusBar style="auto" />
9-
</View>
37+
<ViroARSceneNavigator
38+
autofocus={true}
39+
initialScene={{
40+
scene: HelloWorldSceneAR,
41+
}}
42+
style={styles.f1}
43+
/>
1044
);
11-
}
45+
};
1246

13-
const styles = StyleSheet.create({
14-
container: {
15-
flex: 1,
16-
backgroundColor: '#fff',
17-
alignItems: 'center',
18-
justifyContent: 'center',
47+
var styles = StyleSheet.create({
48+
f1: { flex: 1 },
49+
helloWorldTextStyle: {
50+
fontFamily: "Arial",
51+
fontSize: 30,
52+
color: "#ffffff",
53+
textAlignVertical: "center",
54+
textAlign: "center",
1955
},
2056
});

app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"web": {
2727
"favicon": "./assets/favicon.png"
28-
}
28+
},
29+
"plugins": ["@viro-community/react-viro"]
2930
}
3031
}

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"web": "expo start --web"
1010
},
1111
"dependencies": {
12+
"@viro-community/react-viro": "^2.23.1",
1213
"expo": "~50.0.4",
1314
"expo-status-bar": "~1.11.1",
1415
"react": "18.2.0",

0 commit comments

Comments
 (0)