-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.1.js
368 lines (319 loc) · 10.9 KB
/
App.1.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {AppRegistry,
ActivityIndicator,
Text,
View,
StyleSheet,
TouchableHighlight,
Image,
Alert,
Platform,
Animated,
Dimensions,
Linking,
Easing} from 'react-native';
import codePush from "react-native-code-push";
import {
ViroARSceneNavigator,
} from 'react-viro';
import renderIf from './js/helpers/renderIf';
var apiKey = "381814B3-73D4-4B04-B481-FB85528A89BE";
//import renderscene from './js/Arscene';
//var InitialARScene = require('./js/ArMultiMarker/MultiMarker');
var InitialARScene = require('./js/Markers/Markers');
//var InitialARScene = require('./js/ARBusinessCardOld/BusinessCard');
var {
width,
height
} = Dimensions.get('window');
let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, updateDialog: { title: "Mise à jour disponible!", mandatoryUpdateMessage:"Installer la nouvelle mise à jour ??", optionalUpdateMessage: "Installer la nouvelle mise à jour ?", optionalIgnoreButtonLabel: "Surtout pas!",
optionalInstallButtonLabel: "Bien sûr!"}, installMode: codePush.InstallMode.IMMEDIATE };
//type Props = {};
class ICEar extends Component{
constructor(props) {
super(props);
this._renderTrackingScanLine = this._renderTrackingScanLine.bind(this);
this._changeStateScanline = this._changeStateScanline.bind(this);
this._onLoadStart = this._onLoadStart.bind(this);
this._onLoadEnd = this._onLoadEnd.bind(this);
this._onDisplayDialog = this._onDisplayDialog.bind(this);
this._onResetScanAr = this._onResetScanAr.bind(this);
//this._onContextClearAll = this._onContextClearAll.bind(this);
// Set initial state here
this.state = {
temp: 0,
restartAllowed: true,
animationScanLine : true,
resetScene: false,
isLoading: false,
viroAppProps: {resetScene: false,displayObject:false, animationScanLine : true, yOffset:0, _onLoadEnd: this._onLoadEnd, _onLoadStart: this._onLoadStart, _onTrackingInit:this._onTrackingInit, _changeStateScanline:this._changeStateScanline, _renderTrackingScanLine: this._renderTrackingScanLine},
};
/*let codePushOptions = ({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, updateDialog: { title: "Mise à jour disponible!", mandatoryUpdateMessage:"Installer la nouvelle mise à jour ??", optionalUpdateMessage: "Installer la nouvelle mise à jour ?", optionalIgnoreButtonLabel: "Surtout pas!",
optionalInstallButtonLabel: "Bien sûr!"}, installMode: codePush.InstallMode.IMMEDIATE }, this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this));*/
}
/*this.position = new Animated.ValueXY(0, 0);
this.animatedValue = new Animated.Value(0);*/
componentWillMount() {
/* Animated.loop(
Animated.sequence([
Animated.timing(this.animatedValue, { toValue: 1, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
Animated.timing(this.animatedValue, { toValue: 0, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
])).start();*/
//this.toggleLike();
this._onLoadStart();
}
/* componentDidUpdate() {
this.position = new Animated.ValueXY(0, 0);
this.animatedValue = new Animated.Value(0);
Animated.loop(
Animated.sequence([
Animated.timing(this.animatedValue, { toValue: 1, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
Animated.timing(this.animatedValue, { toValue: 0, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
])).start();
//this.toggleLike();
this._onLoadStart();
}*/
componentDidMount() {
//this.syncImmediate.bind(this);
//codePush.sync({ updateDialog: updateDialogOptions});
}
toggleAnimation(){
//if (this.state.animationScanLine) {
this.position = new Animated.ValueXY(0, 0);
this.animatedValue = new Animated.Value(0);
//return (
Animated.loop(
Animated.sequence([
Animated.timing(this.animatedValue, { toValue: 1, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
Animated.timing(this.animatedValue, { toValue: 0, duration: 3000, easing: Easing.ease, useNativeDriver: true }),
])).start()
// )
// }
/*this.setState((state) => {
const newLiked = !state.liked;
if (newLiked) {
Animated.sequence([
Animated.spring(this.animatedValue, { toValue: 1 }),
Animated.spring(this.animatedValue, { toValue: 0 }),
]).start();
}
return { liked: newLiked };
});*/
}
/* codePushStatusDidChange(syncStatus) {
switch(syncStatus) {
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
this.setState({ syncMessage: "Checking for update." });
break;
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
this.setState({ syncMessage: "Downloading package." });
break;
case CodePush.SyncStatus.AWAITING_USER_ACTION:
this.setState({ syncMessage: "Awaiting user action." });
break;
case CodePush.SyncStatus.INSTALLING_UPDATE:
this.setState({ syncMessage: "Installing update." });
break;
case CodePush.SyncStatus.UP_TO_DATE:
this.setState({ syncMessage: "App up to date.", progress: false });
break;
case CodePush.SyncStatus.UPDATE_IGNORED:
this.setState({ syncMessage: "Update cancelled by user.", progress: false });
break;
case CodePush.SyncStatus.UPDATE_INSTALLED:
this.setState({ syncMessage: "Update installed and will be applied on restart.", progress: false });
break;
case CodePush.SyncStatus.UNKNOWN_ERROR:
this.setState({ syncMessage: "An unknown error occurred.", progress: false });
break;
}
}
codePushDownloadDidProgress(progress) {
this.setState({ progress });
}
let progressView;
if (this.state.progress) {
progressView = (
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
);
}{progressView}*/
renderOverlay = () => {
const lineStyles = [
styles.lineStyle,
{
transform: [
{
translateY: this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [-height/2, height/2]
})
}
],
},
];
return (
<View style={styles.overlay}>
<Animated.View style={lineStyles} />
</View>
);
}
_changeStateScanline() {
//Alert.alert("changed");
this.setState({
animationScanLine: !this.state.animationScanLine
});
}
// Invoked when a model has started to load, we show a loading indictator.
_onLoadStart() {
this.setState({
isLoading: true,
});
}
// Invoked when a model has loaded, we hide the loading indictator.
_onLoadEnd() {
this.setState({
isLoading: false,
});
}
_onResetScanAr() {
Alert.alert("reset");
//Alert.alert(this.state.resetScene);
/* this.setState({
resetScene: !this.state.resetScene,
//animationScanLine: !this.state.animationScanLine,
viroAppProps:{...resetScene: !this.state.resetScene},
});*/
//this._onLoadStart();
// this._renderTrackingScanLine();
//this.renderOverlay();
//Alert.alert(this.state.resetScene);
//this.arSceneNavigator.resetARSession(true, true);
//this.resetARSession(false, true);
}
_onDisplayDialog() {
Alert.alert(
'Scanner un autre objet',
'Select an object to place in the world!',
[
{text: 'Coffee Mug', onPress: () => this._onShowObject(0, "coffee_mug", 0)},
{text: 'Flowers', onPress: () => this._onShowObject(1, "flowers", .290760)},
{text: 'Smile Emoji', onPress: () => this._onShowObject(2, "smile_emoji", .497823)},
],
);
}
_renderActivityLoader() {
return (<View style={{position:'absolute', left:0, right:0, top:0, bottom:0, alignItems: 'center', justifyContent:'center'}}>
<ActivityIndicator size='large' animating={this.state.isLoading} color='#ffffff'/>
</View>);
}
_renderTrackingScanLine() {
this.toggleAnimation();
// Alert.alert(this.state.viroAppProps.animationScanLine)
return (
this.renderOverlay()
);
}
render() {
return (
<View style={styles.outer} >
<ViroARSceneNavigator key={1} style={styles.arView}
apiKey={apiKey}
numberOfTrackedImages={1}
pbrEnabled={true}
videoQuality="High"
initialScene={{scene:InitialARScene, passProps:{animationScanLine:this.state.animationScanLine}}}
//initialScene={{scene:InitialARScene, passProps:{animationScanLine:this.state.animationScanLine, resetScene: this.state.resetScene}}}
viroAppProps={ this.state.viroAppProps}
//worldAlignment="GravityAndHeading"
/>
{ this.state.animationScanLine ? this._renderTrackingScanLine() : this._renderActivityLoader() }
<View style={{position: 'absolute', left: 0, right: 0, bottom: 15, alignItems: 'center'}}>
<TouchableHighlight style={styles.buttons}
onPress={this._onDisplayDialog}
//onPress={this._onResetScanAr}
underlayColor={'#00000000'} >
<Image source={require("./js/res/btn_mode_objects_on.png")} />
</TouchableHighlight>
</View>
</View>
);
}
}
ICEar = codePush(codePushOptions)(ICEar);
//onPress={this._onResetScanAr}
export default ICEar;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
helloWorldTextStyle: {
fontFamily: 'Arial',
fontSize: 30,
color: '#ffffff',
textAlignVertical: 'center',
textAlign: 'center',
},
outer : {
flex : 1,
},
arView: {
flex:1,
},
buttons : {
height: 60,
width: 60,
paddingTop:20,
paddingBottom:20,
marginTop: 10,
marginBottom: 10,
backgroundColor:'#00000000',
borderRadius: 10,
borderWidth: 1,
borderColor: '#ffffff00',
},
lineStyle:{
borderWidth: 4,
borderColor:'red',
margin:0,
top: 0,
width: width,
shadowOffset:{ width: 0, height: 4, },
shadowColor: 'black',
shadowOpacity: 1.0,
elevation: 8,
shadowRadius: 20 ,
},
overlay: {
position:'absolute',
left:0,
right:0,
top:0,
bottom:0,
alignItems: 'center',
justifyContent:'center'
},
overlayHeart: {
tintColor: '#fff',
},
});