Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Merge branch 'boilerplate-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
peat-psuwit committed Nov 14, 2018
2 parents faa6055 + 02458cf commit 01addda
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.4",
"react-native-firebase": "^5.1.0",
"react-native-ratings": "^6.0.0",
"react-navigation": "^2.18.2"
},
"devDependencies": {
Expand Down
28 changes: 26 additions & 2 deletions screens/AddCommentScreen/CommentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TextInput,
View,
} from 'react-native';
import { Rating } from 'react-native-ratings';

class CommentForm extends React.Component {
handleNameChanged = (text) => {
Expand All @@ -17,6 +18,16 @@ class CommentForm extends React.Component {
}
}

handleRatingChanged = (rating) => {
const { comment, onCommentChanged } = this.props;
if (typeof onCommentChanged === 'function') {
onCommentChanged({
...comment,
rating,
});
}
}

handleCommentChanged = (text) => {
const { comment, onCommentChanged } = this.props;
if (typeof onCommentChanged === 'function') {
Expand All @@ -29,7 +40,7 @@ class CommentForm extends React.Component {

render() {
const {
comment: { name, comment },
comment: { name, rating, comment },
onAddComment,
disabled,
} = this.props;
Expand All @@ -41,6 +52,16 @@ class CommentForm extends React.Component {
onChangeText={this.handleNameChanged}
editable={!disabled}
/>
<View style={styles.ratingWrapper}>
<Rating
type="star"
showRating={true}
imageSize={32}
fraction={0}
startingValue={rating}
onFinishRating={this.handleRatingChanged}
/>
</View>
<TextInput
placeholder="Comment"
style={styles.comment}
Expand All @@ -64,10 +85,13 @@ const styles = StyleSheet.create({
padding: 16,
backgroundColor: 'white',
},
ratingWrapper: {
alignSelf: 'center',
},
comment: {
height: 160,
textAlignVertical: 'top',
},
});

export default CommentForm;
export default CommentForm;
3 changes: 2 additions & 1 deletion screens/AddCommentScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AddCommentScreen extends React.Component {
state = {
comment: {
name: '',
rating: 3,
comment: '',
},
disableForm: false,
Expand Down Expand Up @@ -52,4 +53,4 @@ class AddCommentScreen extends React.Component {
}
}

export default AddCommentScreen;
export default AddCommentScreen;
11 changes: 10 additions & 1 deletion screens/AlbumDetailScreen/AlbumHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Text,
View,
} from 'react-native';
import { Rating } from 'react-native-ratings';

class AlbumHeader extends React.Component {
handleSeePressed = () => {
Expand All @@ -21,6 +22,7 @@ class AlbumHeader extends React.Component {
artist,
image,
url,
avg_rating,
} = album;

return (
Expand All @@ -34,6 +36,13 @@ class AlbumHeader extends React.Component {
<Text style={styles.title}>{title}</Text>
<Text style={styles.artist}>{artist}</Text>

<Rating
readonly
type="star"
imageSize={28}
startingValue={typeof avg_rating === 'number' ? avg_rating : 0}
/>

<View style={styles.buttonWrapper}>
<Button
title="See on Amazon"
Expand Down Expand Up @@ -85,4 +94,4 @@ const styles = StyleSheet.create({
},
});

export default AlbumHeader;
export default AlbumHeader;
10 changes: 9 additions & 1 deletion screens/AlbumListScreen/AlbumEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TouchableHighlight,
View,
} from 'react-native';
import { Rating } from 'react-native-ratings';

class AlbumEntry extends React.Component {
handlePressed = () => {
Expand All @@ -21,6 +22,7 @@ class AlbumEntry extends React.Component {
title,
artist,
thumbnail_image,
avg_rating,
} = album;

return (
Expand All @@ -36,6 +38,12 @@ class AlbumEntry extends React.Component {
<View style={styles.textContainer}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.artist}>{artist}</Text>
<Rating
readonly
type="star"
imageSize={20}
startingValue={typeof avg_rating === 'number' ? avg_rating : 0}
/>
</View>
</View>
</TouchableHighlight>
Expand Down Expand Up @@ -72,4 +80,4 @@ const styles = StyleSheet.create({
}
});

export default AlbumEntry;
export default AlbumEntry;
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4228,7 +4228,7 @@ prompts@^0.1.9:
kleur "^2.0.1"
sisteransi "^0.1.1"

prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
dependencies:
Expand Down Expand Up @@ -4335,6 +4335,13 @@ react-native-firebase@^5.1.0:
dependencies:
opencollective-postinstall "^2.0.0"
prop-types "^15.6.2"
react-native-ratings@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/react-native-ratings/-/react-native-ratings-6.0.0.tgz#8083c4955c14aef0751abb7f5ba6c48ae8b2189b"
integrity sha512-65gbGrtR+Y+/bEWxZGbNmYP1CL/3FerNFLQXWCuoYS0Gzn7HqMuSS3HObYjHX4jlRH9KKjIjhP/q59N7AwgAiA==
dependencies:
lodash "^4.17.4"
prop-types "^15.5.10"

[email protected]:
version "0.11.0"
Expand Down

0 comments on commit 01addda

Please sign in to comment.