-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added 'titleNumberOfLines' prop to control the truncating of title text #672
Closed
Closed
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
23ace30
Added 'titleNumberOfLine' prop to control the truncating of title text
andrenanninga 65439d1
Updated navbar to check for number isnt of just falsy value
andrenanninga 3a141cd
ensured all lines of code are less than 100 chars
andrenanninga fc84301
removed 'Integer.isNumber' and added falsy check for 'titleNumerOfLines'
andrenanninga 9669bbf
added example for itleNumberOfLines prop
andrenanninga e5ff803
improved handling of invalid or undefined itleNumberOfProps attribute
andrenanninga 27ec98d
fixed linting issues
andrenanninga 6f288c5
merge
andrenanninga 6b4a3cf
added itleNumberOfLines to API_CONFIGURATION
andrenanninga a4ff35b
remove console.log
andrenanninga cf0c730
improved attribute addition for 'numberOfLines' in navbar
andrenanninga a0295bb
merge
andrenanninga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import {View, Text, StyleSheet} from "react-native"; | ||
import Button from "react-native-button"; | ||
import {Actions} from "react-native-router-flux"; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
backgroundColor: "#F5FCFF", | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: "center", | ||
margin: 10, | ||
}, | ||
instructions: { | ||
textAlign: "center", | ||
color: "#333333", | ||
marginBottom: 5, | ||
}, | ||
}); | ||
|
||
export default class extends React.Component { | ||
constructor() { | ||
super(); | ||
this.title = "Hello world!"; | ||
|
||
this.increaseTitleLength = this.increaseTitleLength.bind(this); | ||
this.decreaseTitleLength = this.decreaseTitleLength.bind(this); | ||
this.setNumberOfLines = this.setNumberOfLines.bind(this); | ||
this.unsetNumberOfLines = this.unsetNumberOfLines.bind(this); | ||
} | ||
|
||
render(){ | ||
return ( | ||
<View style={[styles.container, this.props.style]}> | ||
<Text>Title page</Text> | ||
<Button onPress={this.increaseTitleLength}>Increase title length</Button> | ||
<Button onPress={this.decreaseTitleLength}>Decrease title length</Button> | ||
<View style={{ height: 16 }}/> | ||
<Button onPress={this.unsetNumberOfLines}>Unset numberOfLines</Button> | ||
<Button onPress={()=>this.setNumberOfLines(1)}>Set numberOfLines to 1</Button> | ||
<Button onPress={Actions.pop}>Back</Button> | ||
</View> | ||
); | ||
} | ||
|
||
increaseTitleLength() { | ||
this.title += "Hello World!"; | ||
|
||
Actions.refresh({title: this.title}); | ||
} | ||
|
||
decreaseTitleLength() { | ||
if(this.title.length > 12) { | ||
this.title = this.title.slice(0, -12); | ||
} | ||
|
||
Actions.refresh({title: this.title}); | ||
} | ||
|
||
unsetNumberOfLines() { | ||
Actions.refresh({titleNumberOfLines: null}); | ||
} | ||
|
||
setNumberOfLines(numberOfLines) { | ||
Actions.refresh({titleNumberOfLines: numberOfLines}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure how you can add a conditional attribute in jsx, so I've added a check for the
titleNumberOfLines
prop that will return the<Animated.Text/>
component with thenumberOflines
attribute.I would love to know if there is a better way to handle this case as now there is a lot of extra code just for a single optional attribute.
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.
Ya you can simplify this quite a bit and not have to duplicate anything:
Want to try that and then lets see how it looks?
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.
oh nice, I didn't know that was possible.