File tree Expand file tree Collapse file tree 5 files changed +99
-4
lines changed Expand file tree Collapse file tree 5 files changed +99
-4
lines changed Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import {
3+ StyleSheet ,
4+ Text ,
5+ View
6+ } from 'react-native' ;
7+ import ScrollableTabView , { DefaultTabBar , } from 'react-native-scrollable-tab-view' ;
8+
9+ import SensorExample from './SensorExample' ;
10+ import SensorAwareViewExample from './SensorAwareViewExample' ;
11+
12+ export default class Example extends Component {
13+ render ( ) {
14+ return (
15+ < ScrollableTabView
16+ style = { { marginTop : 20 , } }
17+ renderTabBar = { ( ) => < DefaultTabBar /> }
18+ >
19+ < SensorExample tabLabel = "Sensors" />
20+ < SensorAwareViewExample tabLabel = "SensorAwareView" />
21+ </ ScrollableTabView >
22+ ) ;
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import {
3+ StyleSheet ,
4+ Text ,
5+ View
6+ } from 'react-native' ;
7+ import RNSensors from 'react-native-sensors' ;
8+
9+ function SensorView ( props ) {
10+ const Component = RNSensors . decorator ( {
11+ ...props ,
12+ } ) ( SensorsDisplay ) ;
13+
14+ return (
15+ < Component />
16+ )
17+ }
18+
19+ const SensorDisplay = ( { value, name } ) => (
20+ < Text style = { styles . welcome } > { name } : { value } </ Text >
21+ ) ;
22+
23+ class SensorsDisplay extends Component {
24+ render ( ) {
25+ const {
26+ Accelerometer,
27+ Gyroscope,
28+ Magnetometer,
29+ } = this . props ;
30+
31+ debugger ;
32+
33+ return (
34+ < View style = { styles . container } >
35+ < SensorDisplay name = "Accelerometer" value = { Accelerometer } />
36+ < SensorDisplay name = "Gyroscope" value = { Gyroscope } />
37+ < SensorDisplay name = "Magnetometer" value = { Magnetometer } />
38+ </ View >
39+ ) ;
40+ }
41+ }
42+
43+ export default class SensorAwareViewExample extends Component {
44+ render ( ) {
45+ return (
46+ < View style = { styles . container } >
47+ < SensorView Accelerometer Gyroscope Magnetometer />
48+ </ View >
49+ ) ;
50+ }
51+ }
52+
53+ const styles = StyleSheet . create ( {
54+ container : {
55+ flex : 1 ,
56+ justifyContent : 'center' ,
57+ alignItems : 'center' ,
58+ backgroundColor : '#F5FCFF' ,
59+ } ,
60+ welcome : {
61+ fontSize : 20 ,
62+ textAlign : 'center' ,
63+ margin : 10 ,
64+ } ,
65+ instructions : {
66+ textAlign : 'center' ,
67+ color : '#333333' ,
68+ marginBottom : 5 ,
69+ } ,
70+ } ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { AppRegistry } from 'react-native' ;
3- import SensorExample from './SensorExample ' ;
3+ import Example from './Example ' ;
44
5- AppRegistry . registerComponent ( 'SensorExample' , ( ) => SensorExample ) ;
5+ AppRegistry . registerComponent ( 'SensorExample' , ( ) => Example ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { AppRegistry } from 'react-native' ;
3- import SensorExample from './SensorExample ' ;
3+ import Example from './Example ' ;
44
5- AppRegistry . registerComponent ( 'SensorExample' , ( ) => SensorExample ) ;
5+ AppRegistry . registerComponent ( 'SensorExample' , ( ) => Example ) ;
Original file line number Diff line number Diff line change 99 "dependencies" : {
1010 "react" : " 15.4.1" ,
1111 "react-native" : " 0.39.2" ,
12+ "react-native-scrollable-tab-view" : " ^0.7.0" ,
1213 "react-native-sensors" : " next"
1314 },
1415 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments