-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature small changes #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,20 @@ describe('make', () => { | |
}); | ||
}); | ||
|
||
describe('deep_linking_variables', () => { | ||
const data = { | ||
id: 10, | ||
message: "Saying hello to the world", | ||
title: "Hello World", | ||
start_date: "string", | ||
image_url: "string", | ||
deep_link: "string", | ||
deep_link_text: "string", | ||
}; | ||
Comment on lines
+26
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hobbs: You should use real life data in your tests. |
||
|
||
const newsMessage = new SkillzNewsMessage(data); | ||
|
||
it('returns deep link values', () => { | ||
expect(newsMessage.deep_link.toEqual(data.deep_link)); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,13 @@ | |
|
||
import React from 'react'; | ||
import _ from 'lodash'; | ||
import AppIcon from 'AppIcon'; | ||
import Label from 'Label'; | ||
import Markdown from 'react-native-markdown-renderer'; | ||
import PropTypes from 'prop-types'; | ||
import styles from 'SkillzNewsMessageCellStyles'; | ||
import DeepLinkUtils from 'DeepLinkUtils'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hobbs: This isn't in alphabetical order, fix it. |
||
import PushButton from 'PushButton'; | ||
|
||
import { | ||
Image, | ||
|
@@ -20,7 +23,22 @@ export default class SkillzNewsMessageCell extends React.PureComponent { | |
newsArticle: PropTypes.object.isRequired, | ||
} | ||
|
||
constructor(props: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hobbs: This should obviously be a stateless component, do you have any real need for state here, why are you using it? |
||
super(props); | ||
|
||
this.state = { | ||
newsArticle: this.props.newsArticle, | ||
}; | ||
} | ||
|
||
|
||
_renderMessageHeaderIcon(): React.Element<*> { | ||
if (this.props.newsArticle.game_specific) { | ||
return ( | ||
<AppIcon style={styles.headerAppIcon}/> | ||
); | ||
} | ||
|
||
return ( | ||
<SkillzImage source={'skillz_app_icon.png'} | ||
style={styles.headerIcon}/> | ||
|
@@ -38,6 +56,16 @@ export default class SkillzNewsMessageCell extends React.PureComponent { | |
); | ||
} | ||
|
||
_shouldRenderPlayButton(): boolean { | ||
return this.state.newsArticle.deep_link.length> 0; | ||
} | ||
|
||
_footerButtonOnPress = () => { | ||
console.log('It works!'); | ||
const deepLink = this.state.newsArticle.deep_link; | ||
DeepLinkUtils.handleDeeplink(deepLink); | ||
} | ||
|
||
_renderBody(): React.Element<*> { | ||
return ( | ||
<View style={styles.bodyContainer}> | ||
|
@@ -58,7 +86,23 @@ export default class SkillzNewsMessageCell extends React.PureComponent { | |
<View style={styles.containerView}> | ||
{this._renderHeader()} | ||
{this._renderBody()} | ||
</View> | ||
{() => { | ||
if (!this._shouldRenderPlayButton()) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<View style={styles.footerView}> | ||
<PushButton onPress={this._footerButtonOnPress} | ||
title={this.state.newsArticle.deep_link_text.toUpperCase()} | ||
style={styles.playButton} | ||
textStyle={styles.playButtonText} | ||
colors={SkillzStyle.fullStyles.btnGradientOne} | ||
cornerRadius={SkillzStyle.fullStyles.viewCornerRadiusSecondary.borderRadius}/> | ||
</View> | ||
) | ||
}} | ||
</View> | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hobbs: I would not have put this function here.