-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
155 lines (132 loc) · 3.38 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { Component } from 'react';
import { StyleSheet, Text, View, Dimensions, ScrollView, Image } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
// import { DraxProvider, DraxView, DraxList } from 'react-native-drax';
import Board from './src/components/Board'
import RowRepository from './src/lib/RowRepository'
export default class App extends Component {
constructor(props) {
super(props);
const data = [
{
id: 1,
name: 'A',
rows: [
{ id: 1, name: 'Item1', c: 1 },
{ id: 2, name: 'Item2',c: 1 },
{ id: 3, name: 'Item3',c: 1},
]
},
{
id: 2,
name: 'B',
rows: [
{ id: 4, name: 'Item4' ,c: 2}
]
},
];
this.state = {
rowRepository: new RowRepository(data)
};
}
renderRow(item,index,columnid) {
let style = [styles.item];
// Just to show that other sizes works as well
// if (itemm.id == 2) {
// style.push({ height: 100 });
// }
// let available = false;
// data.map((item,index) => {
// let av = item.rows.findIndex(obj => obj.id == item.id)
// if (av)
// {
// if (index == 1)
// {
// available = true
// }
// }
// })
console.log("item...", item)
return (
<View style={style}>
{
columnid == 2 &&
<View style={{ backgroundColor: 'red', justifyContent: 'center', alignSelf: 'flex-start', alignItems: 'center', height: 20, width: 15 }}>
<Text style={{ color: 'white', fontWeight: 'bold' }}>{index + 1}</Text>
</View>
}
<Image source={require('./assets/adjust.png')} />
<Text>{item.name}</Text>
</View>
)
}
renderColumnWrapper(column, index, columnComponent) {
return (
<View key={`column-${index}`} style={styles.column}>
<Text style={styles.columnHeader}>{column.name}</Text>
{columnComponent}
</View>
);
}
onOpen(item) {
console.log('Opened!', item);
}
onDragEnd(srcColumnId, destColumnId, item) {
console.log(`Dragged item ${item.id()} from column ${srcColumnId} to column ${destColumnId}`);
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignContent: 'center' }}>
<Board
style={styles.board}
rowRepository={this.state.rowRepository}
renderRow={this.renderRow.bind(this)}
renderColumnWrapper={this.renderColumnWrapper.bind(this)}
open={this.onOpen.bind(this)}
onDragEnd={this.onDragEnd.bind(this)}
/>
</View>
);
}
}
const styles = StyleSheet.create({
board: {
flex: 1,
padding: 15,
backgroundColor: '#63A2B8',
},
column: {
width: 300,
margin: 10,
padding: 10,
backgroundColor: '#F5FCFF',
borderWidth: 1,
borderColor: 'white',
borderRadius: 5,
},
columnHeader: {
fontWeight: 'bold',
fontSize: 18,
padding: 10,
alignSelf: 'center'
},
item: {
flex: 1,
width: 70,
margin: 5,
height: 100,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white',
borderWidth: 1,
borderColor: '#63A2B8',
borderRadius: 5,
}
});