Skip to content

Commit 91d89f5

Browse files
author
Miguel Espinoza
committed
onPress loads saved board
1 parent 80504b5 commit 91d89f5

File tree

12 files changed

+344
-52
lines changed

12 files changed

+344
-52
lines changed

.gitignore

+47
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
2+
# Created by https://www.gitignore.io/api/android
3+
4+
### Android ###
5+
*.keystore
6+
# Built application files
7+
*.apk
8+
*.ap_
9+
10+
# Files for the Dalvik VM
11+
*.dex
12+
13+
# Java class files
14+
*.class
15+
16+
# Generated files
17+
bin/
18+
gen/
19+
out/
20+
21+
# Gradle files
22+
.gradle/
23+
build/
24+
25+
# Local configuration file (sdk path, etc)
26+
local.properties
27+
28+
# Proguard folder generated by Eclipse
29+
proguard/
30+
31+
# Log Files
32+
*.log
33+
34+
# Android Studio Navigation editor temp files
35+
.navigation/
36+
37+
# Android Studio captures folder
38+
captures/
39+
40+
# Intellij
41+
*.iml
42+
43+
### Android Patch ###
44+
gen-external-apklibs
45+
46+
47+
148
# OSX
249
#
350
.DS_Store

android/app/src/main/res/mipmap-hdpi/ic_launcher.png

100644100755
2.28 KB
Loading

android/app/src/main/res/mipmap-mdpi/ic_launcher.png

100644100755
1.14 KB
Loading

android/app/src/main/res/mipmap-xhdpi/ic_launcher.png

100644100755
3.43 KB
Loading

android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png

100644100755
5.49 KB
Loading
Loading
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">goku</string>
2+
<string name="app_name">Goku</string>
33
</resources>

app/components/GokuToolbar.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
'use strict';
2+
import React, {
3+
StyleSheet,
4+
Button,
5+
Text,
6+
View,
7+
Animated
8+
} from 'react-native';
9+
10+
var ToolbarAndroid = require('ToolbarAndroid');
11+
12+
var GokuToolbar = React.createClass({
13+
selectedTabIcons: [],
14+
unselectedTabIcons: [],
15+
16+
propTypes: {
17+
goToPage: React.PropTypes.func,
18+
activeTab: React.PropTypes.number,
19+
tabs: React.PropTypes.array
20+
},
21+
22+
toolbarActions (currentTab) {
23+
switch (currentTab) {
24+
case 0:
25+
return solveToolbarActions
26+
case 1:
27+
return savedToolbarAction
28+
}
29+
},
30+
31+
renderTabOption( name, page ) {
32+
var isTabActive = this.props.activeTab === page;
33+
34+
return (
35+
<View>
36+
<Button key={name} onPress={() => this.props.goToPage(page)}>
37+
<Text>
38+
{name}
39+
</Text>
40+
</Button>
41+
</View>
42+
);
43+
},
44+
45+
render() {
46+
var containerWidth = this.props.containerWidth;
47+
var numberOfTabs = this.props.tabs.length;
48+
var tabUnderlineStyle = {
49+
position: 'absolute',
50+
width: containerWidth / numberOfTabs,
51+
height: 4,
52+
backgroundColor: 'white',
53+
bottom: 0,
54+
};
55+
56+
var left = this.props.scrollValue.interpolate({
57+
inputRange: [ 0, 1 ], outputRange: [ 0, containerWidth / numberOfTabs ]
58+
});
59+
60+
return (
61+
<View>
62+
<ToolbarAndroid
63+
title="Goku"
64+
titleColor='white'
65+
style={styles.toolbar}
66+
actions={this.toolbarActions(this.props.activeTab)}
67+
/>
68+
</View>
69+
);
70+
}
71+
});
72+
73+
var solveToolbarActions = [
74+
{title: 'Solve', icon: require('../assets/solve_icon.png'), show:'always'},
75+
{title: 'Delete', icon: require('../assets/delete_icon.png'), show:'always'},
76+
{title: 'Save', icon: require('../assets/save_icon.png'), show:'always'},
77+
];
78+
79+
var savedToolbarAction = [];
80+
81+
const styles = StyleSheet.create({
82+
toolbar: {
83+
backgroundColor: '#2196F3',
84+
height: 56
85+
},
86+
tabs: {
87+
88+
}
89+
});
90+
91+
module.exports = GokuToolbar;

app/pages/SavedPage.js

+92-25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {
44
StyleSheet,
55
PixelRatio,
66
ScrollView,
7+
TouchableOpacity,
78
View,
89
Text
910
} from 'react-native';
@@ -34,29 +35,88 @@ var SavedPage = React.createClass({
3435
);
3536
},
3637

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);
3944
return (
4045
<View style={styles.itemRow}>
41-
<View style={styles.circle}>
46+
<View
47+
style={styles.circle}>
4248
<Text style={styles.itemRowID}>
4349
{rowID+1}
4450
</Text>
4551
</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)} />
4956
</View>
5057
);
5158
},
5259

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+
60120
var rows = [];
61121
var blocks = [];
62122
var puzzle = _.chunk([...board.solved], 9);
@@ -91,18 +151,25 @@ var SavedPage = React.createClass({
91151
</View>
92152
);
93153
});
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>);
95160
blocks = [];
96161
});
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>);
104171
}
105-
});
172+
}
106173

107174
var styles = StyleSheet.create({
108175
// For the container View
@@ -129,7 +196,7 @@ var styles = StyleSheet.create({
129196
width: 50,
130197
height: 50,
131198
borderRadius: 25,
132-
backgroundColor: '#7C4DFF',
199+
backgroundColor: '#03A9F4',
133200
marginTop:32,
134201
},
135202
boardContent: {
@@ -154,15 +221,15 @@ var styles = StyleSheet.create({
154221
boardBlock: {
155222
flex: 1,
156223
justifyContent: 'flex-start',
157-
borderWidth: 1 / PixelRatio.get(),
224+
borderWidth: 5 / PixelRatio.get(),
158225
height:20,
159226
},
160227
boardBlockSelected: {
161228
flex: 1,
162229
justifyContent: 'flex-start',
163230
borderWidth: 1 / PixelRatio.get(),
164231
height:20,
165-
backgroundColor: '#B39DDB',
232+
backgroundColor: '#81D4FA',
166233
},
167234
boardBlockSeperator: {
168235
borderRightWidth: 2

0 commit comments

Comments
 (0)