Commit 4f5c54ee by jhrabal

radegast

parent 2d2df240
import React from 'react'; import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity, AsyncStorage, Alert, StatusBar, ImageBackground, Image } from 'react-native'; import { Text, View, TouchableOpacity, AsyncStorage, StatusBar, Image } from 'react-native';
import EStyleSheet from 'react-native-extended-stylesheet';
const SEND_DATA_TIMER = 60000; const SEND_DATA_TIMER = 60000;
...@@ -14,8 +16,7 @@ class App extends React.PureComponent { ...@@ -14,8 +16,7 @@ class App extends React.PureComponent {
super(props); super(props);
this.state = { this.state = {
mode: 'rating', mode: 'rating',
stats: {}, lastRating: null,
statsLoading: false,
buffer: [] buffer: []
}; };
...@@ -79,7 +80,7 @@ class App extends React.PureComponent { ...@@ -79,7 +80,7 @@ class App extends React.PureComponent {
let rating = { rating: r, key }; let rating = { rating: r, key };
try { try {
this.setState({ mode: "info" }); this.setState({ mode: "info", lastRating: r });
await AsyncStorage.setItem(JSON.stringify(key), JSON.stringify(rating)); await AsyncStorage.setItem(JSON.stringify(key), JSON.stringify(rating));
//add to buffer //add to buffer
...@@ -95,53 +96,29 @@ class App extends React.PureComponent { ...@@ -95,53 +96,29 @@ class App extends React.PureComponent {
} }
renderResults() { render() {
return <View></View> let { mode, lastRating } = this.state;
} let showInfo = mode == "info";
renderInfo() {
return <View style={styles.center}><Text>Děkujeme za hodnocení</Text></View>
}
renderRating() {
const buttons = []; const buttons = [];
for (let i = 1; i <= 10; i++) { for (let i = 1; i <= 10; i++) {
buttons.push(<TouchableOpacity key={ i } onPress={ this.onPress(i) }> buttons.push(
<Text style={styles.rating}>{ i }</Text> <TouchableOpacity key={ i } onPress={ this.onPress(i) }>
<View style={styles.rating}>
<Text style={styles.ratingNumber}>{ i }</Text>
{ showInfo && lastRating && i <= lastRating ? <Image source={ require('./assets/siska.png') } style={ styles.ratingImage } /> : null }
</View>
</TouchableOpacity> </TouchableOpacity>
); );
} }
return ( return (
<View style={styles.container}>
<StatusBar hidden />
<Image source={ require('./assets/bg.jpg') } style={ styles.bg } imageStyle={{ resizeMode: 'stretch' }}/>
<View style={styles.ratingsContainer}> <View style={styles.ratingsContainer}>
{ buttons } { buttons }
</View> </View>
);
}
render() {
let { mode } = this.state;
let content = null;
switch (mode) {
case 'results':
content = this.renderResults();
break;
case 'info':
default:
content = this.renderRating();
}
return (
<View style={styles.container}>
<StatusBar hidden />
<Image source={ require('./assets/bg.jpg') } style={{width: '100%', height: '100%', position: 'absolute'}} imageStyle={{ resizeMode: 'stretch' }}/>
{ content }
</View> </View>
); );
} }
...@@ -153,20 +130,35 @@ class App extends React.PureComponent { ...@@ -153,20 +130,35 @@ class App extends React.PureComponent {
export default App; export default App;
const styles = StyleSheet.create({
EStyleSheet.build({});
const styles = EStyleSheet.create({
container: {
flex: 1,
backgroundColor: '#000000',
width: '100%',
height: '100%'
},
center: { center: {
flex: 1, flex: 1,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
bg: {
width: '100%',
height: '100%',
position: 'absolute'
},
ratingsContainer: { ratingsContainer: {
position: 'absolute', position: 'absolute',
left: 0, left: 0,
top: '35%', top: '32%',
width: '100%', width: '100%',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'flex-start',
justifyContent: 'space-around', justifyContent: 'space-around',
color: '#FFFFFF', color: '#FFFFFF',
paddingLeft: '5%', paddingLeft: '5%',
...@@ -174,16 +166,28 @@ const styles = StyleSheet.create({ ...@@ -174,16 +166,28 @@ const styles = StyleSheet.create({
}, },
rating: { rating: {
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'center',
position: 'relative'
},
ratingNumber: {
backgroundColor: '#FFFFFF', backgroundColor: '#FFFFFF',
fontSize: 20, fontSize: '1.4rem',
borderRadius: 14, borderRadius: '1rem',
width: 28, width: '2rem',
height: 28, height: '2rem',
textAlign: 'center' textAlign: 'center'
}, },
container: { ratingImage: {
flex: 1, resizeMode: 'contain',
backgroundColor: '#000000' position: 'absolute',
}, top: '3rem',
height: '4.5rem'
}
}); });
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
"orientation": "landscape", "orientation": "landscape",
"icon": "./assets/icon.png", "icon": "./assets/icon.png",
"splash": { "splash": {
"image": "./assets/bg.jpg", "backgroundColor": "#BCBCBC"
"resizeMode": "contain",
"backgroundColor": "#000000"
}, },
"updates": { "updates": {
"fallbackToCacheTimeout": 0 "fallbackToCacheTimeout": 0
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"react": "16.8.3", "react": "16.8.3",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-extended-stylesheet": "^0.12.0",
"react-native-web": "^0.11.4" "react-native-web": "^0.11.4"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -1496,6 +1496,11 @@ css-in-js-utils@^2.0.0: ...@@ -1496,6 +1496,11 @@ css-in-js-utils@^2.0.0:
hyphenate-style-name "^1.0.2" hyphenate-style-name "^1.0.2"
isobject "^3.0.1" isobject "^3.0.1"
css-mediaquery@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/css-mediaquery/-/css-mediaquery-0.1.2.tgz#6a2c37344928618631c54bd33cedd301da18bea0"
integrity sha1-aiw3NEkoYYYxxUvTPO3TAdoYvqA=
debounce@^1.2.0: debounce@^1.2.0:
version "1.2.0" version "1.2.0"
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131" resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131"
...@@ -3485,6 +3490,11 @@ object-keys@^1.0.11, object-keys@^1.0.12: ...@@ -3485,6 +3490,11 @@ object-keys@^1.0.11, object-keys@^1.0.12:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
object-resolve-path@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/object-resolve-path/-/object-resolve-path-1.1.1.tgz#a7f8f93e8a20af80e44217ba7db54316d9d12232"
integrity sha1-p/j5Poogr4DkQhe6fbVDFtnRIjI=
object-visit@^1.0.0: object-visit@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb"
...@@ -3863,6 +3873,14 @@ react-native-branch@2.2.5: ...@@ -3863,6 +3873,14 @@ react-native-branch@2.2.5:
version "2.2.5" version "2.2.5"
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-2.2.5.tgz#4074dd63b4973e6397d9ce50e97b57c77a518e9d" resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-2.2.5.tgz#4074dd63b4973e6397d9ce50e97b57c77a518e9d"
react-native-extended-stylesheet@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/react-native-extended-stylesheet/-/react-native-extended-stylesheet-0.12.0.tgz#ebacf22d78a8e2173bdef2a08cbf1acba4dc051f"
integrity sha512-y4MEI+a9F8qtAKEjxKbwqotJg1FqKfl6vaiF25ULZ/VGkWI4GNTnsFunU9x6B3XJ6ly1E8O9fybO63u6UazL/A==
dependencies:
css-mediaquery "^0.1.2"
object-resolve-path "^1.1.0"
react-native-gesture-handler@1.2.1: react-native-gesture-handler@1.2.1:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.2.1.tgz#9c48fb1ab13d29cece24bbb77b1e847eebf27a2b" resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.2.1.tgz#9c48fb1ab13d29cece24bbb77b1e847eebf27a2b"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment