Skip to content

Commit 4b9414f

Browse files
committed
autoscale update
1 parent f36a750 commit 4b9414f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

App/Components/AutoScaleText.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class AutoScaleText extends React.Component {
1212
static propTypes = {
1313
...Text.propTypes,
1414
maxFontSize: React.PropTypes.number.isRequired,
15-
maxHeight: React.PropTypes.number.isRequired,
15+
//maxHeight: React.PropTypes.number.isRequired,
1616
color: React.PropTypes.string,
17-
style: React.PropTypes.oneOfType([
18-
Text.propTypes.style,
19-
React.PropTypes.shape({
20-
width: React.PropTypes.number,
21-
}),
22-
]).isRequired,
17+
//style: React.PropTypes.oneOfType([
18+
// React.PropTypes.number,
19+
// React.PropTypes.shape({
20+
// width: React.PropTypes.number,
21+
// }),
22+
//]),
2323
};
2424

2525
static defaultProps = {
@@ -31,17 +31,21 @@ class AutoScaleText extends React.Component {
3131

3232
this.state = {
3333
fontSize: props.maxFontSize,
34-
finished: false,
34+
finished: null,
3535
};
3636

37-
this.visible = true;
37+
this.visible = true
3838
}
3939

4040
determineFontSize = () => {
4141
UIManager.measure(ReactNative.findNodeHandle(this.refs.textView), (x, y, w, h, px, py) => {
4242
if (!this.visible) return;
4343

44-
if (h > this.props.maxHeight) {
44+
var tooBig = this.props.maxHeight && h > this.props.maxHeight;
45+
if (!tooBig) {
46+
tooBig = this.props.maxWidth && w > this.props.maxWidth;
47+
}
48+
if (tooBig) {
4549
this.setState({
4650
fontSize: this.state.fontSize - 0.5,
4751
});
@@ -61,13 +65,14 @@ class AutoScaleText extends React.Component {
6165
return (
6266
<Text
6367
ref='textView'
64-
onLayout={this.determineFontSize}
68+
//onLayout={this.determineFontSize}
69+
allowFontScaling={false}
6570
{...this.props}
6671
style={[
6772
this.props.style,
6873
{
6974
fontSize: this.state.fontSize,
70-
color: this.state.finished ? this.props.color : 'transparent',
75+
//color: this.state.finished ? this.props.color || 'black' : 'transparent',
7176
},
7277
]}
7378
>

0 commit comments

Comments
 (0)