-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
App.js
137 lines (130 loc) · 3.97 KB
/
App.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
/*
* @Author: Young
* DSHARP
* @flow
* @Date: 2018-02-08 17:53:17
* @Last Modified by: Young
* @Last Modified time: 2018-08-31 09:59:55
*/
import React, { Component } from "react";
import { StyleSheet, Text, View, ScrollView, Dimensions } from "react-native";
const SCREEN_WIDTH = Dimensions.get("window").width;
const ios_blue = "#007AFF";
const themeColor = "#0D1014";
import { SelectMultipleGroupButton } from "./index.js";
import SimpleButton from "./sample/SimpleButton";
import GroupButton from "./sample/GroupButton";
import SegmentedControl from "./sample/SegmentedControl";
import ListButton from "./sample/ListButton";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
usageScrollView: null
};
}
render() {
return (
<View style={{ flex: 1, backgroundColor: "#15191F" }}>
<View style={{ marginTop: 20 }}>
<SelectMultipleGroupButton
multiple={false}
group={[
{ value: "SimpleBtn" },
{ value: "GroupBtn" },
{ value: "Segment" },
{ value: "List" }
]}
defaultSelectedIndexes={[0]}
singleTap={valueTap => {
switch (valueTap) {
case "SimpleBtn":
this.state.usageScrollView.scrollTo({
x: 0 * SCREEN_WIDTH,
y: 0,
animated: true
});
break;
case "GroupBtn":
this.state.usageScrollView.scrollTo({
x: 1 * SCREEN_WIDTH,
y: 0,
animated: true
});
break;
case "Segment":
this.state.usageScrollView.scrollTo({
x: 2 * SCREEN_WIDTH,
y: 0,
animated: true
});
break;
case "List":
this.state.usageScrollView.scrollTo({
x: 3 * SCREEN_WIDTH,
y: 0,
animated: true
});
break;
default:
break;
}
}}
buttonViewStyle={{ flex: 1, margin: 0, borderRadius: 0 }}
highLightStyle={{
borderColor: ios_blue,
textColor: ios_blue,
backgroundColor: themeColor,
borderTintColor: ios_blue,
textTintColor: "white",
backgroundTintColor: ios_blue
}}
/>
<ScrollView
ref={ref => (this.state.usageScrollView = ref)}
pagingEnabled={true}
scrollEnabled={false}
horizontal={true}
>
<ScrollView
style={styles.horizontalView}
contentContainerStyle={styles.contentStyle}
>
<Text style={styles.usageTitle}>Simple Button Usage</Text>
<SimpleButton />
</ScrollView>
<ScrollView
style={styles.horizontalView}
contentContainerStyle={styles.contentStyle}
>
<Text style={styles.usageTitle}>Group Button Usage</Text>
<GroupButton />
</ScrollView>
<ScrollView style={styles.horizontalView}>
<Text style={[styles.usageTitle, { marginBottom: 20 }]}>
SegmentedControl Usage
</Text>
<SegmentedControl />
</ScrollView>
<ScrollView style={styles.horizontalView}>
<Text style={styles.usageTitle}>List Usage</Text>
<ListButton />
</ScrollView>
</ScrollView>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
usageTitle: {
color: "white",
marginTop: 20
},
horizontalView: {
width: SCREEN_WIDTH
},
contentStyle: {
height: 700
}
});