Skip to content
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

Add the option to style the container of the text View. #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions AutotypingText.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
Expand All @@ -11,18 +10,22 @@ export default class AutotypingText extends Component {

static defaultProps = {
text: '',
charMovingTime: '50',
charMovingTime: 50,
delay: 0,
style: {
color: 'black',
fontSize: 14
},
containerStyle: {
flex: 1,
}
};

static propTypes = {
text: PropTypes.string.isRequired,
charMovingTime: PropTypes.number.isRequired,
style: PropTypes.object,
containerStyle: PropTypes.object,
onComplete: PropTypes.func,
delay: PropTypes.number,
};
Expand Down Expand Up @@ -78,8 +81,8 @@ export default class AutotypingText extends Component {
render() {
let textShow = this.state.textShow;
return (
<View style={[styles.flex1]}>
<Text { ...this.props }>
<View style={this.props.containerStyle}>
<Text style={this.props.style}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackThomson2 some props (selectable, accessible, etc.), users need to pass to the Text component so I prefer to keep { ...this.props }.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackThomson2 just give you a comment. please kindly review :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure no problem I'll make the change when I get a chance 👍

{textShow}
</Text>

Expand All @@ -90,10 +93,4 @@ export default class AutotypingText extends Component {
</View>
);
}
}

const styles = StyleSheet.create({
flex1: {
flex: 1,
}
});
}
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import AutoTypingText from 'react-native-auto-typing-text';
top: 240,
left: 0,
}}
containerStyle={{
flex: 2,
alignItems: 'center',
}}
onComplete={() => { console.log('done'); }}
/>
```
Expand All @@ -40,5 +44,6 @@ import AutoTypingText from 'react-native-auto-typing-text';
|**`text`**|`string`|Text to type|
|**`charMovingTime`**|`number`|time to type each character|
|**`delay`**|`number`|Delay time before typing|
|**`style`**|`string`|Style for text|
|**`style`**|`object`|Style for text|
|**`containerStyle`**|`object`|Style for text container|
|**`onComplete`**|`func`|is called when typing completed|