ViewRenderingTestModule.js
2.32 KB
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
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ViewRenderingTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
var View = require('View');
var StyleSheet = require('StyleSheet');
var renderApplication = require('renderApplication');
var styles = StyleSheet.create({
view: {
opacity: 0.75,
backgroundColor: 'rgb(255, 0, 0)',
},
});
class ViewSampleApp extends React.Component {
state = {};
render() {
return (
<View style={styles.view} collapsable={false}/>
);
}
}
var updateMargins;
class MarginSampleApp extends React.Component {
state = {margin: 10};
render() {
updateMargins = this.setState.bind(this, {margin: 15});
return (
<View style={{margin: this.state.margin, marginLeft: 20}} collapsable={false}/>
);
}
}
class BorderSampleApp extends React.Component {
render() {
return (
<View style={{borderLeftWidth: 20, borderWidth: 5, backgroundColor: 'blue'}} collapsable={false}>
<View style={{backgroundColor: 'red', width: 20, height: 20}} collapsable={false}/>
</View>
);
}
}
class TransformSampleApp extends React.Component {
render() {
var style = {
transform: [
{translateX: 20},
{translateY: 25},
{rotate: '15deg'},
{scaleX: 5},
{scaleY: 10},
]
};
return (
<View style={style} collapsable={false}/>
);
}
}
var ViewRenderingTestModule = {
renderViewApplication: function(rootTag) {
renderApplication(ViewSampleApp, {}, rootTag);
},
renderMarginApplication: function(rootTag) {
renderApplication(MarginSampleApp, {}, rootTag);
},
renderBorderApplication: function(rootTag) {
renderApplication(BorderSampleApp, {}, rootTag);
},
renderTransformApplication: function(rootTag) {
renderApplication(TransformSampleApp, {}, rootTag);
},
updateMargins: function() {
updateMargins();
},
};
BatchedBridge.registerCallableModule(
'ViewRenderingTestModule',
ViewRenderingTestModule
);
module.exports = ViewRenderingTestModule;