-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapptest.js
124 lines (114 loc) · 3.07 KB
/
apptest.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
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TouchableHighlight,
} from 'react-native';
import * as Animatable from 'react-native-animatable';
import Collapsible from 'react-native-collapsible';
import Accordion from 'react-native-collapsible/Accordion';
const BACON_IPSUM = 'Bacon ipsum dolor amet chuck turducken landjaeger tongue spare ribs. Picanha beef prosciutto meatball turkey shoulder shank salami cupim doner jowl pork belly cow. Chicken shankle rump swine tail frankfurter meatloaf ground round flank ham hock tongue shank andouille boudin brisket. ';
const CONTENT = [
{
title: 'First',
content: BACON_IPSUM,
},
{
title: 'Second',
content: BACON_IPSUM,
},
{
title: 'Third',
content: BACON_IPSUM,
},
{
title: 'Fourth',
content: BACON_IPSUM,
},
{
title: 'Fifth',
content: BACON_IPSUM,
},
];
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#F5FCFF',
},
title: {
textAlign: 'center',
fontSize: 22,
fontWeight: '300',
marginBottom: 20,
},
header: {
backgroundColor: '#F5FCFF',
padding: 10,
},
headerText: {
textAlign: 'center',
fontSize: 16,
fontWeight: '500',
},
content: {
flex: 1,
padding: 20,
backgroundColor: '#fff',
},
active: {
backgroundColor: 'rgba(255,255,255,1)',
},
inactive: {
backgroundColor: 'rgba(245,252,255,1)',
},
});
var apptest = React.createClass({
getInitialState: function() {
return {
collapsed: true,
}
},
_toggleExpanded() {
this.setState({ collapsed: !this.state.collapsed });
},
_renderHeader(section, i, isActive) {
return (
<Animatable.View duration={400} style={[styles.header, isActive ? styles.active : styles.inactive]} transition="backgroundColor">
<Text style={styles.headerText}>{section.title}</Text>
</Animatable.View>
);
},
_renderContent(section, i, isActive) {
return (
<Animatable.View duration={400} style={[styles.content, isActive ? styles.active : styles.inactive]} transition="backgroundColor">
<Animatable.Text animation={isActive ? 'bounceIn' : undefined}>{section.content}</Animatable.Text>
</Animatable.View>
);
},
render() {
return (
<View style={styles.container}>
<Text style={styles.title}>Accordion Example</Text>
<TouchableHighlight onPress={this._toggleExpanded}>
<View style={styles.header}>
<Text style={styles.headerText}>Single Collapsible</Text>
</View>
</TouchableHighlight>
<Collapsible collapsed={this.state.collapsed} align="center">
<View style={styles.content}>
<Text>Bacon ipsum dolor amet chuck turducken landjaeger tongue spare ribs</Text>
</View>
</Collapsible>
<Accordion
sections={CONTENT}
renderHeader={this._renderHeader}
renderContent={this._renderContent}
duration={400}
/>
</View>
);
}
});
module.exports = apptest;