@@ -4,6 +4,7 @@ import React, {
4
4
StyleSheet ,
5
5
PixelRatio ,
6
6
ScrollView ,
7
+ TouchableOpacity ,
7
8
View ,
8
9
Text
9
10
} from 'react-native' ;
@@ -34,29 +35,88 @@ var SavedPage = React.createClass({
34
35
) ;
35
36
} ,
36
37
37
- _renderRow ( item , sectionID , rowID ) {
38
- console . log ( item ) ;
38
+ _onBoardClicked ( board ) {
39
+ console . log ( "onBoardClicked: " + board . solved ) ;
40
+ } ,
41
+
42
+ _renderRow ( rowData , sectionID , rowID ) {
43
+ console . log ( rowData ) ;
39
44
return (
40
45
< View style = { styles . itemRow } >
41
- < View style = { styles . circle } >
46
+ < View
47
+ style = { styles . circle } >
42
48
< Text style = { styles . itemRowID } >
43
49
{ rowID + 1 }
44
50
</ Text >
45
51
</ View >
46
- < View style = { styles . boardContent } >
47
- { this . _renderCuteBoard ( item ) }
48
- </ View >
52
+
53
+ < BoardItem
54
+ item = { rowData }
55
+ onPress = { ( ) => this . props . onPressItem ( rowData , rowID ) } />
49
56
</ View >
50
57
) ;
51
58
} ,
52
59
53
- _renderCuteBoard ( board ) {
54
- console . log ( "cuteBoard: " + board . presolved ) ;
55
- // return (
56
- // <Text>
57
- // {board.solved}
58
- // </Text>
59
- // );
60
+ // _renderCuteBoard(board) {
61
+ // console.log("cuteBoard: " + board.presolved);
62
+ //
63
+ // var rows = [];
64
+ // var blocks = [];
65
+ // var puzzle = _.chunk([...board.solved], 9);
66
+ // var userInserts = board.presolved.split(',');
67
+ //
68
+ // puzzle.map((row) => {
69
+ // var rowSeperator = ((rows.length == 2 || rows.length == 5)) ? true : false;
70
+ //
71
+ // row.map((block) => {
72
+ // var key = rows.length + "_" + blocks.length;
73
+ //
74
+ // var isUserInsert = false;
75
+ // userInserts.map((insertKey) => {
76
+ // if (insertKey == key) {
77
+ // isUserInsert = true;
78
+ // console.log(insertKey + " :: " + key + " :: found match");
79
+ // }
80
+ // });
81
+ // var blockSeperator = ((blocks.length == 2 || blocks.length == 5)) ? true : false;
82
+ //
83
+ // // console.log("block not null");
84
+ // blocks.push(
85
+ // <View
86
+ // key={key}
87
+ // style={[
88
+ // styles.boardBlock,
89
+ // blockSeperator && styles.boardBlockSeperator,
90
+ // isUserInsert && styles.boardBlockSelected
91
+ // ]}
92
+ // >
93
+ // <Text style={styles.boardBlockText}>{block}</Text>
94
+ // </View>
95
+ // );
96
+ // });
97
+ // rows.push(<View
98
+ // key={rows.length}
99
+ // style={[styles.boardRow, rowSeperator && styles.boardRowSeperator]}
100
+ // >
101
+ // {blocks}
102
+ // </View>);
103
+ // blocks = [];
104
+ // });
105
+ // return (<View key={rows.length} style={styles.boardContainer}>{rows}</View>);
106
+ // },
107
+
108
+ updateDataSource ( ) {
109
+ this . setState ( {
110
+ dataSource : this . state . dataSource . cloneWithRows ( GokuDB . getBoards ( ) ) ,
111
+ } ) ;
112
+ }
113
+ } ) ;
114
+
115
+
116
+ class BoardItem extends React . Component {
117
+ render ( ) {
118
+ var board = this . props . item ;
119
+
60
120
var rows = [ ] ;
61
121
var blocks = [ ] ;
62
122
var puzzle = _ . chunk ( [ ...board . solved ] , 9 ) ;
@@ -91,18 +151,25 @@ var SavedPage = React.createClass({
91
151
</ View >
92
152
) ;
93
153
} ) ;
94
- rows . push ( < View key = { rows . length } style = { [ styles . boardRow , rowSeperator && styles . boardRowSeperator ] } > { blocks } </ View > ) ;
154
+ rows . push ( < View
155
+ key = { rows . length }
156
+ style = { [ styles . boardRow , rowSeperator && styles . boardRowSeperator ] }
157
+ >
158
+ { blocks }
159
+ </ View > ) ;
95
160
blocks = [ ] ;
96
161
} ) ;
97
- return ( < View key = { rows . length } style = { styles . boardContainer } > { rows } </ View > ) ;
98
- } ,
99
-
100
- updateDataSource ( ) {
101
- this . setState ( {
102
- dataSource : this . state . dataSource . cloneWithRows ( GokuDB . getBoards ( ) ) ,
103
- } ) ;
162
+ return ( < TouchableOpacity
163
+ onPress = { this . props . onPress }
164
+ style = { styles . boardContent } >
165
+ < View
166
+ key = { rows . length }
167
+ style = { styles . boardContainer } >
168
+ { rows }
169
+ </ View >
170
+ </ TouchableOpacity > ) ;
104
171
}
105
- } ) ;
172
+ }
106
173
107
174
var styles = StyleSheet . create ( {
108
175
// For the container View
@@ -129,7 +196,7 @@ var styles = StyleSheet.create({
129
196
width : 50 ,
130
197
height : 50 ,
131
198
borderRadius : 25 ,
132
- backgroundColor : '#7C4DFF ' ,
199
+ backgroundColor : '#03A9F4 ' ,
133
200
marginTop :32 ,
134
201
} ,
135
202
boardContent : {
@@ -154,15 +221,15 @@ var styles = StyleSheet.create({
154
221
boardBlock : {
155
222
flex : 1 ,
156
223
justifyContent : 'flex-start' ,
157
- borderWidth : 1 / PixelRatio . get ( ) ,
224
+ borderWidth : 5 / PixelRatio . get ( ) ,
158
225
height :20 ,
159
226
} ,
160
227
boardBlockSelected : {
161
228
flex : 1 ,
162
229
justifyContent : 'flex-start' ,
163
230
borderWidth : 1 / PixelRatio . get ( ) ,
164
231
height :20 ,
165
- backgroundColor : '#B39DDB ' ,
232
+ backgroundColor : '#81D4FA ' ,
166
233
} ,
167
234
boardBlockSeperator : {
168
235
borderRightWidth : 2
0 commit comments