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

Allow font scalling prop #113

Open
wants to merge 2 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
7 changes: 7 additions & 0 deletions widgets/ErrorsWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const WidgetMixin = require('../mixins/WidgetMixin.js');
module.exports = React.createClass({
mixins: [WidgetMixin],

getDefaultProps() {
return {
allowTextFontScaling: true,
};
},

render() {
var errors = this.props.form.state.errors;
if (errors.length > 0) {
Expand All @@ -18,6 +24,7 @@ module.exports = React.createClass({
style={this.getStyle('errorContainer')}
>
<Text
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('errorText')}
>
{errors.join('\n')}
Expand Down
2 changes: 2 additions & 0 deletions widgets/GroupWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = React.createClass({
getDefaultProps() {
return {
type: 'GroupWidget',
allowTextFontScaling: true,
// @todo proptypes
};
},
Expand All @@ -35,6 +36,7 @@ module.exports = React.createClass({
return (
<View>
<Text
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('headerTitle')}
{...this.props}
>
Expand Down
11 changes: 6 additions & 5 deletions widgets/NoticeWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ var WidgetMixin = require('../mixins/WidgetMixin.js');

module.exports = React.createClass({
mixins: [WidgetMixin],

getDefaultProps() {
return {
type: 'NoticeWidget',
allowTextFontScaling: true,
};
},

render() {
return (
<View>
<View style={this.getStyle('noticeRow')}>
<Text
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('noticeTitle')}
{...this.props}
>
Expand All @@ -31,7 +33,7 @@ module.exports = React.createClass({
</View>
);
},

defaultStyles: {
noticeRow: {
paddingBottom: 10,
Expand All @@ -42,7 +44,6 @@ module.exports = React.createClass({
noticeTitle: {
fontSize: 13,
color: '#9b9b9b',
},
},
},
});

24 changes: 14 additions & 10 deletions widgets/OptionWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ var WidgetMixin = require('../mixins/WidgetMixin.js');

module.exports = React.createClass({
mixins: [WidgetMixin],

getDefaultProps() {
return ({
// onChange: null,
type: 'OptionWidget',
allowTextFontScaling: true,
});
},

_renderCheckmark() {
if (this.state.value === true) {
return (
Expand All @@ -33,25 +34,25 @@ module.exports = React.createClass({
}
return null;
},

_onClose() {
if (this.props.multiple === false) {
this.props.unSelectAll();
this._onChange(true);

if (typeof this.props.onSelect === 'function') {
// console.log('onSelect');
this.props.onSelect(this.props.value);
}

if (typeof this.props.onClose === 'function') {
this.props.onClose(this.props.title, this.props.navigator);
}
} else {
this._onChange(!this.state.value)
}
},

render() {
return (
<View style={this.getStyle('rowContainer')}>
Expand All @@ -62,16 +63,20 @@ module.exports = React.createClass({
>
<View style={this.getStyle('row')}>
{this._renderImage()}
<Text numberOfLines={1} style={this.getStyle('switchTitle')}>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('switchTitle')}
>
{this.props.title}
</Text>
{this._renderCheckmark()}
</View>
</View>
</TouchableHighlight>
</View>
);
},

defaultStyles: {
rowImage: {
height: 20,
Expand Down Expand Up @@ -102,4 +107,3 @@ module.exports = React.createClass({
},
},
});

19 changes: 14 additions & 5 deletions widgets/RowValueWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ var TimerMixin = require('react-timer-mixin');

module.exports = React.createClass({
mixins: [TimerMixin, WidgetMixin],

getDefaultProps() {
return {
type: 'RowValueWidget',
onPress: () => {},
disclosure: true,
allowTextFontScaling: true,
};
},

render() {
return (
<View style={this.getStyle('rowContainer')}>
Expand All @@ -36,16 +37,24 @@ module.exports = React.createClass({
>
<View style={this.getStyle('row')}>
{this._renderImage()}
<Text numberOfLines={1} style={this.getStyle('title')}>{this.props.title}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('title')}
>{this.props.title}</Text>
<View style={this.getStyle('alignRight')}>
<Text numberOfLines={1} style={this.getStyle('value')}>{this.state.value}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('value')}
>{this.state.value}</Text>
</View>
</View>
</TouchableHighlight>
</View>
);
},

defaultStyles: {
rowImage: {
height: 20,
Expand Down
15 changes: 10 additions & 5 deletions widgets/RowWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ var TimerMixin = require('react-timer-mixin');

module.exports = React.createClass({
mixins: [TimerMixin, WidgetMixin],

getDefaultProps() {
return {
type: 'RowWidget',
onPress: () => {},
disclosure: true,
allowTextFontScaling: true,
};
},

_renderDisclosure() {
if (this.props.disclosure === true) {
return (
Expand All @@ -34,7 +35,7 @@ module.exports = React.createClass({
}
return null;
},

render() {
return (
<View style={this.getStyle('rowContainer')}>
Expand All @@ -49,14 +50,18 @@ module.exports = React.createClass({
>
<View style={this.getStyle('row')}>
{this._renderImage()}
<Text numberOfLines={1} style={this.getStyle('title')}>{this.props.title}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('title')}
>{this.props.title}</Text>
{this._renderDisclosure()}
</View>
</TouchableHighlight>
</View>
);
},

defaultStyles: {
rowImage: {
height: 20,
Expand Down
17 changes: 11 additions & 6 deletions widgets/SelectCountryWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ module.exports = React.createClass({
onClose: () => {},
code: 'alpha2',
autoFocus: false,
allowTextFontScaling: true,
};
},

Expand Down Expand Up @@ -1834,9 +1835,11 @@ module.exports = React.createClass({
}}
/>

<Text numberOfLines={1} style={{
flex: 1,
}}>{rowData.name}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={{flex: 1}}
>{rowData.name}</Text>
</View>
</TouchableHighlight>
);
Expand Down Expand Up @@ -1865,9 +1868,11 @@ module.exports = React.createClass({
marginRight: 10,
}}
/>
<Text numberOfLines={1} style={{
flex: 1,
}}>{rowData.name}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={{flex: 1}}
>{rowData.name}</Text>
</View>
</TouchableHighlight>
);
Expand Down
7 changes: 6 additions & 1 deletion widgets/SwitchWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = React.createClass({
getDefaultProps() {
return {
type: 'SwitchWidget',
allowTextFontScaling: true,
};
},

Expand All @@ -43,7 +44,11 @@ module.exports = React.createClass({
<View style={this.getStyle('row')}>
{this._renderImage()}

<Text numberOfLines={1} style={this.getStyle('switchTitle')}>{this.props.title}</Text>
<Text
numberOfLines={1}
allowFontScaling={this.props.allowTextFontScaling}
style={this.getStyle('switchTitle')}
>{this.props.title}</Text>
<View style={this.getStyle('switchAlignRight')}>
<GiftedSwitch
style={this.getStyle('switch')}
Expand Down
Loading