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 allowFontScaling & fontSize props for Skip, Next, and Done labels #54

Open
wants to merge 6 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
8 changes: 6 additions & 2 deletions AppIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import RenderDots from './components/Dots';
const windowsWidth = Dimensions.get('window').width;
const windowsHeight = Dimensions.get('window').height;

const defaulStyles = {
const defaultStyles = {
header: {
flex: 0.5,
justifyContent: 'center',
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class AppIntro extends Component {
constructor(props) {
super(props);

this.styles = StyleSheet.create(assign({}, defaulStyles, props.customStyles));
this.styles = StyleSheet.create(assign({}, defaultStyles, props.customStyles));

this.state = {
skipFadeOpacity: new Animated.Value(1),
Expand Down Expand Up @@ -388,6 +388,8 @@ AppIntro.propTypes = {
showSkipButton: PropTypes.bool,
showDoneButton: PropTypes.bool,
showDots: PropTypes.bool,
allowFontScaling: PropTypes.bool,
fontSize: PropTypes.number
};

AppIntro.defaultProps = {
Expand All @@ -407,4 +409,6 @@ AppIntro.defaultProps = {
showSkipButton: true,
showDoneButton: true,
showDots: true
allowFontScaling: true,
fontSize: 22
};
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ And in Android, image inside view component, view need width、height.
| showSkipButton | bool | true | a boolean defining if we should render the skip button |
| showDoneButton | bool | true | a boolean that defines if we should render the done button |
| showDots | bool | true | a boolean that defines if we should render the bottom dots |
| allowFontScaling | bool | true | a boolean that defines if we should allow font scaling on devices with larger text sizes enabled |
| fontSize | number | 22 | a number that specifies the size of the Skip, Done, and Next labels |

##### **Children View Properties**
| Prop | PropType | Default Value | Description |
Expand Down
3 changes: 2 additions & 1 deletion components/DoneButton.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ export const DoneButton = ({
styles, onDoneBtnClick, onNextBtnClick,
rightTextColor, isDoneBtnShow,
doneBtnLabel, nextBtnLabel,
allowFontScaling, fontSize
}) => {
return (
<View style={[styles.btnContainer, { height: 0, paddingBottom: 5 }]}>
<TouchableOpacity style={styles.full}
onPress={ isDoneBtnShow ? onDoneBtnClick : onNextBtnClick}
>
<Text style={[styles.nextButtonText, { color: rightTextColor }]}>
<Text allowFontScaling={allowFontScaling} style={[styles.nextButtonText, { color: rightTextColor, fontSize }]}>
{isDoneBtnShow ? doneBtnLabel : nextBtnLabel}
</Text>
</TouchableOpacity>
Expand Down
10 changes: 5 additions & 5 deletions components/DoneButton.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const DoneButton = ({
styles, onDoneBtnClick, onNextBtnClick,
rightTextColor, isDoneBtnShow,
doneBtnLabel, nextBtnLabel,
doneFadeOpacity, skipFadeOpacity, nextOpacity
doneFadeOpacity, skipFadeOpacity, nextOpacity,
allowFontScaling, fontSize
}) => {
return (
<View style={styles.btnContainer}>
Expand All @@ -25,8 +26,8 @@ export const DoneButton = ({
}]}
>
<View style={styles.full}>
<Text style={[styles.controllText, {
color: rightTextColor, paddingRight: 30,
<Text allowFontScaling={allowFontScaling} style={[styles.controllText, {
color: rightTextColor, paddingRight: 30, fontSize
}]}>
{doneBtnLabel}
</Text>
Expand All @@ -35,7 +36,7 @@ export const DoneButton = ({
<Animated.View style={[styles.full, { height: 0 }, { opacity: nextOpacity }]}>
<TouchableOpacity style={styles.full}
onPress={ isDoneBtnShow ? onDoneBtnClick : onNextBtnClick}>
<Text style={[styles.nextButtonText, { color: rightTextColor }]}>
<Text allowFontScaling={allowFontScaling} style={[styles.nextButtonText, { color: rightTextColor, fontSize }]}>
{nextBtnLabel}
</Text>
</TouchableOpacity>
Expand All @@ -45,4 +46,3 @@ export const DoneButton = ({
}

export default DoneButton

6 changes: 4 additions & 2 deletions components/SkipButton.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const SkipButton = ({
styles, onSkipBtnClick, isSkipBtnShow,
leftTextColor,
skipBtnLabel,
skipFadeOpacity
skipFadeOpacity,
allowFontScaling,
fontSize
}) => {
return (
<View style={[styles.btnContainer, {
Expand All @@ -20,7 +22,7 @@ export const SkipButton = ({
<TouchableOpacity
style={styles.full}
onPress={isSkipBtnShow ? () => onSkipBtnClick() : null}>
<Text style={[styles.controllText, { color: leftTextColor }]}>
<Text allowFontScaling={allowFontScaling} style={[styles.controllText, { color: leftTextColor, fontSize }]}>
{skipBtnLabel}
</Text>
</TouchableOpacity>
Expand Down
5 changes: 3 additions & 2 deletions components/SkipButton.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const SkipButton = ({
styles, onSkipBtnClick, isSkipBtnShow,
leftTextColor,
skipBtnLabel,
skipFadeOpacity
skipFadeOpacity,
allowFontScaling, fontSize
}) => {
return (
<Animated.View style={[styles.btnContainer, {
Expand All @@ -26,7 +27,7 @@ export const SkipButton = ({
<TouchableOpacity
style={styles.full}
onPress={isSkipBtnShow ? () => onSkipBtnClick() : null}>
<Text style={[styles.controllText, { color: leftTextColor }]}>
<Text allowFontScaling={allowFontScaling} style={[styles.controllText, { color: leftTextColor, fontSize }]}>
{skipBtnLabel}
</Text>
</TouchableOpacity>
Expand Down